/* libmisc/_intercept.h - Interceptable ("weak") functions * * Copyright (C) 2024-2025 Luke T. Shumaker * SPDX-License-Identifier: AGPL-3.0-or-later */ #ifndef _LIBMISC__INTERCEPT_H_ #define _LIBMISC__INTERCEPT_H_ #include /* 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. */ [[gnu::format(printf, 1, 2)]] size_t __lm_printf(const char *format, ...); [[noreturn]] void __lm_abort(void); /* __lm_light_printf is expected to have less stack use than regular * __lm_printf, if possible. */ [[gnu::format(printf, 1, 2)]] size_t __lm_light_printf(const char *format, ...); #endif /* _LIBMISC__INTERCEPT_H_ */