diff options
-rw-r--r-- | src/localconsts.h | 26 | ||||
-rw-r--r-- | src/logger.h | 59 |
2 files changed, 35 insertions, 50 deletions
diff --git a/src/localconsts.h b/src/localconsts.h index a120ed9d7..6d922ab09 100644 --- a/src/localconsts.h +++ b/src/localconsts.h @@ -171,6 +171,32 @@ #define gnu_printf printf #endif // __clang__ + +#ifdef __GNUC__ + #ifdef __OpenBSD__ + #define A_FORMAT_PRINTF(fmtIndex, firstArgIndex) \ + __attribute__((__format__(printf, (fmtIndex), (firstArgIndex)))) + #else // __OpenBSD__ + + #ifdef BAD_CILKPLUS + // This one is 0-indexed? + #define A_FORMAT_PRINTF(fmtIndex, firstArgIndex) \ + __attribute__((__format__(gnu_printf, \ + ((fmtIndex) - 1), \ + ((firstArgIndex)-1) \ + ))) + #else // BAD_CILKPLUS + #define A_FORMAT_PRINTF(fmtIndex, firstArgIndex) \ + __attribute__((__format__(gnu_printf, \ + (fmtIndex), \ + (firstArgIndex) \ + ))) + #endif // BAD_CILKPLUS + + #endif // __OpenBSD__ +#endif // __GNUC__ + + #ifdef ADVGCC #define const2 const diff --git a/src/logger.h b/src/logger.h index b8c48e429..89f4c5286 100644 --- a/src/logger.h +++ b/src/logger.h @@ -91,64 +91,23 @@ class Logger final /** * Enters a message in the log. The message will be timestamped. */ - void log(const char *const log_text, ...) A_NONNULL(2) -#ifdef __GNUC__ -#ifdef __OpenBSD__ - - __attribute__((__format__(printf, 2, 3))) -#else // __OpenBSD__ - -#ifdef BAD_CILKPLUS - __attribute__((__format__(gnu_printf, 1, 2))) -#else // BAD_CILKPLUS - - __attribute__((__format__(gnu_printf, 2, 3))) -#endif // BAD_CILKPLUS - -#endif // __OpenBSD__ -#endif // __GNUC__ - ; + void log(const char *const log_text, ...) + A_NONNULL(2) + A_FORMAT_PRINTF(2, 3); /** * Enters a message in the log. The message will be timestamped. */ - void assertLog(const char *const log_text, ...) A_NONNULL(2) -#ifdef __GNUC__ -#ifdef __OpenBSD__ - - __attribute__((__format__(printf, 2, 3))) -#else // __OpenBSD__ - -#ifdef BAD_CILKPLUS - __attribute__((__format__(gnu_printf, 1, 2))) -#else // BAD_CILKPLUS - - __attribute__((__format__(gnu_printf, 2, 3))) -#endif // BAD_CILKPLUS - -#endif // __OpenBSD__ -#endif // __GNUC__ - ; + void assertLog(const char *const log_text, ...) + A_NONNULL(2) + A_FORMAT_PRINTF(2, 3); /** * Enters a message in the log (thread safe). */ - void log_r(const char *const log_text, ...) A_NONNULL(2) -#ifdef __GNUC__ -#ifdef __OpenBSD__ - __attribute__((__format__(printf, 2, 3))) -#else // __OpenBSD__ - -#ifdef BAD_CILKPLUS - __attribute__((__format__(gnu_printf, 1, 2))) -#else // BAD_CILKPLUS - - __attribute__((__format__(gnu_printf, 2, 3))) -#endif // BAD_CILKPLUS - -#endif // __OpenBSD__ -#endif // __GNUC__ - ; + void log_r(const char *const log_text, ...) + A_NONNULL(2) + A_FORMAT_PRINTF(2, 3); /** * Enters a message in the log. The message will be timestamped. |