From e82d51a9eef5351206771f0942c00a843deaab90 Mon Sep 17 00:00:00 2001 From: Alexey Lapshin Date: Fri, 16 May 2025 14:02:48 +0700 Subject: [PATCH] fix(picolibc): fix missed headers in sources --- components/fatfs/vfs/vfs_fat.c | 1 + components/lwip/port/hooks/lwip_default_hooks.c | 2 ++ components/newlib/platform_include/sys/lock.h | 8 ++------ components/newlib/platform_include/sys/select.h | 4 ++++ components/newlib/src/getentropy.c | 1 + components/newlib/src/picolibc/picolibc_init.c | 2 +- components/newlib/src/pthread.c | 4 ++++ components/newlib/src/reent_syscalls.c | 1 + components/newlib/src/syscalls.c | 1 + components/newlib/test_apps/newlib/main/test_newlib.c | 1 + components/soc/esp32p4/register/soc/pmu_struct.h | 1 + components/soc/lldesc.c | 1 + components/spiffs/esp_spiffs.c | 1 + 13 files changed, 21 insertions(+), 7 deletions(-) diff --git a/components/fatfs/vfs/vfs_fat.c b/components/fatfs/vfs/vfs_fat.c index b0b32fa9dc..a2c865b4c5 100644 --- a/components/fatfs/vfs/vfs_fat.c +++ b/components/fatfs/vfs/vfs_fat.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include diff --git a/components/lwip/port/hooks/lwip_default_hooks.c b/components/lwip/port/hooks/lwip_default_hooks.c index 180c15a632..1ec6e75814 100644 --- a/components/lwip/port/hooks/lwip_default_hooks.c +++ b/components/lwip/port/hooks/lwip_default_hooks.c @@ -11,7 +11,9 @@ #include "esp_log.h" #include +#ifndef __weak #define __weak __attribute__((weak)) +#endif /** * Default lwip behavior is to silence LWIP_ERROR() if LWIP_DEBUG is not set. diff --git a/components/newlib/platform_include/sys/lock.h b/components/newlib/platform_include/sys/lock.h index aed4d2c183..9674232136 100644 --- a/components/newlib/platform_include/sys/lock.h +++ b/components/newlib/platform_include/sys/lock.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -12,7 +12,7 @@ extern "C" { #endif -#ifdef _RETARGETABLE_LOCKING +#if defined(_RETARGETABLE_LOCKING) || defined(CONFIG_LIBC_PICOLIBC) /* Actual platfrom-specific definition of struct __lock. * The size here should be sufficient for a FreeRTOS mutex. @@ -52,10 +52,6 @@ int _lock_try_acquire_recursive(_lock_t *plock); void _lock_release(_lock_t *plock); void _lock_release_recursive(_lock_t *plock); -#if CONFIG_LIBC_PICOLIBC -#define __lock_try_acquire(lock) _lock_try_acquire(&(lock)) -#define __lock_try_acquire_recursive(lock) _lock_try_acquire_recursive(&(lock)) -#endif // CONFIG_LIBC_PICOLIBC #endif // _RETARGETABLE_LOCKING #ifdef __cplusplus diff --git a/components/newlib/platform_include/sys/select.h b/components/newlib/platform_include/sys/select.h index e4d828b711..2eeab9092f 100644 --- a/components/newlib/platform_include/sys/select.h +++ b/components/newlib/platform_include/sys/select.h @@ -26,6 +26,10 @@ int select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *errorfds, struct #endif // fd_set +#if __BSD_VISIBLE && !defined(fds_bits) +#define fds_bits __fds_bits +#endif + #if defined(FD_ISSET) || defined(FD_SET) || defined(FD_CLR) #undef FD_SET #undef FD_CLR diff --git a/components/newlib/src/getentropy.c b/components/newlib/src/getentropy.c index 530a5964cc..850ae4e1cf 100644 --- a/components/newlib/src/getentropy.c +++ b/components/newlib/src/getentropy.c @@ -6,6 +6,7 @@ #include #include +#include int getentropy(void *buffer, size_t length) { diff --git a/components/newlib/src/picolibc/picolibc_init.c b/components/newlib/src/picolibc/picolibc_init.c index 2e0fc30f14..efe982e897 100644 --- a/components/newlib/src/picolibc/picolibc_init.c +++ b/components/newlib/src/picolibc/picolibc_init.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/components/newlib/src/pthread.c b/components/newlib/src/pthread.c index 13da80d7d5..d899dabad3 100644 --- a/components/newlib/src/pthread.c +++ b/components/newlib/src/pthread.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include +#include #include "esp_log.h" const static char *TAG = "esp32_asio_pthread"; @@ -22,6 +23,8 @@ int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict os return 0; } +// picolibc has sigfillset macro in signal.h +#if !CONFIG_LIBC_PICOLIBC int sigfillset(sigset_t *what) { ESP_LOGD(TAG, "%s: Signals not supported in ESP pthread", __func__); @@ -30,6 +33,7 @@ int sigfillset(sigset_t *what) } return 0; } +#endif /* !CONFIG_LIBC_PICOLIBC */ void esp_libc_include_pthread_impl(void) { diff --git a/components/newlib/src/reent_syscalls.c b/components/newlib/src/reent_syscalls.c index 72f3a4ec18..a036222990 100644 --- a/components/newlib/src/reent_syscalls.c +++ b/components/newlib/src/reent_syscalls.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "sdkconfig.h" #include "esp_rom_uart.h" #include "esp_system_console.h" diff --git a/components/newlib/src/syscalls.c b/components/newlib/src/syscalls.c index 4ead5eb1a3..2eb8f5011a 100644 --- a/components/newlib/src/syscalls.c +++ b/components/newlib/src/syscalls.c @@ -10,6 +10,7 @@ #include #include #include +#include #if CONFIG_LIBC_PICOLIBC int open(const char *pathname, int flags, ...) diff --git a/components/newlib/test_apps/newlib/main/test_newlib.c b/components/newlib/test_apps/newlib/main/test_newlib.c index bd6a91627a..65137cebe8 100644 --- a/components/newlib/test_apps/newlib/main/test_newlib.c +++ b/components/newlib/test_apps/newlib/main/test_newlib.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "unity.h" #include "sdkconfig.h" diff --git a/components/soc/esp32p4/register/soc/pmu_struct.h b/components/soc/esp32p4/register/soc/pmu_struct.h index b62a05199b..6d3cf7298c 100644 --- a/components/soc/esp32p4/register/soc/pmu_struct.h +++ b/components/soc/esp32p4/register/soc/pmu_struct.h @@ -5,6 +5,7 @@ */ #pragma once +#include #include #include "soc/pmu_reg.h" #ifdef __cplusplus diff --git a/components/soc/lldesc.c b/components/soc/lldesc.c index 7850d78799..3cc947b62b 100644 --- a/components/soc/lldesc.c +++ b/components/soc/lldesc.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include "soc/lldesc.h" void lldesc_setup_link_constrained(lldesc_t *dmadesc, const void *data, int len, int max_desc_size, bool isrx) diff --git a/components/spiffs/esp_spiffs.c b/components/spiffs/esp_spiffs.c index b4820f5098..68e253db14 100644 --- a/components/spiffs/esp_spiffs.c +++ b/components/spiffs/esp_spiffs.c @@ -15,6 +15,7 @@ #include "freertos/semphr.h" #include #include +#include #include #include #include