ALL: changed ASSURE macro to leverage sim_printf for log and debug output.

This commit is contained in:
Mark Pizzolato 2015-10-27 21:07:03 -07:00
parent 9ee290ac49
commit 7266304105

View file

@ -108,6 +108,9 @@
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define snprintf _snprintf /* poor man's snprintf which will work most of the time but has different return value */
#endif
#include <stdarg.h> #include <stdarg.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
@ -844,11 +847,9 @@ typedef struct sim_bitfield BITFIELD;
/* This replaces any references to "assert()" which should never be invoked */ /* This replaces any references to "assert()" which should never be invoked */
/* with an expression which causes side effects (i.e. must be executed for */ /* with an expression which causes side effects (i.e. must be executed for */
/* the program to work correctly) */ /* the program to work correctly) */
#define ASSURE(_Expression) if (!(_Expression)) {const char *_exp = #_Expression; const char *_file = __FILE__; \ #define ASSURE(_Expression) while (!(_Expression)) {fprintf(stderr, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
fprintf(stderr, "%s failed at %s line %d\n", _exp, _file, __LINE__); \ sim_printf("%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
if (sim_log) fprintf(sim_log, "%s failed at %s line %d\n", _exp, _file, __LINE__); \ abort();}
if (sim_deb) fprintf(sim_deb, "%s failed at %s line %d\n", _exp, _file, __LINE__); \
abort();} else (void)0
/* Asynch/Threaded I/O support */ /* Asynch/Threaded I/O support */