fix UC_ASSERT writing to wrong fd, and unterminated if

log more in UC_NOTREACHED
This commit is contained in:
Nils O. Selåsdal
2013-10-08 17:39:44 +02:00
parent 425062ad18
commit 08a50d8cfe
+11 -4
View File
@@ -84,19 +84,26 @@ const typeof( ((const type *)0)->member ) *__mptr = (ptr); \
/**
* assert() that is not affected by NDEBUG define
*/
#define UC_ASSERT(expr) do {\
if (!(expr) ) {\
#define UC_ASSERT(expr)\
do {\
if (!(expr) ) {\
fprintf(stderr,\
"UC_ASSERT failed '%s' %s:%d\n", UC_STRINGIFY(expr), __FILE__, __LINE__);\
uc_backtrace_fd(3);\
uc_backtrace_fd(2);\
abort();\
}\
} while (0)
/**
* Macro for asserting code that should not be reached,
* terminates the program if executed
*/
#define UC_NOT_REACED() abort()
#define UC_NOT_REACED()\
do {\
fprintf(stderr, "UC_NOT_REACED at %s:%d\n", __FILE__, __LINE__);\
uc_backtrace_fd(2);\
abort();\
while (0)
/**
* Round up X / y