nissy-core

The "engine" of nissy, including the H48 optimal solver.
git clone https://git.tronto.net/nissy-core
Download | Log | Files | Refs | README | LICENSE

dbg_log.h (805B)


      1 #include <stdio.h>
      2 
      3 void (*nissy_log)(const char *, void *);
      4 void *nissy_log_data;
      5 void write_wrapper(void (*)(const char *, void *), const char *, ...);
      6 
      7 void
      8 write_wrapper(void (*write)(const char *, void *), const char *str, ...)
      9 {
     10 	char message[1000];
     11 	va_list args;
     12 
     13 	va_start(args, str);
     14 	vsprintf(message, str, args);
     15 	va_end(args);
     16 
     17 	write(message, nissy_log_data);
     18 }
     19 
     20 #define LOG(...) if (nissy_log != NULL) write_wrapper(nissy_log, __VA_ARGS__);
     21 
     22 #ifdef DEBUG
     23 #define STATIC
     24 #define STATIC_INLINE
     25 #define DBG_WARN(condition, ...) if (!(condition)) LOG(__VA_ARGS__);
     26 #define DBG_ASSERT(condition, ...) \
     27     if (!(condition)) { LOG(__VA_ARGS__); exit(1); }
     28 #else
     29 #define STATIC static
     30 #define STATIC_INLINE static inline
     31 #define DBG_WARN(condition, ...)
     32 #define DBG_ASSERT(condition, ...)
     33 #endif