1 2 3 4 5 6 7 8 9 10 |
/* CV_CALL macro calls CV (or IPL) function, checks error status and signals a error if the function failed. Useful in "parent node" error procesing mode */ #define CV_CALL( Func ) \ { \ Func; \ CV_CHECK(); \ } |
1 2 3 4 5 6 7 8 9 10 |
/* CV_CHECK macro checks error status after CV (or IPL) function call. If error detected, control will be transferred to the exit label. */ #define CV_CHECK() \ { \ if( cvGetErrStatus() < 0 ) \ CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ } |
a
1 2 3 4 |
CV_IMPL int cvGetErrStatus() { return icvGetContext()->err_code; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
static CvContext* icvGetContext(void) { #ifdef CV_DLL #if defined WIN32 || defined WIN64 CvContext* context; //assert(g_TlsIndex != TLS_OUT_OF_INDEXES); if( g_TlsIndex == TLS_OUT_OF_INDEXES ) { g_TlsIndex = TlsAlloc(); if( g_TlsIndex == TLS_OUT_OF_INDEXES ) FatalAppExit( 0, "Only set CV_DLL for DLL usage" ); } context = (CvContext*)TlsGetValue( g_TlsIndex ); if( !context ) { context = icvCreateContext(); if( !context ) FatalAppExit( 0, "OpenCV. Problem to allocate memory for TLS OpenCV context." ); TlsSetValue( g_TlsIndex, context ); } return context; #else CvContext* context = (CvContext*)pthread_getspecific( g_TlsIndex ); if( !context ) { context = icvCreateContext(); if( !context ) { fprintf(stderr,"OpenCV. Problem to allocate memory for OpenCV context."); exit(1); } pthread_setspecific( g_TlsIndex, context ); } return context; #endif #else /* static single-thread library case */ static CvContext* context = 0; if( !context ) context = icvCreateContext(); return context; #endif } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
typedef struct { const char* file; int line; } CvStackRecord; typedef struct CvContext { int err_code; int err_mode; CvErrorCallback error_callback; void* userdata; char err_msg[4096]; CvStackRecord err_ctx; } CvContext; |