This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 680a9752a0614070de3ae75f2eb3dea6bcef3bf2 Author: ouyangxiangzhen <[email protected]> AuthorDate: Tue Nov 24 19:43:49 2026 +0800 include/addrenv: Clean the inclusion Remove the nuttx/addrenv.h inclusion from nuttx/sched.h, nuttx/lib/elf.h and libs/libc/elf/elf.h, and keep only a forward declaration of struct addrenv_s in the structures that store address environment pointers. Include addrenv.h, wqueue.h and list.h directly in the files that need them instead of getting them through sched.h. Assisted-by: opencode:zhipuai/glm-5.3 Signed-off-by: ouyangxiangzhen <[email protected]> --- arch/arm64/src/common/arm64_checkstack.c | 2 ++ arch/arm64/src/common/arm64_mmu.c | 1 + arch/arm64/src/common/arm64_physpgaddr.c | 1 + arch/risc-v/src/common/espressif/esp_i2s.c | 1 + arch/risc-v/src/common/riscv_exception.c | 1 + arch/risc-v/src/common/riscv_mmu.c | 1 + arch/x86_64/src/intel64/intel64_checkstack.c | 2 ++ arch/x86_64/src/intel64/intel64_map_region.c | 1 + arch/xtensa/src/common/espressif/esp_i2s.c | 6 ++++++ arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c | 7 +++++++ drivers/input/goldfish_events.c | 1 + drivers/power/battery/goldfish_battery.c | 1 + drivers/vhost/vhost.c | 1 + include/nuttx/binfmt/binfmt.h | 4 ++-- include/nuttx/lib/elf.h | 9 ++++++--- include/nuttx/list.h | 2 ++ include/nuttx/sched.h | 5 ++++- libs/libc/elf/elf.h | 1 - libs/libc/elf/elf_addrenv.c | 1 + mm/mempool/mempool.c | 1 + sched/clock/clock_settime.c | 1 + sched/group/group_create.c | 1 + sched/pthread/pthread_create.c | 1 + sched/sched/sched_get_stateinfo.c | 2 ++ sched/sched/sched_releasetcb.c | 1 + sched/task/task_fork.c | 1 + sched/task/task_init.c | 1 + 27 files changed, 50 insertions(+), 7 deletions(-) diff --git a/arch/arm64/src/common/arm64_checkstack.c b/arch/arm64/src/common/arm64_checkstack.c index 0257af4c569..630a8b68501 100644 --- a/arch/arm64/src/common/arm64_checkstack.c +++ b/arch/arm64/src/common/arm64_checkstack.c @@ -34,6 +34,7 @@ #include <nuttx/arch.h> #include <nuttx/board.h> +#include <nuttx/addrenv.h> #include "sched/sched.h" #include "arm64_internal.h" @@ -126,6 +127,7 @@ size_t arm64_stack_check(void *stackbase, size_t nbytes) for (j = 0; j < 64; j++) { int ch; + if (*ptr++ == STACK_COLOR) { ch = '.'; diff --git a/arch/arm64/src/common/arm64_mmu.c b/arch/arm64/src/common/arm64_mmu.c index e0235e71549..ec2d32bfe0e 100644 --- a/arch/arm64/src/common/arm64_mmu.c +++ b/arch/arm64/src/common/arm64_mmu.c @@ -30,6 +30,7 @@ #include <assert.h> #include <nuttx/arch.h> +#include <nuttx/addrenv.h> #include <arch/barriers.h> #include <arch/irq.h> #include <arch/chip/chip.h> diff --git a/arch/arm64/src/common/arm64_physpgaddr.c b/arch/arm64/src/common/arm64_physpgaddr.c index 0b1460e4b53..5f3b70c6a36 100644 --- a/arch/arm64/src/common/arm64_physpgaddr.c +++ b/arch/arm64/src/common/arm64_physpgaddr.c @@ -35,6 +35,7 @@ #include "arm64_internal.h" #ifdef CONFIG_ARCH_PGPOOL_MAPPING +# include <nuttx/addrenv.h> # include <nuttx/pgalloc.h> # include "pgalloc.h" #endif diff --git a/arch/risc-v/src/common/espressif/esp_i2s.c b/arch/risc-v/src/common/espressif/esp_i2s.c index e10b00e7bce..2a43a744bf0 100644 --- a/arch/risc-v/src/common/espressif/esp_i2s.c +++ b/arch/risc-v/src/common/espressif/esp_i2s.c @@ -38,6 +38,7 @@ #include <nuttx/irq.h> #include <nuttx/arch.h> #include <nuttx/spinlock.h> +#include <nuttx/wqueue.h> #include "riscv_internal.h" diff --git a/arch/risc-v/src/common/riscv_exception.c b/arch/risc-v/src/common/riscv_exception.c index 1277a7015cc..32580a02173 100644 --- a/arch/risc-v/src/common/riscv_exception.c +++ b/arch/risc-v/src/common/riscv_exception.c @@ -33,6 +33,7 @@ #include <nuttx/irq.h> #include <nuttx/arch.h> #ifdef CONFIG_PAGING +# include <nuttx/addrenv.h> # include <nuttx/pgalloc.h> #endif diff --git a/arch/risc-v/src/common/riscv_mmu.c b/arch/risc-v/src/common/riscv_mmu.c index bf0b8d7f84a..a013f366207 100644 --- a/arch/risc-v/src/common/riscv_mmu.c +++ b/arch/risc-v/src/common/riscv_mmu.c @@ -27,6 +27,7 @@ #include <assert.h> #include <nuttx/config.h> +#include <nuttx/addrenv.h> #include <nuttx/arch.h> #include <nuttx/irq.h> diff --git a/arch/x86_64/src/intel64/intel64_checkstack.c b/arch/x86_64/src/intel64/intel64_checkstack.c index e4a88ad65b3..208332f4cf6 100644 --- a/arch/x86_64/src/intel64/intel64_checkstack.c +++ b/arch/x86_64/src/intel64/intel64_checkstack.c @@ -26,6 +26,8 @@ #include <nuttx/config.h> +#include <nuttx/addrenv.h> + #include "sched/sched.h" #include "x86_64_internal.h" diff --git a/arch/x86_64/src/intel64/intel64_map_region.c b/arch/x86_64/src/intel64/intel64_map_region.c index 8a0caf11926..c0c41a2c7a1 100644 --- a/arch/x86_64/src/intel64/intel64_map_region.c +++ b/arch/x86_64/src/intel64/intel64_map_region.c @@ -28,6 +28,7 @@ #include <nuttx/debug.h> #include <nuttx/irq.h> +#include <nuttx/addrenv.h> #include <nuttx/pgalloc.h> #include "x86_64_internal.h" diff --git a/arch/xtensa/src/common/espressif/esp_i2s.c b/arch/xtensa/src/common/espressif/esp_i2s.c index eae5d86f0d3..7f3f2ed48e1 100644 --- a/arch/xtensa/src/common/espressif/esp_i2s.c +++ b/arch/xtensa/src/common/espressif/esp_i2s.c @@ -40,6 +40,7 @@ #include <nuttx/arch.h> #include <nuttx/cache.h> #include <nuttx/spinlock.h> +#include <nuttx/wqueue.h> #include <arch/irq.h> #include "xtensa.h" @@ -1069,6 +1070,7 @@ static IRAM_ATTR int i2s_txdma_setup(struct esp_i2s_s *priv, /* Get the transfer information, accounting for any data offset */ const apb_samp_t bytes_per_sample = priv->data_width / 8; + samp = &apb->samp[apb->curbyte]; samp_size = (apb->nbytes - apb->curbyte) + priv->tx.carry.bytes; carry_size = samp_size % bytes_per_sample; @@ -2277,6 +2279,7 @@ static void i2s_tx_channel_start(struct esp_i2s_s *priv) static void i2s_rx_channel_start(struct esp_i2s_s *priv) { int upd_timeout; + if (priv->config->rx_en) { if (priv->rx_started) @@ -3344,6 +3347,7 @@ static int i2s_dma_setup(struct esp_i2s_s *priv) int cpuint = esp_setup_irq(periph, 1, ESP_IRQ_TRIGGER_LEVEL, i2s_interrupt, priv); + if (cpuint < 0) { i2serr("Failed to allocate a CPU interrupt.\n"); @@ -3364,6 +3368,7 @@ static int i2s_dma_setup(struct esp_i2s_s *priv) int cpuint = esp_setup_irq(periph, 1, ESP_IRQ_TRIGGER_LEVEL, i2s_interrupt, priv); + if (cpuint < 0) { i2serr("Failed to allocate a CPU interrupt.\n"); @@ -3388,6 +3393,7 @@ static int i2s_dma_setup(struct esp_i2s_s *priv) ESP_IRQ_PRIORITY_DEFAULT, ESP_IRQ_TRIGGER_LEVEL, i2s_interrupt, priv); + if (cpuint < 0) { i2serr("Failed to allocate a CPU interrupt.\n"); diff --git a/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c b/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c index 361abba2bde..c49ae7ac0c7 100644 --- a/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c +++ b/arch/xtensa/src/esp32s3/esp32s3_spiflash_mtd.c @@ -36,6 +36,7 @@ #include <errno.h> #include <nuttx/arch.h> +#include <nuttx/wqueue.h> #include <nuttx/init.h> #include <nuttx/mutex.h> #include <nuttx/mtd/mtd.h> @@ -354,6 +355,7 @@ void spi_flash_encrypt_ll_plaintext_save(uint32_t address, { uint32_t plaintext_offs = (address % SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX); + DEBUGASSERT( plaintext_offs + size <= SOC_FLASH_ENCRYPTED_XTS_AES_BLOCK_MAX); memcpy((void *)(AES_XTS_PLAIN_BASE + plaintext_offs), buffer, size); @@ -657,6 +659,7 @@ int spi_flash_write_encrypted_manu(uint32_t address, const void *buffer, } const uint8_t *data_bytes = (const uint8_t *)buffer; + esp_flash_encryption->flash_encryption_enable(); while (length > 0) { @@ -1491,6 +1494,7 @@ static int esp32s3_ioctl(struct mtd_dev_s *dev, int cmd, unsigned long arg) { int ret = OK; + finfo("cmd: %d\n", cmd); switch (cmd) @@ -1499,6 +1503,7 @@ static int esp32s3_ioctl(struct mtd_dev_s *dev, int cmd, { struct esp32s3_mtd_dev_s *priv = (struct esp32s3_mtd_dev_s *)dev; struct mtd_geometry_s *geo = (struct mtd_geometry_s *)arg; + if (geo) { memset(geo, 0, sizeof(*geo)); @@ -1519,6 +1524,7 @@ static int esp32s3_ioctl(struct mtd_dev_s *dev, int cmd, { struct esp32s3_mtd_dev_s *priv = (struct esp32s3_mtd_dev_s *)dev; struct partition_info_s *info = (struct partition_info_s *)arg; + if (info != NULL) { info->numsectors = MTD_SIZE(priv) / MTD_BLK_SIZE; @@ -1532,6 +1538,7 @@ static int esp32s3_ioctl(struct mtd_dev_s *dev, int cmd, case MTDIOC_ERASESTATE: { uint8_t *result = (uint8_t *)arg; + *result = MTD_ERASED_STATE; ret = OK; diff --git a/drivers/input/goldfish_events.c b/drivers/input/goldfish_events.c index e6486cc3263..e2e13f522eb 100644 --- a/drivers/input/goldfish_events.c +++ b/drivers/input/goldfish_events.c @@ -30,6 +30,7 @@ #include <nuttx/irq.h> #include <nuttx/queue.h> #include <nuttx/kmalloc.h> +#include <nuttx/wqueue.h> #include <nuttx/input/goldfish_events.h> #include <nuttx/input/mouse.h> diff --git a/drivers/power/battery/goldfish_battery.c b/drivers/power/battery/goldfish_battery.c index 7f67d1a4f13..35803bb5c1c 100644 --- a/drivers/power/battery/goldfish_battery.c +++ b/drivers/power/battery/goldfish_battery.c @@ -31,6 +31,7 @@ #include <nuttx/arch.h> #include <nuttx/kmalloc.h> #include <nuttx/nuttx.h> +#include <nuttx/wqueue.h> #include <nuttx/power/battery_gauge.h> #include <nuttx/power/battery_ioctl.h> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index f721acde7a9..43c3c31f226 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -31,6 +31,7 @@ #include <nuttx/fs/fs.h> #include <nuttx/kmalloc.h> +#include <nuttx/list.h> #include <nuttx/mutex.h> #include <nuttx/nuttx.h> #include <nuttx/percpu.h> diff --git a/include/nuttx/binfmt/binfmt.h b/include/nuttx/binfmt/binfmt.h index bcb4df71ec9..ee5e1740f91 100644 --- a/include/nuttx/binfmt/binfmt.h +++ b/include/nuttx/binfmt/binfmt.h @@ -86,8 +86,8 @@ struct binary_s * used to manage the tasks address space. */ - FAR addrenv_t *addrenv; /* Address environment */ - FAR addrenv_t *oldenv; /* Saved address environment */ + FAR struct addrenv_s *addrenv; /* Address environment */ + FAR struct addrenv_s *oldenv; /* Saved address environment */ #endif size_t mapsize; /* Size of the mapped address region (needed for munmap) */ diff --git a/include/nuttx/lib/elf.h b/include/nuttx/lib/elf.h index 628483dcc4d..ebf335619ea 100644 --- a/include/nuttx/lib/elf.h +++ b/include/nuttx/lib/elf.h @@ -33,7 +33,6 @@ #include <stdbool.h> #include <elf.h> -#include <nuttx/addrenv.h> #include <nuttx/fs/fs.h> #include <nuttx/list.h> @@ -109,6 +108,10 @@ * Public Types ****************************************************************************/ +#ifdef CONFIG_ARCH_ADDRENV +struct addrenv_s; /* Forward definition to avoid including addrenv.h */ +#endif + /* This is the type of the function that is called to uninitialize the * the loaded module. This may mean, for example, un-registering a device * driver. If the module is successfully uninitialized, its memory will be @@ -333,8 +336,8 @@ struct mod_loadinfo_s */ #ifdef CONFIG_ARCH_ADDRENV - FAR addrenv_t *addrenv; /* Address environment */ - FAR addrenv_t *oldenv; /* Saved address environment */ + FAR struct addrenv_s *addrenv; /* Address environment */ + FAR struct addrenv_s *oldenv; /* Saved address environment */ #endif }; diff --git a/include/nuttx/list.h b/include/nuttx/list.h index 9eb7064b52a..30b0c253cca 100644 --- a/include/nuttx/list.h +++ b/include/nuttx/list.h @@ -49,6 +49,8 @@ #include <nuttx/list_type.h> +#include <nuttx/compiler.h> + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ diff --git a/include/nuttx/sched.h b/include/nuttx/sched.h index de083f93413..3fe5fa3d9d2 100644 --- a/include/nuttx/sched.h +++ b/include/nuttx/sched.h @@ -39,7 +39,6 @@ #include <pthread.h> #include <time.h> -#include <nuttx/addrenv.h> #include <nuttx/irq.h> #include <nuttx/percpu.h> #include <nuttx/clock.h> @@ -252,6 +251,10 @@ #ifndef __ASSEMBLY__ +#ifdef CONFIG_ARCH_ADDRENV +struct addrenv_s; /* Forward definition to avoid including addrenv.h */ +#endif + /* General Task Management Types ********************************************/ /* This is the type of the task_state field of the TCB. NOTE: the order and diff --git a/libs/libc/elf/elf.h b/libs/libc/elf/elf.h index 5cd15ff5f2b..458d153ecfa 100644 --- a/libs/libc/elf/elf.h +++ b/libs/libc/elf/elf.h @@ -27,7 +27,6 @@ * Included Files ****************************************************************************/ -#include <nuttx/addrenv.h> #include <nuttx/elf.h> #include <nuttx/lib/elf.h> diff --git a/libs/libc/elf/elf_addrenv.c b/libs/libc/elf/elf_addrenv.c index 5248b64f762..31ade20ed34 100644 --- a/libs/libc/elf/elf_addrenv.c +++ b/libs/libc/elf/elf_addrenv.c @@ -30,6 +30,7 @@ #include <nuttx/debug.h> #include <nuttx/arch.h> +#include <nuttx/addrenv.h> #include <nuttx/kmalloc.h> #include <sys/mman.h> diff --git a/mm/mempool/mempool.c b/mm/mempool/mempool.c index 7a8bae3bd1c..c57a303ce04 100644 --- a/mm/mempool/mempool.c +++ b/mm/mempool/mempool.c @@ -32,6 +32,7 @@ #include <syslog.h> #include <sys/param.h> +#include <nuttx/addrenv.h> #include <nuttx/kmalloc.h> #include <nuttx/mm/kasan.h> #include <nuttx/mm/mempool.h> diff --git a/sched/clock/clock_settime.c b/sched/clock/clock_settime.c index 6bea1cf4358..531695ceb3f 100644 --- a/sched/clock/clock_settime.c +++ b/sched/clock/clock_settime.c @@ -38,6 +38,7 @@ #include <nuttx/irq.h> #include <nuttx/spinlock.h> #include <nuttx/timers/ptp_clock.h> +#include <nuttx/wqueue.h> #include "clock/clock.h" #ifdef CONFIG_CLOCK_TIMEKEEPING diff --git a/sched/group/group_create.c b/sched/group/group_create.c index 64cc0a10597..d953f268dbf 100644 --- a/sched/group/group_create.c +++ b/sched/group/group_create.c @@ -31,6 +31,7 @@ #include <assert.h> #include <errno.h> +#include <nuttx/addrenv.h> #include <nuttx/debug.h> #include <nuttx/irq.h> #include <nuttx/kmalloc.h> diff --git a/sched/pthread/pthread_create.c b/sched/pthread/pthread_create.c index e0468c44abd..c6b908055a5 100644 --- a/sched/pthread/pthread_create.c +++ b/sched/pthread/pthread_create.c @@ -37,6 +37,7 @@ #include <nuttx/queue.h> #include <nuttx/sched.h> +#include <nuttx/addrenv.h> #include <nuttx/arch.h> #include <nuttx/semaphore.h> #include <nuttx/kmalloc.h> diff --git a/sched/sched/sched_get_stateinfo.c b/sched/sched/sched_get_stateinfo.c index dde18093175..b9804e1ef61 100644 --- a/sched/sched/sched_get_stateinfo.c +++ b/sched/sched/sched_get_stateinfo.c @@ -31,6 +31,7 @@ #include <semaphore.h> #include <nuttx/mutex.h> #include <nuttx/irq.h> +#include <nuttx/addrenv.h> #include "nuttx/sched.h" /**************************************************************************** @@ -102,6 +103,7 @@ void nxsched_get_stateinfo(FAR struct tcb_s *tcb, FAR char *state, ((FAR sem_t *)(tcb->waitobj))->flags & SEM_TYPE_MUTEX) { pid_t holder = nxmutex_get_holder((FAR mutex_t *)tcb->waitobj); + leave_critical_section(flags); snprintf(state, length, "Waiting,Mutex:%d", holder); diff --git a/sched/sched/sched_releasetcb.c b/sched/sched/sched_releasetcb.c index a68a14df8ea..d33e36a2403 100644 --- a/sched/sched/sched_releasetcb.c +++ b/sched/sched/sched_releasetcb.c @@ -31,6 +31,7 @@ #include <errno.h> #include <nuttx/arch.h> +#include <nuttx/addrenv.h> #include <nuttx/sched.h> #include "task/task.h" diff --git a/sched/task/task_fork.c b/sched/task/task_fork.c index 0c36ca9ba95..706fb7419e7 100644 --- a/sched/task/task_fork.c +++ b/sched/task/task_fork.c @@ -34,6 +34,7 @@ #include <errno.h> #include <nuttx/debug.h> +#include <nuttx/addrenv.h> #include <nuttx/kmalloc.h> #include <nuttx/queue.h> #include <nuttx/semaphore.h> diff --git a/sched/task/task_init.c b/sched/task/task_init.c index 3d5f38cb3d9..157e07e2dc2 100644 --- a/sched/task/task_init.c +++ b/sched/task/task_init.c @@ -34,6 +34,7 @@ #include <nuttx/arch.h> #include <nuttx/queue.h> +#include <nuttx/addrenv.h> #include <nuttx/sched.h> #include <nuttx/trace.h> #include <nuttx/environ.h>
