diff --git a/drivers/console/efi_console.c b/drivers/console/efi_console.c index 245510dbca5..ac4ff17b39f 100644 --- a/drivers/console/efi_console.c +++ b/drivers/console/efi_console.c @@ -17,6 +17,7 @@ #include #include #include +#include extern int efi_console_putchar(int c); @@ -39,10 +40,6 @@ static int console_out(int c) #endif -#if defined(CONFIG_STDOUT_CONSOLE) -extern void __stdout_hook_install(int (*hook)(int)); -#endif - /** * @brief Install printk/stdout hook for EFI console output */ diff --git a/drivers/console/ipm_console.c b/drivers/console/ipm_console.c index aed3e25eb0b..9c9f51a8fff 100644 --- a/drivers/console/ipm_console.c +++ b/drivers/console/ipm_console.c @@ -9,6 +9,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(ipm_console, CONFIG_IPM_LOG_LEVEL); @@ -42,10 +43,6 @@ static int console_out(int c) return c; } -#if defined(CONFIG_STDOUT_CONSOLE) -extern void __stdout_hook_install(int (*hook)(int)); -#endif - /* Install printk/stdout hooks */ static void ipm_console_hook_install(void) { diff --git a/drivers/console/ipm_console_sender.c b/drivers/console/ipm_console_sender.c index a0888f1c779..03e261ec5f1 100644 --- a/drivers/console/ipm_console_sender.c +++ b/drivers/console/ipm_console_sender.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -31,8 +32,6 @@ static int consoleOut(int character) return character; } -extern void __stdout_hook_install(int (*fn)(int)); - int ipm_console_sender_init(const struct device *d) { const struct ipm_console_sender_config_info *config_info; diff --git a/drivers/console/jailhouse_debug_console.c b/drivers/console/jailhouse_debug_console.c index 1a9b514bf9b..bf31a530001 100644 --- a/drivers/console/jailhouse_debug_console.c +++ b/drivers/console/jailhouse_debug_console.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -26,10 +27,6 @@ static int console_out(int c) } #endif -#if defined(CONFIG_STDOUT_CONSOLE) -extern void __stdout_hook_install(int (*hook)(int)); -#endif - /** * @brief Initialize the console/debug port * @return 0 if successful, otherwise failed. diff --git a/drivers/console/posix_arch_console.c b/drivers/console/posix_arch_console.c index a118a8bb161..7d2dab02faa 100644 --- a/drivers/console/posix_arch_console.c +++ b/drivers/console/posix_arch_console.c @@ -8,6 +8,7 @@ #include #include #include +#include #define _STDOUT_BUF_SIZE 256 static char stdout_buff[_STDOUT_BUF_SIZE]; @@ -55,7 +56,6 @@ static int posix_arch_console_init(void) __printk_hook_install(print_char); #endif #ifdef CONFIG_STDOUT_CONSOLE - extern void __stdout_hook_install(int (*fn)(int)); __stdout_hook_install(print_char); #endif return 0; diff --git a/drivers/console/ram_console.c b/drivers/console/ram_console.c index b2762a9b495..9544544fb5b 100644 --- a/drivers/console/ram_console.c +++ b/drivers/console/ram_console.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -28,8 +29,6 @@ #define RAM_CONSOLE_BUF_ATTR #endif -extern void __stdout_hook_install(int (*fn)(int)); - char ram_console_buf[CONFIG_RAM_CONSOLE_BUFFER_SIZE] RAM_CONSOLE_BUF_ATTR; char *ram_console; static int pos; diff --git a/drivers/console/rtt_console.c b/drivers/console/rtt_console.c index 8baf05d23e7..a5cd7bb051a 100644 --- a/drivers/console/rtt_console.c +++ b/drivers/console/rtt_console.c @@ -12,12 +12,11 @@ #include #include #include +#include #include #include #include -extern void __stdout_hook_install(int (*fn)(int)); - static bool host_present; /** @brief Wait for fixed period. diff --git a/drivers/console/semihost_console.c b/drivers/console/semihost_console.c index 6c7655189c0..3f500b3e56b 100644 --- a/drivers/console/semihost_console.c +++ b/drivers/console/semihost_console.c @@ -7,8 +7,7 @@ #include #include #include - -extern void __stdout_hook_install(int (*fn)(int)); +#include int arch_printk_char_out(int _c) { @@ -18,7 +17,6 @@ int arch_printk_char_out(int _c) static int semihost_console_init(void) { - /* * The printk output callback is arch_printk_char_out by default and * is installed at link time. That makes printk() usable very early. diff --git a/drivers/console/uart_console.c b/drivers/console/uart_console.c index 43d65d40370..8d776ff7aee 100644 --- a/drivers/console/uart_console.c +++ b/drivers/console/uart_console.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #ifdef CONFIG_UART_CONSOLE_MCUMGR #include @@ -111,10 +112,6 @@ static int console_out(int c) #endif -#if defined(CONFIG_STDOUT_CONSOLE) -extern void __stdout_hook_install(int (*hook)(int c)); -#endif - #if defined(CONFIG_CONSOLE_HANDLER) static struct k_fifo *avail_queue; static struct k_fifo *lines_queue; diff --git a/drivers/console/winstream_console.c b/drivers/console/winstream_console.c index ac018b619ac..79794068ce8 100644 --- a/drivers/console/winstream_console.c +++ b/drivers/console/winstream_console.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -47,10 +48,6 @@ int arch_printk_char_out(int c) return 0; } -#if defined(CONFIG_STDOUT_CONSOLE) -extern void __stdout_hook_install(int (*hook)(int)); -#endif - static void winstream_console_hook_install(void) { #if defined(CONFIG_STDOUT_CONSOLE) diff --git a/drivers/console/xtensa_sim_console.c b/drivers/console/xtensa_sim_console.c index a7a8513ea37..9347ed2647e 100644 --- a/drivers/console/xtensa_sim_console.c +++ b/drivers/console/xtensa_sim_console.c @@ -7,6 +7,7 @@ #include #include #include +#include #if defined(CONFIG_PRINTK) || defined(CONFIG_STDOUT_CONSOLE) /** @@ -34,10 +35,6 @@ int arch_printk_char_out(int c) } #endif -#if defined(CONFIG_STDOUT_CONSOLE) -extern void __stdout_hook_install(int (*hook)(int)); -#endif - /** * @brief Install printk/stdout hook for Xtensa Simulator console output */ diff --git a/drivers/serial/uart_hvc_xen.c b/drivers/serial/uart_hvc_xen.c index 8fa4a06ca88..800603fc258 100644 --- a/drivers/serial/uart_hvc_xen.c +++ b/drivers/serial/uart_hvc_xen.c @@ -18,6 +18,7 @@ #include #include #include +#include #include LOG_MODULE_REGISTER(uart_hvc_xen, CONFIG_UART_LOG_LEVEL); @@ -268,8 +269,6 @@ DEVICE_DT_DEFINE(DT_NODELABEL(xen_hvc), xen_console_init, NULL, &xen_hvc_data, &xen_hvc_api); #ifdef CONFIG_XEN_EARLY_CONSOLEIO -extern void __stdout_hook_install(int (*fn)(int)); - int xen_consoleio_putc(int c) { char symbol = (char) c; diff --git a/include/zephyr/sys/libc-hooks.h b/include/zephyr/sys/libc-hooks.h index e737fc6872d..5455bdf29a7 100644 --- a/include/zephyr/sys/libc-hooks.h +++ b/include/zephyr/sys/libc-hooks.h @@ -44,6 +44,8 @@ __syscall size_t zephyr_fwrite(const void *ZRESTRICT ptr, size_t size, #endif /* CONFIG_NEWLIB_LIBC */ +void __stdout_hook_install(int (*hook)(int)); + #ifdef CONFIG_USERSPACE #ifdef CONFIG_COMMON_LIBC_MALLOC diff --git a/subsys/bluetooth/host/monitor.c b/subsys/bluetooth/host/monitor.c index abc84a7837c..980d91410f5 100644 --- a/subsys/bluetooth/host/monitor.c +++ b/subsys/bluetooth/host/monitor.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -260,8 +261,6 @@ static int monitor_console_out(int c) return c; } - -extern void __stdout_hook_install(int (*fn)(int)); #endif /* !CONFIG_UART_CONSOLE && !CONFIG_RTT_CONSOLE && !CONFIG_LOG_PRINTK */ #ifndef CONFIG_LOG_MODE_MINIMAL