Changeset 4970:5fd50d4ef2ea in roaraudio


Ignore:
Timestamp:
05/16/11 13:50:52 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_panic()

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/libroar.h

    r4965 r4970  
    203203int roar_reset(int forked); 
    204204 
     205// fatal probelms: 
     206enum roar_fatal_error { 
     207 ROAR_FATAL_ERROR_NONE = 0,          // ??? 
     208 ROAR_FATAL_ERROR_UNKNOWN,           // Unknown error 
     209 ROAR_FATAL_ERROR_MEMORY_CORRUPTION, // some structure has been corrupted 
     210 ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD, // memory was corruppted but no data has been harmed (yet) 
     211 ROAR_FATAL_ERROR_CPU_FAILTURE,      // CPU general CPU failture 
     212 
     213 ROAR_FATAL_ERROR_EOL 
     214}; 
     215 
     216#if __STDC_VERSION__ < 199901L 
     217#if __GNUC__ >= 2 
     218#define __roar_func__ __FUNCTION__ 
     219#else 
     220#define __roar_func__ NULL 
     221#endif 
     222#else 
     223#define __roar_func__ __func__ 
     224#endif 
     225 
     226#define roar_panic(err,info) roar_panic_real((err), (info), __LINE__, __FILE__, ROAR_DBG_PREFIX, __roar_func__) 
     227void roar_panic_real(enum roar_fatal_error error, const char * info, 
     228                     unsigned long int line, const char * file, const char * prefix, const char * func); 
     229 
    205230#endif 
    206231 
  • libroar.ckport

    r4969 r4970  
    88roar_vio_open_get_cookie        unknown 
    99roar_reset                      wip     Do not use yet 
     10roar_panic_real                 maybe   Mostly for internal use only. 
    1011 
    1112# VIO: 
  • libroar/libroar.c

    r4965 r4970  
    161161} 
    162162 
     163void roar_panic_real(enum roar_fatal_error error, const char * info, 
     164                     unsigned long int line, const char * file, const char * prefix, const char * func) { 
     165 const char * errname = NULL; 
     166//#define ROAR_ERR(format, args...)  roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, __LINE__, __FILE__, ROAR_DBG_PREFIX, format, ## args) 
     167 
     168 if ( func == NULL ) 
     169  func = "<unknown>"; 
     170 
     171 switch (error) { 
     172  case ROAR_FATAL_ERROR_MEMORY_CORRUPTION_GUARD: 
     173    roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a guard segment memory corruption has happened. Backup your data and terminate this program. Report this lion to developer. Thanks.", func); 
     174    return; 
     175   break; 
     176  case ROAR_FATAL_ERROR_UNKNOWN: 
     177    errname = "<unknown error>"; 
     178   break; 
     179  case ROAR_FATAL_ERROR_MEMORY_CORRUPTION: 
     180    errname = "Memory corruption"; 
     181   break; 
     182  case ROAR_FATAL_ERROR_CPU_FAILTURE: 
     183    errname = "CPU failture, replace hardware"; 
     184   break; 
     185  default: 
     186    errname = "<unknown error code, BAD>"; 
     187   break; 
     188 } 
     189 
     190 roar_debug_msg(ROAR_DEBUG_TYPE_ERROR, line, file, prefix, "in %s() a _FATAL_ error of type \"%s\" happend. Terminating program. Report this lion to developer. Thanks.", func, errname); 
     191 
     192#ifdef SIGKILL 
     193 raise(SIGKILL); 
     194#endif 
     195 abort(); 
     196 
     197 while(1); 
     198} 
     199 
    163200//ll 
Note: See TracChangeset for help on using the changeset viewer.