#include <cstdlib>
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#if _MSC_VER
#include <crtdbg.h>
#define __TBB_USE_DBGBREAK_DLG TBB_USE_DEBUG
#endif
#if _MSC_VER >= 1400
#define __TBB_EXPORTED_FUNC __cdecl
#else
#define __TBB_EXPORTED_FUNC
#endif
using namespace std;
#if __TBBMALLOC_BUILD
namespace rml { namespace internal {
#else
namespace tbb {
#endif
typedef void(*assertion_handler_type)( const char* filename, int line, const char* expression, const char * comment );
static assertion_handler_type assertion_handler;
assertion_handler_type __TBB_EXPORTED_FUNC set_assertion_handler( assertion_handler_type new_handler ) {
assertion_handler_type old_handler = assertion_handler;
assertion_handler = new_handler;
return old_handler;
}
void __TBB_EXPORTED_FUNC assertion_failure( const char* filename, int line, const char* expression, const char* comment ) {
if( assertion_handler_type a = assertion_handler ) {
(*a)(filename,line,expression,comment);
} else {
static bool already_failed;
if( !already_failed ) {
already_failed = true;
fprintf( stderr, "Assertion %s failed on line %d of file %s\n",
expression, line, filename );
if( comment )
fprintf( stderr, "Detailed description: %s\n", comment );
#if __TBB_USE_DBGBREAK_DLG
if(1 == _CrtDbgReport(_CRT_ASSERT, filename, line, "tbb_debug.dll", "%s\r\n%s", expression, comment?comment:""))
_CrtDbgBreak();
#else
fflush(stderr);
abort();
#endif
}
}
}
#if defined(_MSC_VER)&&_MSC_VER<1400
# define vsnprintf _vsnprintf
#endif
#if !__TBBMALLOC_BUILD
namespace internal {
void __TBB_EXPORTED_FUNC runtime_warning( const char* format, ... )
{
char str[1024]; memset(str, 0, 1024);
va_list args; va_start(args, format);
vsnprintf( str, 1024-1, format, args);
va_end(args);
fprintf( stderr, "TBB Warning: %s\n", str);
}
}
#endif
#if __TBBMALLOC_BUILD
}}
#else
}
#endif