diff --git a/makefiles/pseudomodules.inc.mk b/makefiles/pseudomodules.inc.mk index 063eb10722..c2a03b2d4a 100644 --- a/makefiles/pseudomodules.inc.mk +++ b/makefiles/pseudomodules.inc.mk @@ -152,6 +152,7 @@ PSEUDOMODULES += sock_udp PSEUDOMODULES += socket_zep_hello PSEUDOMODULES += soft_uart_modecfg PSEUDOMODULES += stdin +PSEUDOMODULES += stdio_available PSEUDOMODULES += stdio_cdc_acm PSEUDOMODULES += stdio_ethos PSEUDOMODULES += stdio_uart_rx diff --git a/sys/Kconfig.stdio b/sys/Kconfig.stdio index f031cb0f43..f167e26988 100644 --- a/sys/Kconfig.stdio +++ b/sys/Kconfig.stdio @@ -53,6 +53,11 @@ config MODULE_STDIO_UART_RX help Reception when using UART-based STDIO needs to be enabled. +config MODULE_STDIO_AVAILABLE + bool + help + Indicates that the implementation supports function stdio_available + config MODULE_PRINTF_FLOAT bool "Float support in printf" diff --git a/sys/include/stdio_base.h b/sys/include/stdio_base.h index e76bd2ff19..d9a972064f 100644 --- a/sys/include/stdio_base.h +++ b/sys/include/stdio_base.h @@ -25,6 +25,8 @@ #include +#include "kernel_defines.h" + #ifdef __cplusplus extern "C" { #endif @@ -34,6 +36,18 @@ extern "C" { */ void stdio_init(void); +#if IS_USED(MODULE_STDIO_AVAILABLE) || DOXYGEN +/** + * @brief Get the number of bytes available for reading from stdio. + * + * @warning This function is only available if the implementation supports + * it and the @c stdio_available module is enabled. + * + * @return number of available bytes + */ +int stdio_available(void); +#endif + /** * @brief read @p len bytes from stdio uart into @p buffer *