Merge branch 'reformat/astyle_misc_core_comps' into 'master'

refactor(core): reformat newlib and pthread with astyle

See merge request espressif/esp-idf!29277
This commit is contained in:
Marius Vikhammer
2024-03-05 12:54:20 +08:00
39 changed files with 442 additions and 460 deletions

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -11,7 +11,6 @@
#include <malloc.h> #include <malloc.h>
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
/* /*
These contain the business logic for the malloc() and realloc() implementation. Because of heap tracing These contain the business logic for the malloc() and realloc() implementation. Because of heap tracing
wrapping reasons, we do not want these to be a public api, however, so they're not defined publicly. wrapping reasons, we do not want these to be a public api, however, so they're not defined publicly.

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -38,15 +38,14 @@ static portMUX_TYPE lock_init_spinlock = portMUX_INITIALIZER_UNLOCKED;
Called by _lock_init*, also called by _lock_acquire* to lazily initialize locks that might have Called by _lock_init*, also called by _lock_acquire* to lazily initialize locks that might have
been initialised (to zero only) before the RTOS scheduler started. been initialised (to zero only) before the RTOS scheduler started.
*/ */
static void IRAM_ATTR lock_init_generic(_lock_t *lock, uint8_t mutex_type) { static void IRAM_ATTR lock_init_generic(_lock_t *lock, uint8_t mutex_type)
{
portENTER_CRITICAL(&lock_init_spinlock); portENTER_CRITICAL(&lock_init_spinlock);
if (*lock) { if (*lock) {
/* Lock already initialised (either we didn't check earlier, /* Lock already initialised (either we didn't check earlier,
or it got initialised while we were waiting for the or it got initialised while we were waiting for the
spinlock.) */ spinlock.) */
} } else {
else
{
/* Create a new semaphore /* Create a new semaphore
this is a bit of an API violation, as we're calling the this is a bit of an API violation, as we're calling the
@@ -70,12 +69,14 @@ static void IRAM_ATTR lock_init_generic(_lock_t *lock, uint8_t mutex_type) {
portEXIT_CRITICAL(&lock_init_spinlock); portEXIT_CRITICAL(&lock_init_spinlock);
} }
void IRAM_ATTR _lock_init(_lock_t *lock) { void IRAM_ATTR _lock_init(_lock_t *lock)
{
*lock = 0; // In case lock's memory is uninitialized *lock = 0; // In case lock's memory is uninitialized
lock_init_generic(lock, queueQUEUE_TYPE_MUTEX); lock_init_generic(lock, queueQUEUE_TYPE_MUTEX);
} }
void IRAM_ATTR _lock_init_recursive(_lock_t *lock) { void IRAM_ATTR _lock_init_recursive(_lock_t *lock)
{
*lock = 0; // In case lock's memory is uninitialized *lock = 0; // In case lock's memory is uninitialized
lock_init_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX); lock_init_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
} }
@@ -90,7 +91,8 @@ void IRAM_ATTR _lock_init_recursive(_lock_t *lock) {
re-initialised if it is used again. Caller has to avoid doing re-initialised if it is used again. Caller has to avoid doing
this! this!
*/ */
void IRAM_ATTR _lock_close(_lock_t *lock) { void IRAM_ATTR _lock_close(_lock_t *lock)
{
portENTER_CRITICAL(&lock_init_spinlock); portENTER_CRITICAL(&lock_init_spinlock);
if (*lock) { if (*lock) {
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock); SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
@@ -108,7 +110,8 @@ void _lock_close_recursive(_lock_t *lock) __attribute__((alias("_lock_close")));
/* Acquire the mutex semaphore for lock. wait up to delay ticks. /* Acquire the mutex semaphore for lock. wait up to delay ticks.
mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX
*/ */
static int IRAM_ATTR lock_acquire_generic(_lock_t *lock, uint32_t delay, uint8_t mutex_type) { static int IRAM_ATTR lock_acquire_generic(_lock_t *lock, uint32_t delay, uint8_t mutex_type)
{
SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock); SemaphoreHandle_t h = (SemaphoreHandle_t)(*lock);
if (!h) { if (!h) {
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) { if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
@@ -137,8 +140,7 @@ static int IRAM_ATTR lock_acquire_generic(_lock_t *lock, uint32_t delay, uint8_t
if (higher_task_woken) { if (higher_task_woken) {
portYIELD_FROM_ISR(); portYIELD_FROM_ISR();
} }
} } else {
else {
/* In task context */ /* In task context */
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) { if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
success = xSemaphoreTakeRecursive(h, delay); success = xSemaphoreTakeRecursive(h, delay);
@@ -150,26 +152,31 @@ static int IRAM_ATTR lock_acquire_generic(_lock_t *lock, uint32_t delay, uint8_t
return (success == pdTRUE) ? 0 : -1; return (success == pdTRUE) ? 0 : -1;
} }
void IRAM_ATTR _lock_acquire(_lock_t *lock) { void IRAM_ATTR _lock_acquire(_lock_t *lock)
{
lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_MUTEX); lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_MUTEX);
} }
void IRAM_ATTR _lock_acquire_recursive(_lock_t *lock) { void IRAM_ATTR _lock_acquire_recursive(_lock_t *lock)
{
lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_RECURSIVE_MUTEX); lock_acquire_generic(lock, portMAX_DELAY, queueQUEUE_TYPE_RECURSIVE_MUTEX);
} }
int IRAM_ATTR _lock_try_acquire(_lock_t *lock) { int IRAM_ATTR _lock_try_acquire(_lock_t *lock)
{
return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_MUTEX); return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_MUTEX);
} }
int IRAM_ATTR _lock_try_acquire_recursive(_lock_t *lock) { int IRAM_ATTR _lock_try_acquire_recursive(_lock_t *lock)
{
return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_RECURSIVE_MUTEX); return lock_acquire_generic(lock, 0, queueQUEUE_TYPE_RECURSIVE_MUTEX);
} }
/* Release the mutex semaphore for lock. /* Release the mutex semaphore for lock.
mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX mutex_type is queueQUEUE_TYPE_RECURSIVE_MUTEX or queueQUEUE_TYPE_MUTEX
*/ */
static void IRAM_ATTR lock_release_generic(_lock_t *lock, uint8_t mutex_type) { static void IRAM_ATTR lock_release_generic(_lock_t *lock, uint8_t mutex_type)
{
if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) { if (xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED) {
return; /* locking is a no-op before scheduler is up */ return; /* locking is a no-op before scheduler is up */
} }
@@ -194,11 +201,13 @@ static void IRAM_ATTR lock_release_generic(_lock_t *lock, uint8_t mutex_type) {
} }
} }
void IRAM_ATTR _lock_release(_lock_t *lock) { void IRAM_ATTR _lock_release(_lock_t *lock)
{
lock_release_generic(lock, queueQUEUE_TYPE_MUTEX); lock_release_generic(lock, queueQUEUE_TYPE_MUTEX);
} }
void IRAM_ATTR _lock_release_recursive(_lock_t *lock) { void IRAM_ATTR _lock_release_recursive(_lock_t *lock)
{
lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX); lock_release_generic(lock, queueQUEUE_TYPE_RECURSIVE_MUTEX);
} }
@@ -242,7 +251,6 @@ _Static_assert(configSUPPORT_STATIC_ALLOCATION,
static StaticSemaphore_t s_common_mutex; static StaticSemaphore_t s_common_mutex;
static StaticSemaphore_t s_common_recursive_mutex; static StaticSemaphore_t s_common_recursive_mutex;
#if ESP_ROM_HAS_RETARGETABLE_LOCKING #if ESP_ROM_HAS_RETARGETABLE_LOCKING
/* C3 and S3 ROMs are built without Newlib static lock symbols exported, and /* C3 and S3 ROMs are built without Newlib static lock symbols exported, and
* with an extra level of _LOCK_T indirection in mind. * with an extra level of _LOCK_T indirection in mind.
@@ -271,7 +279,6 @@ static StaticSemaphore_t s_common_recursive_mutex;
#define MAYBE_OVERRIDE_LOCK(_lock, _lock_to_use_instead) #define MAYBE_OVERRIDE_LOCK(_lock, _lock_to_use_instead)
#endif // ROM_NEEDS_MUTEX_OVERRIDE #endif // ROM_NEEDS_MUTEX_OVERRIDE
void IRAM_ATTR __retarget_lock_init(_LOCK_T *lock) void IRAM_ATTR __retarget_lock_init(_LOCK_T *lock)
{ {
*lock = NULL; /* In case lock's memory is uninitialized */ *lock = NULL; /* In case lock's memory is uninitialized */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -48,7 +48,6 @@ extern int _printf_float(struct _reent *rptr,
int (*pfunc)(struct _reent *, FILE *, const char *, size_t len), int (*pfunc)(struct _reent *, FILE *, const char *, size_t len),
va_list * ap); va_list * ap);
extern int _scanf_float(struct _reent *rptr, extern int _scanf_float(struct _reent *rptr,
void *pdata, void *pdata,
FILE *fp, FILE *fp,
@@ -196,8 +195,7 @@ void esp_setup_newlib_syscalls(void) __attribute__((alias("esp_newlib_init")));
*/ */
void esp_newlib_init_global_stdio(const char *stdio_dev) void esp_newlib_init_global_stdio(const char *stdio_dev)
{ {
if (stdio_dev == NULL) if (stdio_dev == NULL) {
{
_GLOBAL_REENT->__cleanup = NULL; _GLOBAL_REENT->__cleanup = NULL;
_REENT_SDIDINIT(_GLOBAL_REENT) = 0; _REENT_SDIDINIT(_GLOBAL_REENT) = 0;
__sinit(_GLOBAL_REENT); __sinit(_GLOBAL_REENT);

View File

@@ -4,7 +4,6 @@
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
/* This header file wraps newlib's own unmodified assert.h and adds /* This header file wraps newlib's own unmodified assert.h and adds
support for silent assertion failure. support for silent assertion failure.
*/ */

View File

@@ -7,7 +7,7 @@
*/ */
/*- /*-
* SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2020 Francesco Giancane <francesco.giancane@accenture.com> * SPDX-FileCopyrightText: 2020 Francesco Giancane <francesco.giancane@accenture.com>
* SPDX-FileCopyrightText: 2002 Thomas Moestl <tmm@FreeBSD.org> * SPDX-FileCopyrightText: 2002 Thomas Moestl <tmm@FreeBSD.org>
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND Apache-2.0 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND Apache-2.0

View File

@@ -1,6 +1,6 @@
/* /*
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -28,7 +28,6 @@ extern "C" {
typedef u32_t socklen_t; typedef u32_t socklen_t;
unsigned int if_nametoindex(const char *ifname); unsigned int if_nametoindex(const char *ifname);
char *if_indextoname(unsigned int ifindex, char *ifname); char *if_indextoname(unsigned int ifindex, char *ifname);

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -21,7 +21,6 @@
#include_next<sys/reent.h> #include_next<sys/reent.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -14,7 +14,6 @@
// Not everything has a defined meaning for ESP-IDF (e.g. process leader IDs) and therefore are likely to be stubbed // Not everything has a defined meaning for ESP-IDF (e.g. process leader IDs) and therefore are likely to be stubbed
// in actual implementations. // in actual implementations.
#include <stdint.h> #include <stdint.h>
#include <sys/types.h> #include <sys/types.h>
#include "sdkconfig.h" #include "sdkconfig.h"
@@ -164,8 +163,7 @@ typedef uint8_t cc_t;
typedef uint32_t speed_t; typedef uint32_t speed_t;
typedef uint16_t tcflag_t; typedef uint16_t tcflag_t;
struct termios struct termios {
{
tcflag_t c_iflag; /** Input modes */ tcflag_t c_iflag; /** Input modes */
tcflag_t c_oflag; /** Output modes */ tcflag_t c_oflag; /** Output modes */
tcflag_t c_cflag; /** Control modes */ tcflag_t c_cflag; /** Control modes */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2018-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2018-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -50,8 +50,6 @@
#include "esp32p4/rtc.h" #include "esp32p4/rtc.h"
#endif #endif
// Offset between High resolution timer and the RTC. // Offset between High resolution timer and the RTC.
// Initialized after reset or light sleep. // Initialized after reset or light sleep.
#if defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER) && defined(CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER) #if defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER) && defined(CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER)
@@ -94,7 +92,6 @@ uint64_t esp_time_impl_get_time(void)
#endif // defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) || defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER ) #endif // defined( CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER ) || defined( CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER )
void esp_time_impl_set_boot_time(uint64_t time_us) void esp_time_impl_set_boot_time(uint64_t time_us)
{ {
_lock_acquire(&s_boot_time_lock); _lock_acquire(&s_boot_time_lock);

View File

@@ -43,7 +43,6 @@ char * realpath(const char *file_name, char *resolved_name)
/* number of path components in the output buffer */ /* number of path components in the output buffer */
size_t out_depth = 0; size_t out_depth = 0;
while (*in_ptr) { while (*in_ptr) {
/* "path component" is the part between two '/' path separators. /* "path component" is the part between two '/' path separators.
* locate the next path component in the input path: * locate the next path component in the input path:

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -297,7 +297,6 @@ CLANG_DECLARE_ALIAS( __sync_lock_test_and_set_ ## n )
} \ } \
CLANG_DECLARE_ALIAS( __sync_lock_release_ ## n ) CLANG_DECLARE_ALIAS( __sync_lock_release_ ## n )
#if !HAS_ATOMICS_32 #if !HAS_ATOMICS_32
_Static_assert(sizeof(unsigned char) == 1, "atomics require a 1-byte type"); _Static_assert(sizeof(unsigned char) == 1, "atomics require a 1-byte type");
@@ -416,7 +415,6 @@ SYNC_VAL_CMP_EXCHANGE(1, unsigned char)
SYNC_VAL_CMP_EXCHANGE(2, short unsigned int) SYNC_VAL_CMP_EXCHANGE(2, short unsigned int)
SYNC_VAL_CMP_EXCHANGE(4, unsigned int) SYNC_VAL_CMP_EXCHANGE(4, unsigned int)
SYNC_LOCK_TEST_AND_SET(1, unsigned char) SYNC_LOCK_TEST_AND_SET(1, unsigned char)
SYNC_LOCK_TEST_AND_SET(2, short unsigned int) SYNC_LOCK_TEST_AND_SET(2, short unsigned int)
SYNC_LOCK_TEST_AND_SET(4, unsigned int) SYNC_LOCK_TEST_AND_SET(4, unsigned int)
@@ -436,12 +434,14 @@ ATOMIC_STORE(4, unsigned int)
#elif __riscv_atomic == 1 #elif __riscv_atomic == 1
bool CLANG_ATOMIC_SUFFIX(__atomic_always_lock_free) (unsigned int size, const volatile void *) { bool CLANG_ATOMIC_SUFFIX(__atomic_always_lock_free)(unsigned int size, const volatile void *)
{
return size <= sizeof(int); return size <= sizeof(int);
} }
CLANG_DECLARE_ALIAS(__atomic_always_lock_free) CLANG_DECLARE_ALIAS(__atomic_always_lock_free)
bool CLANG_ATOMIC_SUFFIX(__atomic_is_lock_free) (unsigned int size, const volatile void *) { bool CLANG_ATOMIC_SUFFIX(__atomic_is_lock_free)(unsigned int size, const volatile void *)
{
return size <= sizeof(int); return size <= sizeof(int);
} }
CLANG_DECLARE_ALIAS(__atomic_is_lock_free) CLANG_DECLARE_ALIAS(__atomic_is_lock_free)
@@ -519,21 +519,24 @@ ATOMIC_STORE(8, long long unsigned int)
#endif // !HAS_ATOMICS_64 #endif // !HAS_ATOMICS_64
// Clang generates calls to the __atomic_load/__atomic_store functions for object size more then 4 bytes // Clang generates calls to the __atomic_load/__atomic_store functions for object size more then 4 bytes
void CLANG_ATOMIC_SUFFIX( __atomic_load ) (size_t size, const volatile void *src, void *dest, int model) { void CLANG_ATOMIC_SUFFIX(__atomic_load)(size_t size, const volatile void *src, void *dest, int model)
{
unsigned state = _ATOMIC_ENTER_CRITICAL(); unsigned state = _ATOMIC_ENTER_CRITICAL();
memcpy(dest, (const void *)src, size); memcpy(dest, (const void *)src, size);
_ATOMIC_EXIT_CRITICAL(state); _ATOMIC_EXIT_CRITICAL(state);
} }
CLANG_DECLARE_ALIAS(__atomic_load) CLANG_DECLARE_ALIAS(__atomic_load)
void CLANG_ATOMIC_SUFFIX( __atomic_store ) (size_t size, volatile void *dest, void *src, int model) { void CLANG_ATOMIC_SUFFIX(__atomic_store)(size_t size, volatile void *dest, void *src, int model)
{
unsigned state = _ATOMIC_ENTER_CRITICAL(); unsigned state = _ATOMIC_ENTER_CRITICAL();
memcpy((void *)dest, (const void *)src, size); memcpy((void *)dest, (const void *)src, size);
_ATOMIC_EXIT_CRITICAL(state); _ATOMIC_EXIT_CRITICAL(state);
} }
CLANG_DECLARE_ALIAS(__atomic_store) CLANG_DECLARE_ALIAS(__atomic_store)
bool CLANG_ATOMIC_SUFFIX(__atomic_compare_exchange) (size_t size, volatile void *ptr, void *expected, void *desired, int success_memorder, int failure_memorder) { bool CLANG_ATOMIC_SUFFIX(__atomic_compare_exchange)(size_t size, volatile void *ptr, void *expected, void *desired, int success_memorder, int failure_memorder)
{
bool ret = false; bool ret = false;
unsigned state = _ATOMIC_ENTER_CRITICAL(); unsigned state = _ATOMIC_ENTER_CRITICAL();
if (!memcmp((void *)ptr, expected, size)) { if (!memcmp((void *)ptr, expected, size)) {

View File

@@ -83,7 +83,6 @@ static int _fsync_console(int fd)
return -1; return -1;
} }
/* The following weak definitions of syscalls will be used unless /* The following weak definitions of syscalls will be used unless
* another definition is provided. That definition may come from * another definition is provided. That definition may come from
* VFS, LWIP, or the application. * VFS, LWIP, or the application.
@@ -97,7 +96,6 @@ int _fstat_r (struct _reent *r, int fd, struct stat *st)
int fsync(int fd) int fsync(int fd)
__attribute__((weak, alias("_fsync_console"))); __attribute__((weak, alias("_fsync_console")));
/* The aliases below are to "syscall_not_implemented", which /* The aliases below are to "syscall_not_implemented", which
* doesn't have the same signature as the original function. * doesn't have the same signature as the original function.
* Disable type mismatch warnings for this reason. * Disable type mismatch warnings for this reason.
@@ -126,7 +124,6 @@ int _rename_r(struct _reent *r, const char *src, const char *dst)
int _isatty_r(struct _reent *r, int fd) int _isatty_r(struct _reent *r, int fd)
__attribute__((weak, alias("syscall_not_implemented"))); __attribute__((weak, alias("syscall_not_implemented")));
/* These functions are not expected to be overridden */ /* These functions are not expected to be overridden */
int _system_r(struct _reent *r, const char *str) int _system_r(struct _reent *r, const char *str)
__attribute__((alias("syscall_not_implemented"))); __attribute__((alias("syscall_not_implemented")));

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -14,7 +14,6 @@
#define RECORD_TIME_START() do {__t1 = esp_cpu_get_cycle_count();}while(0) #define RECORD_TIME_START() do {__t1 = esp_cpu_get_cycle_count();}while(0)
#define RECORD_TIME_END(p_time) do{__t2 = esp_cpu_get_cycle_count(); *p_time = (__t2-__t1);}while(0) #define RECORD_TIME_END(p_time) do{__t2 = esp_cpu_get_cycle_count(); *p_time = (__t2-__t1);}while(0)
#define TEST_TIMES 11 #define TEST_TIMES 11
//Test twice, and only get the result of second time, to avoid influence of cache miss //Test twice, and only get the result of second time, to avoid influence of cache miss
@@ -38,7 +37,9 @@ static void sorted_array_insert(uint32_t* array, int* size, uint32_t item)
{ {
int pos; int pos;
for (pos = *size; pos > 0; pos--) { for (pos = *size; pos > 0; pos--) {
if (array[pos-1] < item) break; if (array[pos - 1] < item) {
break;
}
array[pos] = array[pos - 1]; array[pos] = array[pos - 1];
} }
array[pos] = item; array[pos] = item;

View File

@@ -18,7 +18,6 @@
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
#include "esp_vfs.h" #include "esp_vfs.h"
TEST_CASE("misc - posix_memalign", "[newlib_misc]") TEST_CASE("misc - posix_memalign", "[newlib_misc]")
{ {
void* outptr = NULL; void* outptr = NULL;

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -95,7 +95,6 @@ TEST_CASE("test time functions", "[newlib]")
} }
TEST_CASE("test asctime", "[newlib]") TEST_CASE("test asctime", "[newlib]")
{ {
char buf[64]; char buf[64];
@@ -204,7 +203,6 @@ TEST_CASE("test 64bit int formats", "[newlib]")
} }
#endif // CONFIG_NEWLIB_NANO_FORMAT #endif // CONFIG_NEWLIB_NANO_FORMAT
TEST_CASE("fmod and fmodf work as expected", "[newlib]") TEST_CASE("fmod and fmodf work as expected", "[newlib]")
{ {
TEST_ASSERT_EQUAL(0.1, fmod(10.1, 2.0)); TEST_ASSERT_EQUAL(0.1, fmod(10.1, 2.0));
@@ -216,7 +214,6 @@ TEST_CASE("newlib: can link 'system', 'raise'", "[newlib]")
printf("system: %p, raise: %p\n", &system, &raise); printf("system: %p, raise: %p\n", &system, &raise);
} }
TEST_CASE("newlib: rom and toolchain localtime func gives the same result", "[newlib]") TEST_CASE("newlib: rom and toolchain localtime func gives the same result", "[newlib]")
{ {
// This UNIX time represents 2020-03-12 15:00:00 EDT (19:00 GMT) // This UNIX time represents 2020-03-12 15:00:00 EDT (19:00 GMT)

View File

@@ -9,7 +9,6 @@
#include "unity.h" #include "unity.h"
#include "esp_system.h" #include "esp_system.h"
typedef struct { typedef struct {
jmp_buf jmp_env; jmp_buf jmp_env;
uint32_t retval; uint32_t retval;

View File

@@ -21,7 +21,6 @@ atomic_uint g_atomic32;
atomic_ushort g_atomic16; atomic_ushort g_atomic16;
atomic_uchar g_atomic8; atomic_uchar g_atomic8;
TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]") TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
{ {
unsigned long long x64 = 0; unsigned long long x64 = 0;
@@ -173,7 +172,6 @@ TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
#endif // #ifndef __clang__ #endif // #ifndef __clang__
#define TEST_EXCLUSION(n) TEST_CASE("stdatomic - test_" #n "bit_exclusion", "[newlib_stdatomic]") \ #define TEST_EXCLUSION(n) TEST_CASE("stdatomic - test_" #n "bit_exclusion", "[newlib_stdatomic]") \
{ \ { \
g_atomic ## n = 0; \ g_atomic ## n = 0; \
@@ -216,7 +214,6 @@ TEST_EXCLUSION(16)
TEST_EXCLUSION_TASK(8) TEST_EXCLUSION_TASK(8)
TEST_EXCLUSION(8) TEST_EXCLUSION(8)
#define ITER_COUNT 20000 #define ITER_COUNT 20000
#define TEST_RACE_OPERATION(ASSERT_SUFFIX, NAME, LHSTYPE, PRE, POST, INIT, FINAL) \ #define TEST_RACE_OPERATION(ASSERT_SUFFIX, NAME, LHSTYPE, PRE, POST, INIT, FINAL) \

View File

@@ -72,7 +72,6 @@ static void time_adc_test_task(void* arg)
vTaskDelete(NULL); vTaskDelete(NULL);
} }
TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]") TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]")
{ {
SemaphoreHandle_t done = xSemaphoreCreateBinary(); SemaphoreHandle_t done = xSemaphoreCreateBinary();
@@ -190,7 +189,9 @@ static void adjtimeTask2(void *pvParameters)
while (exit_flag == false) { while (exit_flag == false) {
delta.tv_sec += 1; delta.tv_sec += 1;
delta.tv_usec = 900000; delta.tv_usec = 900000;
if (delta.tv_sec >= 2146) delta.tv_sec = 1; if (delta.tv_sec >= 2146) {
delta.tv_sec = 1;
}
adjtime(&delta, &outdelta); adjtime(&delta, &outdelta);
} }
xSemaphoreGive(*sema); xSemaphoreGive(*sema);
@@ -563,7 +564,6 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]")
extern int64_t s_microseconds_offset; extern int64_t s_microseconds_offset;
static const uint64_t s_start_timestamp = 1606838354; static const uint64_t s_start_timestamp = 1606838354;
static __NOINIT_ATTR uint64_t s_saved_time; static __NOINIT_ATTR uint64_t s_saved_time;
static __NOINIT_ATTR uint64_t s_time_in_reboot; static __NOINIT_ATTR uint64_t s_time_in_reboot;
@@ -662,7 +662,6 @@ static void check_time(void)
TEST_ASSERT_LESS_OR_EQUAL(latency_before_run_ut, dt); TEST_ASSERT_LESS_OR_EQUAL(latency_before_run_ut, dt);
} }
TEST_CASE_MULTIPLE_STAGES("Timestamp after abort is correct in case RTC & High-res timer have + big error", "[newlib][reset=abort,SW_CPU_RESET]", set_timestamp1, check_time); TEST_CASE_MULTIPLE_STAGES("Timestamp after abort is correct in case RTC & High-res timer have + big error", "[newlib][reset=abort,SW_CPU_RESET]", set_timestamp1, check_time);
TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have + big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp2, check_time); TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have + big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp2, check_time);
TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have - big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp3, check_time); TEST_CASE_MULTIPLE_STAGES("Timestamp after restart is correct in case RTC & High-res timer have - big error", "[newlib][reset=SW_CPU_RESET]", set_timestamp3, check_time);

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -83,7 +83,6 @@ static uint64_t adjust_boot_time(void)
return boot_time; return boot_time;
} }
// Get the adjusted boot time. // Get the adjusted boot time.
static uint64_t get_adjusted_boot_time(void) static uint64_t get_adjusted_boot_time(void)
{ {

View File

@@ -65,7 +65,6 @@ static SLIST_HEAD(esp_thread_list_head, esp_pthread_entry) s_threads_list
= SLIST_HEAD_INITIALIZER(s_threads_list); = SLIST_HEAD_INITIALIZER(s_threads_list);
static pthread_key_t s_pthread_cfg_key; static pthread_key_t s_pthread_cfg_key;
static int pthread_mutex_lock_internal(esp_pthread_mutex_t *mux, TickType_t tmo); static int pthread_mutex_lock_internal(esp_pthread_mutex_t *mux, TickType_t tmo);
static void esp_pthread_cfg_key_destructor(void *value) static void esp_pthread_cfg_key_destructor(void *value)

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2017-2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */
@@ -23,7 +23,6 @@
#include "esp_log.h" #include "esp_log.h"
const static char *TAG = "pthread_rw_lock"; const static char *TAG = "pthread_rw_lock";
/** pthread rw_mutex FreeRTOS wrapper */ /** pthread rw_mutex FreeRTOS wrapper */
typedef struct { typedef struct {
/** /**
@@ -247,7 +246,8 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
return 0; return 0;
} }
int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) { int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
{
esp_pthread_rwlock_t *esp_rwlock; esp_pthread_rwlock_t *esp_rwlock;
int res; int res;

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Apache-2.0 * SPDX-License-Identifier: Apache-2.0
*/ */

View File

@@ -11,7 +11,6 @@
#include "unity_test_runner.h" #include "unity_test_runner.h"
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
// Some resources are lazy allocated (e.g. newlib locks), the threshold is left for that case // Some resources are lazy allocated (e.g. newlib locks), the threshold is left for that case
#define TEST_MEMORY_LEAK_THRESHOLD (-200) #define TEST_MEMORY_LEAK_THRESHOLD (-200)

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -24,11 +24,14 @@ static void waits(int idx, int timeout_ms)
std::unique_lock<std::mutex> lk(cv_m); std::unique_lock<std::mutex> lk(cv_m);
auto now = std::chrono::system_clock::now(); auto now = std::chrono::system_clock::now();
if(cv.wait_until(lk, now + std::chrono::milliseconds(timeout_ms), [](){return i == 1;})) if (cv.wait_until(lk, now + std::chrono::milliseconds(timeout_ms), []() {
return i == 1;
}))
std::cout << "Thread " << idx << " finished waiting. i == " << i << '\n'; std::cout << "Thread " << idx << " finished waiting. i == " << i << '\n';
else else {
std::cout << "Thread " << idx << " timed out. i == " << i << '\n'; std::cout << "Thread " << idx << " timed out. i == " << i << '\n';
} }
}
static void signals(int signal_ms) static void signals(int signal_ms)
{ {
@@ -53,7 +56,6 @@ TEST_CASE("C++ condition_variable", "[std::condition_variable]")
std::cout << "All threads joined\n"; std::cout << "All threads joined\n";
} }
TEST_CASE("cxx: condition_variable can timeout", "[cxx]") TEST_CASE("cxx: condition_variable can timeout", "[cxx]")
{ {
std::condition_variable cv; std::condition_variable cv;
@@ -84,7 +86,8 @@ TEST_CASE("cxx: condition_variable timeout never before deadline", "[cxx]")
(deadline - secs); (deadline - secs);
struct timespec ts = { struct timespec ts = {
.tv_sec = static_cast<time_t>(secs.time_since_epoch().count()), .tv_sec = static_cast<time_t>(secs.time_since_epoch().count()),
.tv_nsec = static_cast<long>(nsecs.count())}; .tv_nsec = static_cast<long>(nsecs.count())
};
int rc = ::pthread_cond_timedwait(cond.native_handle(), int rc = ::pthread_cond_timedwait(cond.native_handle(),
lock.mutex()->native_handle(), &ts); lock.mutex()->native_handle(), &ts);
auto status = (rc == ETIMEDOUT) ? std::cv_status::timeout : auto status = (rc == ETIMEDOUT) ? std::cv_status::timeout :

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */

View File

@@ -1,5 +1,5 @@
/* /*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* *
* SPDX-License-Identifier: Unlicense OR CC0-1.0 * SPDX-License-Identifier: Unlicense OR CC0-1.0
*/ */
@@ -153,7 +153,6 @@ static void *thread_stress_test(void *v_key)
return NULL; return NULL;
} }
// This test case added to reproduce issues with unpinned tasks and TLS // This test case added to reproduce issues with unpinned tasks and TLS
TEST_CASE("pthread local storage stress test", "[thread-specific]") TEST_CASE("pthread local storage stress test", "[thread-specific]")
{ {
@@ -169,7 +168,6 @@ TEST_CASE("pthread local storage stress test", "[thread-specific]")
} }
} }
#define NUM_KEYS 4 // number of keys used in repeat destructor test #define NUM_KEYS 4 // number of keys used in repeat destructor test
#define NUM_REPEATS 17 // number of times we re-set a key to a non-NULL value to re-trigger destructor #define NUM_REPEATS 17 // number of times we re-set a key to a non-NULL value to re-trigger destructor
@@ -179,7 +177,6 @@ typedef struct {
int last_idx; // index of last key where destructor was called int last_idx; // index of last key where destructor was called
} destr_test_state_t; } destr_test_state_t;
static void s_test_repeat_destructor(void *vp_state); static void s_test_repeat_destructor(void *vp_state);
static void *s_test_repeat_destructor_thread(void *vp_state); static void *s_test_repeat_destructor_thread(void *vp_state);

View File

@@ -78,7 +78,6 @@ components_not_formatted_temporary:
- "/components/lwip/" - "/components/lwip/"
- "/components/mbedtls/" - "/components/mbedtls/"
- "/components/mqtt/" - "/components/mqtt/"
- "/components/newlib/"
- "/components/nvs_flash/" - "/components/nvs_flash/"
- "/components/nvs_sec_provider/" - "/components/nvs_sec_provider/"
- "/components/openthread/" - "/components/openthread/"
@@ -86,7 +85,6 @@ components_not_formatted_temporary:
- "/components/perfmon/" - "/components/perfmon/"
- "/components/protobuf-c/" - "/components/protobuf-c/"
- "/components/protocomm/" - "/components/protocomm/"
- "/components/pthread/"
- "/components/riscv/" - "/components/riscv/"
- "/components/sdmmc/" - "/components/sdmmc/"
- "/components/soc/" - "/components/soc/"