diff options
Diffstat (limited to 'src/utils')
| -rw-r--r-- | src/utils/dbg_log.h | 21 | ||||
| -rw-r--r-- | src/utils/math.h | 4 |
2 files changed, 21 insertions, 4 deletions
diff --git a/src/utils/dbg_log.h b/src/utils/dbg_log.h index f9b1d8a..c30993a 100644 --- a/src/utils/dbg_log.h +++ b/src/utils/dbg_log.h | |||
| @@ -1,6 +1,23 @@ | |||
| 1 | void (*nissy_log)(const char *, ...); | 1 | #include <stdio.h> |
| 2 | 2 | ||
| 3 | #define LOG(...) if (nissy_log != NULL) nissy_log(__VA_ARGS__); | 3 | void (*nissy_log)(const char *); |
| 4 | void write_wrapper(void (*)(const char *), const char *, ...); | ||
| 5 | |||
| 6 | void | ||
| 7 | write_wrapper(void (*write)(const char *), const char *str, ...) | ||
| 8 | { | ||
| 9 | static const size_t len = 1000; | ||
| 10 | char message[len]; | ||
| 11 | va_list args; | ||
| 12 | |||
| 13 | va_start(args, str); | ||
| 14 | sprintf(message, str, args); | ||
| 15 | va_end(args); | ||
| 16 | |||
| 17 | write(message); | ||
| 18 | } | ||
| 19 | |||
| 20 | #define LOG(...) if (nissy_log != NULL) write_wrapper(nissy_log, __VA_ARGS__); | ||
| 4 | 21 | ||
| 5 | #ifdef DEBUG | 22 | #ifdef DEBUG |
| 6 | #define STATIC | 23 | #define STATIC |
diff --git a/src/utils/math.h b/src/utils/math.h index a9d9b85..1ae4013 100644 --- a/src/utils/math.h +++ b/src/utils/math.h | |||
| @@ -168,8 +168,8 @@ sumzerotodigits(int64_t d, size_t n, uint8_t b, uint8_t a[n]) | |||
| 168 | size_t i; | 168 | size_t i; |
| 169 | 169 | ||
| 170 | if (!((n == 8 && b == 3 ) || (n == 12 && b == 2))) { | 170 | if (!((n == 8 && b == 3 ) || (n == 12 && b == 2))) { |
| 171 | LOG("Won't compute 'digits' for n=%" PRIu8 "and b=%" PRIu8 | 171 | LOG("Won't compute 'digits' for n=%zu and b=%" PRIu8 |
| 172 | " (use n=8 b=3 or n=12 b=2)\n"); | 172 | " (use n=8 b=3 or n=12 b=2)\n", n, b); |
| 173 | goto sumzerotodigits_error; | 173 | goto sumzerotodigits_error; |
| 174 | } | 174 | } |
| 175 | 175 | ||
