This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new f6e5be7972f include/stdio.h: Hide the kernel file system types from
kernel-build programs.
f6e5be7972f is described below
commit f6e5be7972fdbc2ca0a4bcaf4898907051858430
Author: Marco Casaroli <[email protected]>
AuthorDate: Tue Oct 13 09:43:34 2026 +0200
include/stdio.h: Hide the kernel file system types from kernel-build
programs.
stdio.h included nuttx/fs/fs.h and nuttx/lib/lib.h, so every program
that includes stdio.h saw the kernel's struct file, struct inode and the
other file system types. A program that defines its own struct file
does not compile.
stdio.h no longer includes nuttx/lib/lib.h in any build, and includes
nuttx/fs/fs.h only for kernel code and for flat and protected builds.
In the user space of a kernel build (CONFIG_BUILD_KERNEL and not
__KERNEL__) programs cannot use the file system types anyway, so they
do not see them. Doing the same for flat and protected builds breaks
many files that rely on the indirect include.
stdio.h now defines what it needs itself: the fopencookie() callback
types, struct file_struct and its __FS_FLAG_* flags, which were in
nuttx/fs/fs.h, and the declaration of lib_get_stream(), which stdin,
stdout and stderr expand to. struct streamlist moves from
nuttx/fs/fs.h to nuttx/tls.h, where struct task_info_s holds the stream
list. nuttx/tls.h includes stdio.h for struct file_struct.
The files that used kernel types or other headers through stdio.h now
include what they use.
Assisted-by: Claude Code:claude-opus-5-5
Signed-off-by: Marco Casaroli <[email protected]>
---
arch/arm/src/stm32h7/stm32_crypto.c | 1 +
arch/arm/src/xmc4/xmc4_i2c.c | 1 +
arch/risc-v/src/bl808/bl808_gpadc.c | 1 +
.../risc-v/src/common/espressif/esp_allocateheap.c | 1 +
arch/risc-v/src/common/espressif/esp_gpio.c | 1 +
arch/risc-v/src/common/espressif/esp_i2c_slave.c | 1 +
arch/risc-v/src/common/espressif/esp_i2s.c | 1 +
arch/risc-v/src/common/espressif/esp_irq.c | 1 +
arch/risc-v/src/common/espressif/esp_spi.c | 1 +
.../src/common/espressif/esp_temperature_sensor.c | 1 +
arch/sim/src/sim/sim_gpiochip.c | 1 +
arch/xtensa/src/common/espressif/esp_i2c_slave.c | 1 +
arch/xtensa/src/common/espressif/esp_irq.c | 1 +
arch/xtensa/src/esp32s2/esp32s2_spi.c | 1 +
arch/xtensa/src/esp32s3/esp32s3_partition.c | 1 +
.../stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c | 1 +
.../arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c | 1 +
.../pic32mx/pic32mx7mmb/src/pic32_touchscreen.c | 1 +
boards/risc-v/esp32c2/common/src/esp_board_adc.c | 1 +
boards/risc-v/esp32c3/common/src/esp_board_adc.c | 1 +
boards/risc-v/esp32c6/common/src/esp_board_adc.c | 1 +
.../risc-v/esp32c6/common/src/esp_board_mpu60x0.c | 1 +
boards/risc-v/esp32h2/common/src/esp_board_adc.c | 1 +
boards/risc-v/esp32p4/common/src/esp_board_adc.c | 1 +
boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c | 1 +
boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c | 1 +
boards/xtensa/esp32/common/src/esp32_board_adc.c | 1 +
.../xtensa/esp32s2/common/src/esp32s2_board_adc.c | 1 +
.../xtensa/esp32s3/common/src/esp32s3_board_adc.c | 1 +
drivers/analog/ads1115.c | 1 +
drivers/analog/ads7046.c | 1 +
drivers/analog/mcp47x6.c | 1 +
drivers/leds/ktd2052.c | 1 +
drivers/mtd/mtd_cfi.c | 1 +
drivers/net/oa_tc6/oa_tc6.c | 1 +
drivers/net/telnet.c | 1 +
drivers/pci/pci_uio_ivshmem.c | 1 +
drivers/rpmsg/rpmsg_virtio_ivshmem.c | 1 +
drivers/rptun/rptun_bmp.c | 1 +
drivers/timers/pl031.c | 1 +
drivers/usbdev/cdcncm.c | 1 +
drivers/video/goldfish_camera.c | 1 +
drivers/virtio/virtio-pci.c | 1 +
drivers/virtio/virtio-rpmb.c | 1 +
drivers/wireless/bluetooth/bt_uart.c | 1 +
drivers/wireless/gs2200m.c | 1 +
fs/smartfs/smartfs_utils.c | 1 +
fs/xipfs/xipfs_mmap.c | 1 +
include/nuttx/fs/fs.h | 102 -------------------
include/nuttx/fs/procfs.h | 5 +-
include/nuttx/tls.h | 12 +++
include/stdio.h | 112 ++++++++++++++++++++-
libs/libbuiltin/libgcc/gcov.c | 1 +
libs/libc/gdbstub/lib_gdbstub.c | 1 +
libs/libc/libc.h | 1 +
libs/libc/locale/lib_iconv.c | 2 +
libs/libc/misc/lib_ftok.c | 2 +
libs/libc/netdb/lib_netdb.h | 1 +
libs/libc/pwd/lib_getspnamr.c | 1 +
libs/libc/signal/sig_psignal.c | 1 +
libs/libc/stdio/lib_clearerr.c | 1 +
libs/libc/stdio/lib_feof.c | 1 +
libs/libc/stdio/lib_ferror.c | 1 +
libs/libc/stdio/lib_fgetwc.c | 2 +
libs/libc/stdio/lib_fileno.c | 1 +
libs/libc/stdio/lib_libfilelock.c | 1 +
libs/libc/stdio/lib_printf.c | 1 +
libs/libc/stdio/lib_putwchar.c | 2 +
libs/libc/stdio/lib_remove.c | 1 +
libs/libc/stdio/lib_ungetwc.c | 3 +
libs/libc/stdio/lib_vasprintf.c | 1 +
libs/libc/stdio/lib_vprintf.c | 1 +
libs/libc/unistd/lib_getpass.c | 1 +
sched/misc/coredump.c | 1 +
74 files changed, 199 insertions(+), 108 deletions(-)
diff --git a/arch/arm/src/stm32h7/stm32_crypto.c
b/arch/arm/src/stm32h7/stm32_crypto.c
index 9ff3b164a97..42e087939e5 100644
--- a/arch/arm/src/stm32h7/stm32_crypto.c
+++ b/arch/arm/src/stm32h7/stm32_crypto.c
@@ -33,6 +33,7 @@
#include <crypto/cryptodev.h>
#include <crypto/xform.h>
#include <nuttx/crypto/crypto.h>
+#include <nuttx/kmalloc.h>
#include "arm_internal.h"
#include "hardware/stm32h7x3xx_rcc.h"
diff --git a/arch/arm/src/xmc4/xmc4_i2c.c b/arch/arm/src/xmc4/xmc4_i2c.c
index 38414abd5b3..e62bb0f2db2 100644
--- a/arch/arm/src/xmc4/xmc4_i2c.c
+++ b/arch/arm/src/xmc4/xmc4_i2c.c
@@ -34,6 +34,7 @@
#include <nuttx/debug.h>
#include <arch/board/board.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/irq.h>
diff --git a/arch/risc-v/src/bl808/bl808_gpadc.c
b/arch/risc-v/src/bl808/bl808_gpadc.c
index f80447e2bde..3901e0034d7 100644
--- a/arch/risc-v/src/bl808/bl808_gpadc.c
+++ b/arch/risc-v/src/bl808/bl808_gpadc.c
@@ -40,6 +40,7 @@
#include <nuttx/fs/ioctl.h>
#include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h>
+#include <nuttx/kmalloc.h>
#include "hardware/bl808_gpadc.h"
#include "riscv_internal.h"
diff --git a/arch/risc-v/src/common/espressif/esp_allocateheap.c
b/arch/risc-v/src/common/espressif/esp_allocateheap.c
index 5e562aedf49..29566a5f497 100644
--- a/arch/risc-v/src/common/espressif/esp_allocateheap.c
+++ b/arch/risc-v/src/common/espressif/esp_allocateheap.c
@@ -32,6 +32,7 @@
#include <arch/board/board.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mm/mm.h>
#include "riscv_internal.h"
diff --git a/arch/risc-v/src/common/espressif/esp_gpio.c
b/arch/risc-v/src/common/espressif/esp_gpio.c
index c10ea7d6b92..ec82ee659c4 100644
--- a/arch/risc-v/src/common/espressif/esp_gpio.c
+++ b/arch/risc-v/src/common/espressif/esp_gpio.c
@@ -40,6 +40,7 @@
#include <arch/irq.h>
#include <nuttx/arch.h>
#include <nuttx/irq.h>
+#include <nuttx/kmalloc.h>
/* Arch */
diff --git a/arch/risc-v/src/common/espressif/esp_i2c_slave.c
b/arch/risc-v/src/common/espressif/esp_i2c_slave.c
index dbbb06ba2e7..1f4c6a847b7 100644
--- a/arch/risc-v/src/common/espressif/esp_i2c_slave.c
+++ b/arch/risc-v/src/common/espressif/esp_i2c_slave.c
@@ -43,6 +43,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/signal.h>
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
diff --git a/arch/risc-v/src/common/espressif/esp_i2s.c
b/arch/risc-v/src/common/espressif/esp_i2s.c
index e831672eb42..e10b00e7bce 100644
--- a/arch/risc-v/src/common/espressif/esp_i2s.c
+++ b/arch/risc-v/src/common/espressif/esp_i2s.c
@@ -33,6 +33,7 @@
#include <stdint.h>
#include <math.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nuttx.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
diff --git a/arch/risc-v/src/common/espressif/esp_irq.c
b/arch/risc-v/src/common/espressif/esp_irq.c
index 945da04b0b1..0ee7d29c392 100644
--- a/arch/risc-v/src/common/espressif/esp_irq.c
+++ b/arch/risc-v/src/common/espressif/esp_irq.c
@@ -34,6 +34,7 @@
#include <nuttx/irq.h>
#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
#include "irq/irq.h"
diff --git a/arch/risc-v/src/common/espressif/esp_spi.c
b/arch/risc-v/src/common/espressif/esp_spi.c
index d74a6e27932..a655e858b32 100644
--- a/arch/risc-v/src/common/espressif/esp_spi.c
+++ b/arch/risc-v/src/common/espressif/esp_spi.c
@@ -41,6 +41,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/spi/spi.h>
#include <nuttx/nuttx.h>
diff --git a/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
b/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
index 07a512a6f60..df88b0f88c7 100644
--- a/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
+++ b/arch/risc-v/src/common/espressif/esp_temperature_sensor.c
@@ -25,6 +25,7 @@
****************************************************************************/
#include <nuttx/config.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nuttx.h>
#ifdef CONFIG_ESPRESSIF_TEMP
diff --git a/arch/sim/src/sim/sim_gpiochip.c b/arch/sim/src/sim/sim_gpiochip.c
index 52906811888..e437b2a6e0d 100644
--- a/arch/sim/src/sim/sim_gpiochip.c
+++ b/arch/sim/src/sim/sim_gpiochip.c
@@ -23,6 +23,7 @@
****************************************************************************/
#include <nuttx/debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/wdog.h>
#include <nuttx/ioexpander/gpio.h>
#include <nuttx/ioexpander/ioexpander.h>
diff --git a/arch/xtensa/src/common/espressif/esp_i2c_slave.c
b/arch/xtensa/src/common/espressif/esp_i2c_slave.c
index 94d6d9cb454..c65cff7c34f 100644
--- a/arch/xtensa/src/common/espressif/esp_i2c_slave.c
+++ b/arch/xtensa/src/common/espressif/esp_i2c_slave.c
@@ -43,6 +43,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/semaphore.h>
#include <nuttx/i2c/i2c_slave.h>
diff --git a/arch/xtensa/src/common/espressif/esp_irq.c
b/arch/xtensa/src/common/espressif/esp_irq.c
index b7396d59b31..56b62833b56 100644
--- a/arch/xtensa/src/common/espressif/esp_irq.c
+++ b/arch/xtensa/src/common/espressif/esp_irq.c
@@ -34,6 +34,7 @@
#include <string.h>
#include <nuttx/irq.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <arch/irq.h>
diff --git a/arch/xtensa/src/esp32s2/esp32s2_spi.c
b/arch/xtensa/src/esp32s2/esp32s2_spi.c
index 30e1c7bfdb1..b6ebff6dd23 100644
--- a/arch/xtensa/src/esp32s2/esp32s2_spi.c
+++ b/arch/xtensa/src/esp32s2/esp32s2_spi.c
@@ -39,6 +39,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mutex.h>
#include <nuttx/spinlock.h>
#include <nuttx/spi/spi.h>
diff --git a/arch/xtensa/src/esp32s3/esp32s3_partition.c
b/arch/xtensa/src/esp32s3/esp32s3_partition.c
index ba261f3ec6a..8b267a4614f 100644
--- a/arch/xtensa/src/esp32s3/esp32s3_partition.c
+++ b/arch/xtensa/src/esp32s3/esp32s3_partition.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <nuttx/kmalloc.h>
+#include <nuttx/lib/lib.h>
#include "esp32s3_spiflash_mtd.h"
#include "esp32s3_partition.h"
diff --git a/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c
b/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c
index 35c3f8eced2..923e46fa895 100644
--- a/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c
+++ b/boards/arm/stm32f4/mikroe-stm32f4/src/stm32_touchscreen.c
@@ -38,6 +38,7 @@
#include <nuttx/irq.h>
#include <nuttx/board.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/wqueue.h>
#include <nuttx/fs/fs.h>
#include <nuttx/input/touchscreen.h>
diff --git a/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c
b/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c
index eff17a00c9b..aeb59bd1867 100644
--- a/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c
+++ b/boards/arm/tiva/tm4c1294-launchpad/src/tm4c_bringup.c
@@ -31,6 +31,7 @@
#include <nuttx/debug.h>
#include <nuttx/i2c/i2c_master.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/sensors/bmi160.h>
#include <nuttx/sensors/bmp280.h>
#include <nuttx/sensors/mpu60x0.h>
diff --git a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c
b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c
index 53ca39a95c2..7251ef75bdd 100644
--- a/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c
+++ b/boards/mips/pic32mx/pic32mx7mmb/src/pic32_touchscreen.c
@@ -37,6 +37,7 @@
#include <nuttx/board.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/wqueue.h>
#include <nuttx/fs/fs.h>
#include <nuttx/input/touchscreen.h>
diff --git a/boards/risc-v/esp32c2/common/src/esp_board_adc.c
b/boards/risc-v/esp32c2/common/src/esp_board_adc.c
index aaf61adedc0..074d458a7de 100644
--- a/boards/risc-v/esp32c2/common/src/esp_board_adc.c
+++ b/boards/risc-v/esp32c2/common/src/esp_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/risc-v/esp32c3/common/src/esp_board_adc.c
b/boards/risc-v/esp32c3/common/src/esp_board_adc.c
index e16c5d291f2..4db4ef7a9ef 100644
--- a/boards/risc-v/esp32c3/common/src/esp_board_adc.c
+++ b/boards/risc-v/esp32c3/common/src/esp_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/risc-v/esp32c6/common/src/esp_board_adc.c
b/boards/risc-v/esp32c6/common/src/esp_board_adc.c
index 726c2bf94b0..a9cae026ee9 100644
--- a/boards/risc-v/esp32c6/common/src/esp_board_adc.c
+++ b/boards/risc-v/esp32c6/common/src/esp_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/risc-v/esp32c6/common/src/esp_board_mpu60x0.c
b/boards/risc-v/esp32c6/common/src/esp_board_mpu60x0.c
index 53d35e7c4ae..a87d972d1f1 100644
--- a/boards/risc-v/esp32c6/common/src/esp_board_mpu60x0.c
+++ b/boards/risc-v/esp32c6/common/src/esp_board_mpu60x0.c
@@ -30,6 +30,7 @@
#include <nuttx/debug.h>
#include <nuttx/arch.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/sensors/mpu60x0.h>
#include <nuttx/i2c/i2c_master.h>
diff --git a/boards/risc-v/esp32h2/common/src/esp_board_adc.c
b/boards/risc-v/esp32h2/common/src/esp_board_adc.c
index 5401507d08d..7b2dc0b0f76 100644
--- a/boards/risc-v/esp32h2/common/src/esp_board_adc.c
+++ b/boards/risc-v/esp32h2/common/src/esp_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/risc-v/esp32p4/common/src/esp_board_adc.c
b/boards/risc-v/esp32p4/common/src/esp_board_adc.c
index 786ecb6f6b2..4759f7f8e85 100644
--- a/boards/risc-v/esp32p4/common/src/esp_board_adc.c
+++ b/boards/risc-v/esp32p4/common/src/esp_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c
b/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c
index 6f889a5e178..b148ea14567 100644
--- a/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c
+++ b/boards/sparc/bm3803/xx3803/src/bm3803_am29lv.c
@@ -35,6 +35,7 @@
#include <nuttx/debug.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/kmalloc.h>
#ifdef CONFIG_MTD_AM29LV
# include <nuttx/mtd/mtd.h>
# include <nuttx/fs/nxffs.h>
diff --git a/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c
b/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c
index d04d144a21a..47dcb1ce574 100644
--- a/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c
+++ b/boards/sparc/bm3823/xx3823/src/bm3823_am29lv.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <errno.h>
#include <nuttx/debug.h>
+#include <nuttx/kmalloc.h>
#ifdef CONFIG_MTD_AM29LV
# include <nuttx/mtd/mtd.h>
diff --git a/boards/xtensa/esp32/common/src/esp32_board_adc.c
b/boards/xtensa/esp32/common/src/esp32_board_adc.c
index 07c41e542a4..4a19c6526a7 100644
--- a/boards/xtensa/esp32/common/src/esp32_board_adc.c
+++ b/boards/xtensa/esp32/common/src/esp32_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/xtensa/esp32s2/common/src/esp32s2_board_adc.c
b/boards/xtensa/esp32s2/common/src/esp32s2_board_adc.c
index 0990315a5a4..71f6718d133 100644
--- a/boards/xtensa/esp32s2/common/src/esp32s2_board_adc.c
+++ b/boards/xtensa/esp32s2/common/src/esp32s2_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/boards/xtensa/esp32s3/common/src/esp32s3_board_adc.c
b/boards/xtensa/esp32s3/common/src/esp32s3_board_adc.c
index 1c8322e7cd9..d0fa9cf4489 100644
--- a/boards/xtensa/esp32s3/common/src/esp32s3_board_adc.c
+++ b/boards/xtensa/esp32s3/common/src/esp32s3_board_adc.c
@@ -29,6 +29,7 @@
#include <syslog.h>
#include <nuttx/analog/adc.h>
+#include <nuttx/kmalloc.h>
#include "espressif/esp_adc.h"
diff --git a/drivers/analog/ads1115.c b/drivers/analog/ads1115.c
index 9577cfdd752..86e64ba60d5 100644
--- a/drivers/analog/ads1115.c
+++ b/drivers/analog/ads1115.c
@@ -25,6 +25,7 @@
****************************************************************************/
#include <nuttx/config.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nuttx.h>
#include <nuttx/signal.h>
diff --git a/drivers/analog/ads7046.c b/drivers/analog/ads7046.c
index d79a193c1e0..150e17a8096 100644
--- a/drivers/analog/ads7046.c
+++ b/drivers/analog/ads7046.c
@@ -39,6 +39,7 @@
#include <nuttx/analog/adc.h>
#include <nuttx/analog/ioctl.h>
#include <nuttx/analog/ads7046.h>
+#include <nuttx/kmalloc.h>
/****************************************************************************
* Pre-processor Definitions
diff --git a/drivers/analog/mcp47x6.c b/drivers/analog/mcp47x6.c
index f65f23eb47f..e862fc4c185 100644
--- a/drivers/analog/mcp47x6.c
+++ b/drivers/analog/mcp47x6.c
@@ -39,6 +39,7 @@
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/analog/mcp47x6.h>
+#include <nuttx/kmalloc.h>
/****************************************************************************
* Preprocessor definitions
diff --git a/drivers/leds/ktd2052.c b/drivers/leds/ktd2052.c
index 298c9568248..1a0e969f67b 100644
--- a/drivers/leds/ktd2052.c
+++ b/drivers/leds/ktd2052.c
@@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <nuttx/i2c/i2c_master.h>
#include <nuttx/fs/ioctl.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/leds/ktd2052.h>
#include <stdio.h>
diff --git a/drivers/mtd/mtd_cfi.c b/drivers/mtd/mtd_cfi.c
index ff04913fd81..cbaaba51ace 100644
--- a/drivers/mtd/mtd_cfi.c
+++ b/drivers/mtd/mtd_cfi.c
@@ -32,6 +32,7 @@
#include <nuttx/fs/ioctl.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mtd/mtd.h>
#include "cfi.h"
diff --git a/drivers/net/oa_tc6/oa_tc6.c b/drivers/net/oa_tc6/oa_tc6.c
index d7337c33586..85fb0594e44 100644
--- a/drivers/net/oa_tc6/oa_tc6.c
+++ b/drivers/net/oa_tc6/oa_tc6.c
@@ -30,6 +30,7 @@
#include <nuttx/debug.h>
#include <sys/endian.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/net/ioctl.h>
#ifdef CONFIG_NET_OA_TC6_NCV7410
diff --git a/drivers/net/telnet.c b/drivers/net/telnet.c
index 78bff9addb0..7369b591fd1 100644
--- a/drivers/net/telnet.c
+++ b/drivers/net/telnet.c
@@ -36,6 +36,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/kthread.h>
+#include <nuttx/lib/lib.h>
#include <nuttx/signal.h>
#include <nuttx/mutex.h>
#include <nuttx/fs/fs.h>
diff --git a/drivers/pci/pci_uio_ivshmem.c b/drivers/pci/pci_uio_ivshmem.c
index 9340dda5180..1eadf730519 100644
--- a/drivers/pci/pci_uio_ivshmem.c
+++ b/drivers/pci/pci_uio_ivshmem.c
@@ -34,6 +34,7 @@
#include <stdlib.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mm/map.h>
#include <nuttx/pci/pci_ivshmem.h>
#include <nuttx/semaphore.h>
diff --git a/drivers/rpmsg/rpmsg_virtio_ivshmem.c
b/drivers/rpmsg/rpmsg_virtio_ivshmem.c
index 21183eb6962..2eec277d038 100644
--- a/drivers/rpmsg/rpmsg_virtio_ivshmem.c
+++ b/drivers/rpmsg/rpmsg_virtio_ivshmem.c
@@ -31,6 +31,7 @@
#include <stdio.h>
#include <nuttx/drivers/addrenv.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/pci/pci_ivshmem.h>
#include <nuttx/rpmsg/rpmsg_virtio_ivshmem.h>
#include <nuttx/rpmsg/rpmsg_virtio_lite.h>
diff --git a/drivers/rptun/rptun_bmp.c b/drivers/rptun/rptun_bmp.c
index f7b3394cb87..3a749f6d3c1 100644
--- a/drivers/rptun/rptun_bmp.c
+++ b/drivers/rptun/rptun_bmp.c
@@ -24,6 +24,7 @@
* Included Files
****************************************************************************/
+#include <nuttx/kmalloc.h>
#include <nuttx/rptun/rptun.h>
#include <nuttx/rptun/rptun_bmp.h>
#include <nuttx/sched.h>
diff --git a/drivers/timers/pl031.c b/drivers/timers/pl031.c
index 0ff350d5339..38aaa4a0a8f 100644
--- a/drivers/timers/pl031.c
+++ b/drivers/timers/pl031.c
@@ -30,6 +30,7 @@
#include <nuttx/arch.h>
#include <nuttx/irq.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/timers/rtc.h>
#include <nuttx/timers/pl031.h>
diff --git a/drivers/usbdev/cdcncm.c b/drivers/usbdev/cdcncm.c
index 161fd2950fd..ede6cb00a25 100644
--- a/drivers/usbdev/cdcncm.c
+++ b/drivers/usbdev/cdcncm.c
@@ -38,6 +38,7 @@
#include <stdbool.h>
#include <sys/poll.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/net/netdev_lowerhalf.h>
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/cdc.h>
diff --git a/drivers/video/goldfish_camera.c b/drivers/video/goldfish_camera.c
index 0354bcad599..5ac39611dc8 100644
--- a/drivers/video/goldfish_camera.c
+++ b/drivers/video/goldfish_camera.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <string.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/nuttx.h>
#include <nuttx/kthread.h>
#include <nuttx/video/imgsensor.h>
diff --git a/drivers/virtio/virtio-pci.c b/drivers/virtio/virtio-pci.c
index 168b087661c..79b6c56cf08 100644
--- a/drivers/virtio/virtio-pci.c
+++ b/drivers/virtio/virtio-pci.c
@@ -32,6 +32,7 @@
#include <sys/param.h>
#include <nuttx/clock.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/virtio/virtio-pci.h>
#include "virtio-pci.h"
diff --git a/drivers/virtio/virtio-rpmb.c b/drivers/virtio/virtio-rpmb.c
index d395cd9f901..9ca8d5fb45b 100644
--- a/drivers/virtio/virtio-rpmb.c
+++ b/drivers/virtio/virtio-rpmb.c
@@ -30,6 +30,7 @@
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/semaphore.h>
#include <nuttx/spinlock.h>
#include <nuttx/mmcsd.h>
diff --git a/drivers/wireless/bluetooth/bt_uart.c
b/drivers/wireless/bluetooth/bt_uart.c
index e761625b8e2..1e174de9223 100644
--- a/drivers/wireless/bluetooth/bt_uart.c
+++ b/drivers/wireless/bluetooth/bt_uart.c
@@ -44,6 +44,7 @@
#include <errno.h>
#include <nuttx/debug.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/net/bluetooth.h>
#include <nuttx/wireless/bluetooth/bt_core.h>
diff --git a/drivers/wireless/gs2200m.c b/drivers/wireless/gs2200m.c
index afa922f6182..428ba552628 100644
--- a/drivers/wireless/gs2200m.c
+++ b/drivers/wireless/gs2200m.c
@@ -51,6 +51,7 @@
#include <nuttx/arch.h>
#include <nuttx/spi/spi.h>
#include <nuttx/kmalloc.h>
+#include <nuttx/lib/lib.h>
#include <nuttx/wqueue.h>
#include <nuttx/mutex.h>
#include <nuttx/signal.h>
diff --git a/fs/smartfs/smartfs_utils.c b/fs/smartfs/smartfs_utils.c
index f81e980acf8..8155077b2fe 100644
--- a/fs/smartfs/smartfs_utils.c
+++ b/fs/smartfs/smartfs_utils.c
@@ -39,6 +39,7 @@
#include <nuttx/kmalloc.h>
#include <nuttx/fs/fs.h>
#include <nuttx/fs/ioctl.h>
+#include <nuttx/lib/lib.h>
#include "smartfs.h"
#include "fs_heap.h"
diff --git a/fs/xipfs/xipfs_mmap.c b/fs/xipfs/xipfs_mmap.c
index 580b271c43c..aeb02ca9862 100644
--- a/fs/xipfs/xipfs_mmap.c
+++ b/fs/xipfs/xipfs_mmap.c
@@ -51,6 +51,7 @@
#include <debug.h>
#include <errno.h>
+#include <nuttx/kmalloc.h>
#include <nuttx/mm/map.h>
#include <nuttx/sched.h>
diff --git a/include/nuttx/fs/fs.h b/include/nuttx/fs/fs.h
index 36c039888ec..f55547c6180 100644
--- a/include/nuttx/fs/fs.h
+++ b/include/nuttx/fs/fs.h
@@ -102,13 +102,6 @@
# define _NX_GETERRVAL(r) (-errno)
#endif
-/* Stream flags for the fs_flags field of in struct file_struct */
-
-#define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */
-#define __FS_FLAG_ERROR (1 << 1) /* Error detected by any operation */
-#define __FS_FLAG_LBF (1 << 2) /* Line buffered */
-#define __FS_FLAG_UBF (1 << 3) /* Buffer allocated by caller of setvbuf */
-
/* Inode i_flags values:
*
* Bit 0-3: Inode type (Bit 3 indicates internal OS types)
@@ -478,33 +471,6 @@ struct inode
#define FSNODE_SIZE(n) (sizeof(struct inode) + (n))
-/* Definitions for custom stream operations with fopencookie. The
- * implementation is as defined in Standard C library (libc). The only
- * difference is that we use off_t instead of off64_t. This means
- * off_t is int64_t if CONFIG_FS_LARGEFILE is defined and int32_t if not.
- *
- * These callbacks can either lead to custom functions if fopencookie is used
- * or to standard file system functions if not.
- */
-
-typedef CODE ssize_t cookie_read_function_t(FAR void *cookie, FAR char *buf,
- size_t size);
-typedef CODE ssize_t cookie_write_function_t(FAR void *cookie,
- FAR const char *buf,
- size_t size);
-typedef CODE off_t cookie_seek_function_t(FAR void *cookie,
- FAR off_t *offset,
- int whence);
-typedef CODE int cookie_close_function_t(FAR void *cookie);
-
-typedef struct cookie_io_functions_t
-{
- FAR cookie_read_function_t *read;
- FAR cookie_write_function_t *write;
- FAR cookie_seek_function_t *seek;
- FAR cookie_close_function_t *close;
-} cookie_io_functions_t;
-
/* This is the underlying representation of an open file. A file
* descriptor is an index into an array of such types. The type associates
* the file descriptor to the file state and to a set of inode operations.
@@ -560,74 +526,6 @@ struct fdlist
struct fd fl_prefds[CONFIG_NFILE_DESCRIPTORS_PER_BLOCK];
};
-/* The following structure defines the list of files used for standard C I/O.
- * Note that NuttX can support the standard C APIs with or without buffering
- *
- * When buffering is used, the following describes the usage of the I/O
- * buffer.
- * The buffer can be used for reading or writing -- but not both at the same
- * time.
- * An fflush is implied between each change in direction of access.
- *
- * The field fs_bufread determines whether the buffer is being used for
- * reading or for writing as follows:
- *
- * BUFFER
- * +----------------------+ <- fs_bufstart Points to the beginning of
- * | | the buffer.
- * | WR: Buffered data | WR: Start of buffered write
- * | | data.
- * | RD: Already read | RD: Start of already read
- * | | data.
- * +----------------------+
- * | WR: Available buffer | <- fs_bufpos Points to next byte:
- * | RD: Read-ahead data | WR: End+1 of buffered write
- * | | data.
- * | | RD: Points to next char to
- * | | return
- * +----------------------+
- * | WR: Available | <- fs_bufread Top+1 of buffered read data
- * | RD: Available | WR: bufstart buffer used for
- * | | writing.
- * | | RD: Pointer to last buffered
- * | | read char+1
- * +----------------------+
- * <- fs_bufend Points to the end of the
- * buffer+1
- */
-
-#ifdef CONFIG_FILE_STREAM
-struct file_struct
-{
- sq_entry_t fs_entry; /* Entry of file stream */
- rmutex_t fs_lock; /* Recursive lock */
- cookie_io_functions_t fs_iofunc; /* Callbacks to user / system
functions */
- FAR void *fs_cookie; /* Pointer to file descriptor / cookie
struct */
-#ifndef CONFIG_STDIO_DISABLE_BUFFERING
- FAR char *fs_bufstart; /* Pointer to start of buffer */
- FAR char *fs_bufend; /* Pointer to 1 past end of buffer */
- FAR char *fs_bufpos; /* Current position in buffer */
- FAR char *fs_bufread; /* Pointer to 1 past last buffered
read char. */
-# if CONFIG_STDIO_BUFFER_SIZE > 0
- char fs_buffer[CONFIG_STDIO_BUFFER_SIZE];
-# endif
-#endif
- uint16_t fs_oflags; /* Open mode flags */
- uint8_t fs_flags; /* Stream flags */
-#if CONFIG_NUNGET_CHARS > 0
- uint8_t fs_nungotten; /* The number of characters buffered
for ungetc */
- char fs_ungotten[CONFIG_NUNGET_CHARS];
-#endif
-};
-
-struct streamlist
-{
- mutex_t sl_lock; /* For thread safety */
- struct file_struct sl_std[3];
- sq_queue_t sl_queue;
-};
-#endif /* CONFIG_FILE_STREAM */
-
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
diff --git a/include/nuttx/fs/procfs.h b/include/nuttx/fs/procfs.h
index 35ebca03334..ca369008fbd 100644
--- a/include/nuttx/fs/procfs.h
+++ b/include/nuttx/fs/procfs.h
@@ -29,6 +29,7 @@
#include <nuttx/config.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/mm/mm.h>
/****************************************************************************
* Pre-processor Definitions
@@ -130,10 +131,6 @@ struct procfs_dir_priv_s
/* An entry for procfs_register_meminfo */
-struct mallinfo;
-struct mm_heap_s;
-struct mm_memdump_s;
-
struct procfs_meminfo_entry_s
{
FAR const char *name;
diff --git a/include/nuttx/tls.h b/include/nuttx/tls.h
index e7b673aed5f..256bfd15a14 100644
--- a/include/nuttx/tls.h
+++ b/include/nuttx/tls.h
@@ -31,6 +31,7 @@
#include <stdint.h>
#include <stdbool.h>
+#include <stdio.h>
#include <arch/arch.h>
#include <arch/types.h>
@@ -39,6 +40,8 @@
#include <nuttx/cache.h>
#include <nuttx/atexit.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/mutex.h>
+#include <nuttx/queue.h>
#ifdef CONFIG_PTHREAD_ATFORK
# include <nuttx/list.h>
@@ -75,6 +78,15 @@
* Public Types
****************************************************************************/
+#ifdef CONFIG_FILE_STREAM
+struct streamlist
+{
+ mutex_t sl_lock; /* For thread safety */
+ struct file_struct sl_std[3];
+ sq_queue_t sl_queue;
+};
+#endif /* CONFIG_FILE_STREAM */
+
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
diff --git a/include/stdio.h b/include/stdio.h
index 1aa4e6691b5..0311f96bffb 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -33,8 +33,17 @@
#include <stdarg.h>
#include <time.h>
-#include <nuttx/fs/fs.h>
-#include <nuttx/lib/lib.h>
+#include <nuttx/mutex.h>
+#include <nuttx/queue.h>
+
+/* Kernel code, and every program of a flat or protected build, still sees
+ * the file system types through stdio.h. The programs of a kernel build
+ * cannot use them, and do not see them.
+ */
+
+#if !defined(CONFIG_BUILD_KERNEL) || defined(__KERNEL__)
+# include <nuttx/fs/fs.h>
+#endif
/****************************************************************************
* Pre-processor Definitions
@@ -59,6 +68,13 @@
#define _IOLBF 1 /* Line buffered */
#define _IONBF 2 /* Unbuffered */
+/* Stream flags for the fs_flags field of in struct file_struct */
+
+#define __FS_FLAG_EOF (1 << 0) /* EOF detected by a read operation */
+#define __FS_FLAG_ERROR (1 << 1) /* Error detected by any operation */
+#define __FS_FLAG_LBF (1 << 2) /* Line buffered */
+#define __FS_FLAG_UBF (1 << 3) /* Buffer allocated by caller of setvbuf */
+
/* File system error values */
#define EOF (-1)
@@ -109,6 +125,94 @@
* Public Type Definitions
****************************************************************************/
+/* Definitions for custom stream operations with fopencookie. The
+ * implementation is as defined in Standard C library (libc). The only
+ * difference is that we use off_t instead of off64_t. This means
+ * off_t is int64_t if CONFIG_FS_LARGEFILE is defined and int32_t if not.
+ *
+ * These callbacks can either lead to custom functions if fopencookie is used
+ * or to standard file system functions if not.
+ */
+
+typedef CODE ssize_t cookie_read_function_t(FAR void *cookie, FAR char *buf,
+ size_t size);
+typedef CODE ssize_t cookie_write_function_t(FAR void *cookie,
+ FAR const char *buf,
+ size_t size);
+typedef CODE off_t cookie_seek_function_t(FAR void *cookie,
+ FAR off_t *offset,
+ int whence);
+typedef CODE int cookie_close_function_t(FAR void *cookie);
+
+typedef struct cookie_io_functions_t
+{
+ FAR cookie_read_function_t *read;
+ FAR cookie_write_function_t *write;
+ FAR cookie_seek_function_t *seek;
+ FAR cookie_close_function_t *close;
+} cookie_io_functions_t;
+
+/* The following structure defines the list of files used for standard C I/O.
+ * Note that NuttX can support the standard C APIs with or without buffering
+ *
+ * When buffering is used, the following describes the usage of the I/O
+ * buffer.
+ * The buffer can be used for reading or writing -- but not both at the same
+ * time.
+ * An fflush is implied between each change in direction of access.
+ *
+ * The field fs_bufread determines whether the buffer is being used for
+ * reading or for writing as follows:
+ *
+ * BUFFER
+ * +----------------------+ <- fs_bufstart Points to the beginning of
+ * | | the buffer.
+ * | WR: Buffered data | WR: Start of buffered write
+ * | | data.
+ * | RD: Already read | RD: Start of already read
+ * | | data.
+ * +----------------------+
+ * | WR: Available buffer | <- fs_bufpos Points to next byte:
+ * | RD: Read-ahead data | WR: End+1 of buffered write
+ * | | data.
+ * | | RD: Points to next char to
+ * | | return
+ * +----------------------+
+ * | WR: Available | <- fs_bufread Top+1 of buffered read data
+ * | RD: Available | WR: bufstart buffer used for
+ * | | writing.
+ * | | RD: Pointer to last buffered
+ * | | read char+1
+ * +----------------------+
+ * <- fs_bufend Points to the end of the
+ * buffer+1
+ */
+
+#ifdef CONFIG_FILE_STREAM
+struct file_struct
+{
+ sq_entry_t fs_entry; /* Entry of file stream */
+ rmutex_t fs_lock; /* Recursive lock */
+ cookie_io_functions_t fs_iofunc; /* Callbacks to user / system
functions */
+ FAR void *fs_cookie; /* Pointer to file descriptor / cookie
struct */
+#ifndef CONFIG_STDIO_DISABLE_BUFFERING
+ FAR char *fs_bufstart; /* Pointer to start of buffer */
+ FAR char *fs_bufend; /* Pointer to 1 past end of buffer */
+ FAR char *fs_bufpos; /* Current position in buffer */
+ FAR char *fs_bufread; /* Pointer to 1 past last buffered
read char. */
+# if CONFIG_STDIO_BUFFER_SIZE > 0
+ char fs_buffer[CONFIG_STDIO_BUFFER_SIZE];
+# endif
+#endif
+ uint16_t fs_oflags; /* Open mode flags */
+ uint8_t fs_flags; /* Stream flags */
+#if CONFIG_NUNGET_CHARS > 0
+ uint8_t fs_nungotten; /* The number of characters buffered
for ungetc */
+ char fs_ungotten[CONFIG_NUNGET_CHARS];
+#endif
+};
+#endif /* CONFIG_FILE_STREAM */
+
/* Streams */
typedef struct file_struct FILE;
@@ -132,6 +236,10 @@ extern "C"
/* ANSI-like File System Interfaces */
+/* The standard streams, see stdin, stdout and stderr above */
+
+FAR FILE *lib_get_stream(int fd);
+
/* Operations on streams (FILE) */
void clearerr(FAR FILE *stream);
diff --git a/libs/libbuiltin/libgcc/gcov.c b/libs/libbuiltin/libgcc/gcov.c
index 18c309cce40..2ff033bd111 100644
--- a/libs/libbuiltin/libgcc/gcov.c
+++ b/libs/libbuiltin/libgcc/gcov.c
@@ -31,6 +31,7 @@
#include <sys/types.h>
#include <nuttx/streams.h>
+#include <nuttx/lib/lib.h>
#include <nuttx/reboot_notifier.h>
/****************************************************************************
diff --git a/libs/libc/gdbstub/lib_gdbstub.c b/libs/libc/gdbstub/lib_gdbstub.c
index dac21623eb9..0cccc4a975b 100644
--- a/libs/libc/gdbstub/lib_gdbstub.c
+++ b/libs/libc/gdbstub/lib_gdbstub.c
@@ -36,6 +36,7 @@
#include <nuttx/sched.h>
#include <nuttx/ascii.h>
#include <nuttx/gdbstub.h>
+#include <nuttx/lib/lib.h>
#include <nuttx/memoryregion.h>
#include <nuttx/streams.h>
diff --git a/libs/libc/libc.h b/libs/libc/libc.h
index 465c636589b..02c8d5928a2 100644
--- a/libs/libc/libc.h
+++ b/libs/libc/libc.h
@@ -38,6 +38,7 @@
# include <semaphore.h>
# include <nuttx/lib/lib.h>
+# include <nuttx/tls.h>
# include <nuttx/streams.h>
#endif
diff --git a/libs/libc/locale/lib_iconv.c b/libs/libc/locale/lib_iconv.c
index 6ffac2a1ef9..f6897d6552d 100644
--- a/libs/libc/locale/lib_iconv.c
+++ b/libs/libc/locale/lib_iconv.c
@@ -33,6 +33,8 @@
#include <stdint.h>
#include <locale.h>
+#include <nuttx/lib/lib.h>
+
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
diff --git a/libs/libc/misc/lib_ftok.c b/libs/libc/misc/lib_ftok.c
index 56cb7b4e80d..75e3625aa4f 100644
--- a/libs/libc/misc/lib_ftok.c
+++ b/libs/libc/misc/lib_ftok.c
@@ -33,6 +33,8 @@
#include <string.h>
#include <stdio.h>
+#include <nuttx/lib/lib.h>
+
/****************************************************************************
* Public Functions
****************************************************************************/
diff --git a/libs/libc/netdb/lib_netdb.h b/libs/libc/netdb/lib_netdb.h
index 03bb762888c..815e8035059 100644
--- a/libs/libc/netdb/lib_netdb.h
+++ b/libs/libc/netdb/lib_netdb.h
@@ -30,6 +30,7 @@
#include <nuttx/config.h>
#include <netdb.h>
+#include <stdbool.h>
#include <stdio.h>
#ifdef CONFIG_LIBC_NETDB
diff --git a/libs/libc/pwd/lib_getspnamr.c b/libs/libc/pwd/lib_getspnamr.c
index 69ee8622a2b..8a68fe03137 100644
--- a/libs/libc/pwd/lib_getspnamr.c
+++ b/libs/libc/pwd/lib_getspnamr.c
@@ -25,6 +25,7 @@
#include <nuttx/config.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <shadow.h>
diff --git a/libs/libc/signal/sig_psignal.c b/libs/libc/signal/sig_psignal.c
index 4402f80c269..10df6dcc1fb 100644
--- a/libs/libc/signal/sig_psignal.c
+++ b/libs/libc/signal/sig_psignal.c
@@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <stdio.h>
+#include <signal.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
diff --git a/libs/libc/stdio/lib_clearerr.c b/libs/libc/stdio/lib_clearerr.c
index 43f2adb5537..18b0ee22210 100644
--- a/libs/libc/stdio/lib_clearerr.c
+++ b/libs/libc/stdio/lib_clearerr.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/tls.h>
#ifdef CONFIG_FILE_STREAM
diff --git a/libs/libc/stdio/lib_feof.c b/libs/libc/stdio/lib_feof.c
index dcbde85dcba..9eab089708e 100644
--- a/libs/libc/stdio/lib_feof.c
+++ b/libs/libc/stdio/lib_feof.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/tls.h>
#ifdef CONFIG_FILE_STREAM
diff --git a/libs/libc/stdio/lib_ferror.c b/libs/libc/stdio/lib_ferror.c
index 93522581ebe..ef7ba9b5414 100644
--- a/libs/libc/stdio/lib_ferror.c
+++ b/libs/libc/stdio/lib_ferror.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/tls.h>
#ifdef CONFIG_FILE_STREAM
diff --git a/libs/libc/stdio/lib_fgetwc.c b/libs/libc/stdio/lib_fgetwc.c
index f5a9027aa6d..16fb53076c5 100644
--- a/libs/libc/stdio/lib_fgetwc.c
+++ b/libs/libc/stdio/lib_fgetwc.c
@@ -33,6 +33,8 @@
#include <errno.h>
#include <string.h>
+#include "libc.h"
+
#ifdef CONFIG_FILE_STREAM
/****************************************************************************
diff --git a/libs/libc/stdio/lib_fileno.c b/libs/libc/stdio/lib_fileno.c
index a32e57fe6fe..4366d87f695 100644
--- a/libs/libc/stdio/lib_fileno.c
+++ b/libs/libc/stdio/lib_fileno.c
@@ -30,6 +30,7 @@
#include <errno.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/tls.h>
#ifdef CONFIG_FILE_STREAM
diff --git a/libs/libc/stdio/lib_libfilelock.c
b/libs/libc/stdio/lib_libfilelock.c
index a0e355b6933..10ffa091bb5 100644
--- a/libs/libc/stdio/lib_libfilelock.c
+++ b/libs/libc/stdio/lib_libfilelock.c
@@ -34,6 +34,7 @@
#include <nuttx/mutex.h>
#include <nuttx/fs/fs.h>
+#include <nuttx/tls.h>
/****************************************************************************
* Public Functions
diff --git a/libs/libc/stdio/lib_printf.c b/libs/libc/stdio/lib_printf.c
index 7c787fb735e..190eeee3365 100644
--- a/libs/libc/stdio/lib_printf.c
+++ b/libs/libc/stdio/lib_printf.c
@@ -25,6 +25,7 @@
****************************************************************************/
#include <stdio.h>
+#include <unistd.h>
/****************************************************************************
* Public Functions
diff --git a/libs/libc/stdio/lib_putwchar.c b/libs/libc/stdio/lib_putwchar.c
index c4761fc6c0d..cd8aec0219d 100644
--- a/libs/libc/stdio/lib_putwchar.c
+++ b/libs/libc/stdio/lib_putwchar.c
@@ -31,6 +31,8 @@
#include <limits.h>
#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
#include <wchar.h>
/****************************************************************************
diff --git a/libs/libc/stdio/lib_remove.c b/libs/libc/stdio/lib_remove.c
index 5242c1ee800..f5947124dbe 100644
--- a/libs/libc/stdio/lib_remove.c
+++ b/libs/libc/stdio/lib_remove.c
@@ -27,6 +27,7 @@
#include <nuttx/config.h>
#include <sys/stat.h>
+#include <errno.h>
#include <unistd.h>
#include <stdio.h>
diff --git a/libs/libc/stdio/lib_ungetwc.c b/libs/libc/stdio/lib_ungetwc.c
index 648f654c6f4..6fe10448709 100644
--- a/libs/libc/stdio/lib_ungetwc.c
+++ b/libs/libc/stdio/lib_ungetwc.c
@@ -34,6 +34,9 @@
#include <ctype.h>
#include <fcntl.h>
#include <string.h>
+#include <stdlib.h>
+
+#include "libc.h"
#ifdef CONFIG_FILE_STREAM
diff --git a/libs/libc/stdio/lib_vasprintf.c b/libs/libc/stdio/lib_vasprintf.c
index 97090ed681f..0346f2567f0 100644
--- a/libs/libc/stdio/lib_vasprintf.c
+++ b/libs/libc/stdio/lib_vasprintf.c
@@ -25,6 +25,7 @@
****************************************************************************/
#include <nuttx/streams.h>
+#include <nuttx/lib/lib.h>
/****************************************************************************
* Pre-processor Definitions
diff --git a/libs/libc/stdio/lib_vprintf.c b/libs/libc/stdio/lib_vprintf.c
index fd980a99ee1..456506817dc 100644
--- a/libs/libc/stdio/lib_vprintf.c
+++ b/libs/libc/stdio/lib_vprintf.c
@@ -25,6 +25,7 @@
****************************************************************************/
#include <stdio.h>
+#include <unistd.h>
/****************************************************************************
* Public Functions
diff --git a/libs/libc/unistd/lib_getpass.c b/libs/libc/unistd/lib_getpass.c
index cb543fc035c..9eb3222a1e8 100644
--- a/libs/libc/unistd/lib_getpass.c
+++ b/libs/libc/unistd/lib_getpass.c
@@ -23,6 +23,7 @@
****************************************************************************/
#include <stdio.h>
+#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <fcntl.h>
diff --git a/sched/misc/coredump.c b/sched/misc/coredump.c
index 4ea68f3232a..5a0e2a22aa8 100644
--- a/sched/misc/coredump.c
+++ b/sched/misc/coredump.c
@@ -32,6 +32,7 @@
#include <nuttx/coredump.h>
#include <nuttx/elf.h>
+#include <nuttx/lib/lib.h>
#include <nuttx/nuttx.h>
#include <nuttx/sched.h>