diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-15 00:18:27 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2025-05-15 14:58:17 -0600 |
commit | 3faaad9fe1f11cfe5699c6720c897bfddc7cf49a (patch) | |
tree | f15758869c758eeeb7604afc5c03e8d7601d8315 /libmisc/include | |
parent | 9c0338b1b4495457659157e1e9f47d422dcefc2e (diff) |
Begone with the printf variants of the log functions
Diffstat (limited to 'libmisc/include')
-rw-r--r-- | libmisc/include/libmisc/_intercept.h | 14 | ||||
-rw-r--r-- | libmisc/include/libmisc/log.h | 10 |
2 files changed, 5 insertions, 19 deletions
diff --git a/libmisc/include/libmisc/_intercept.h b/libmisc/include/libmisc/_intercept.h index f02244a..fa327d6 100644 --- a/libmisc/include/libmisc/_intercept.h +++ b/libmisc/include/libmisc/_intercept.h @@ -7,18 +7,12 @@ #ifndef _LIBMISC__INTERCEPT_H_ #define _LIBMISC__INTERCEPT_H_ -#include <stddef.h> /* for size_t */ - -/* pico-sdk/newlib define printf() and abort() to be [[gnu::weak]] - * already, but depending on optimization options glibc might not, and - * GCC might assume it knows what they do and optimize them out. So - * define our own `__lm_` wrappers that GCC/glibc won't interfere - * with. +/* pico-sdk/newlib defines abort() to be [[gnu::weak]] already, but + * depending on optimization options glibc might not, and GCC might + * assume it knows what it does and optimize it out. So define our + * own `__lm_` wrapper that GCC/glibc won't interfere with. */ -[[gnu::format(printf, 1, 2)]] -size_t __lm_printf(const char *format, ...); - [[noreturn]] void __lm_abort(void); /* While newlib defines putchar() to be [[gnu::weak]], pico_stdio does diff --git a/libmisc/include/libmisc/log.h b/libmisc/include/libmisc/log.h index 78ee1e7..e6dfb52 100644 --- a/libmisc/include/libmisc/log.h +++ b/libmisc/include/libmisc/log.h @@ -23,11 +23,6 @@ const char *const_byte_str(uint8_t b); extern lo_interface fmt_dest _log_dest; -#define log_n_errorf(nam, fmt, ...) do { __lm_printf("error: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) -#define log_n_infof(nam, fmt, ...) do { __lm_printf("info : " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) -#define log_n_debugf(nam, fmt, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \ - __lm_printf("debug: " LM_STR_(nam) ": " fmt "\n" __VA_OPT__(,) __VA_ARGS__); } while (0) - #define log_n_errorln(nam, ...) fmt_print(_log_dest, "error: " LM_STR_(nam) ": ", __VA_ARGS__, "\n") #define log_n_infoln(nam, ...) fmt_print(_log_dest, "info : " LM_STR_(nam) ": ", __VA_ARGS__, "\n") #define log_n_debugln(nam, ...) do { if (LM_CAT3_(CONFIG_, nam, _DEBUG) && !_LOG_NDEBUG) \ @@ -35,10 +30,7 @@ extern lo_interface fmt_dest _log_dest; #endif /* _LIBMISC_LOG_H_ */ -#if defined(LOG_NAME) && !defined(log_errorf) -#define log_errorf(fmt, ...) log_n_errorf(LOG_NAME, fmt, __VA_ARGS__) -#define log_infof(fmt, ...) log_n_infof(LOG_NAME, fmt, __VA_ARGS__) -#define log_debugf(fmt, ...) log_n_debugf(LOG_NAME, fmt, __VA_ARGS__) +#if defined(LOG_NAME) && !defined(log_errorln) #define log_errorln(...) log_n_errorln(LOG_NAME, __VA_ARGS__) #define log_infoln(...) log_n_infoln(LOG_NAME, __VA_ARGS__) #define log_debugln(...) log_n_debugln(LOG_NAME, __VA_ARGS__) |