mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
refactor(core): reformat newlib and pthread with astyle
This commit is contained in:
parent
b39f13d685
commit
f2fe408b99
@ -13,8 +13,8 @@
|
||||
|
||||
void __attribute__((noreturn)) abort(void)
|
||||
{
|
||||
#define ERR_STR1 "abort() was called at PC 0x"
|
||||
#define ERR_STR2 " on core "
|
||||
#define ERR_STR1 "abort() was called at PC 0x"
|
||||
#define ERR_STR2 " on core "
|
||||
|
||||
_Static_assert(UINTPTR_MAX == 0xffffffff, "abort() assumes 32-bit addresses");
|
||||
_Static_assert(SOC_CPU_CORES_NUM < 10, "abort() assumes number of cores is 1 to 9");
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
@ -11,14 +11,13 @@
|
||||
#include <malloc.h>
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
extern void *heap_caps_malloc_default( size_t size );
|
||||
extern void *heap_caps_realloc_default( void *ptr, size_t size );
|
||||
extern void *heap_caps_aligned_alloc_default( size_t alignment, size_t size );
|
||||
extern void *heap_caps_malloc_default(size_t size);
|
||||
extern void *heap_caps_realloc_default(void *ptr, size_t size);
|
||||
extern void *heap_caps_aligned_alloc_default(size_t alignment, size_t size);
|
||||
|
||||
void* malloc(size_t size)
|
||||
{
|
||||
@ -52,7 +51,7 @@ void _free_r(struct _reent *r, void* ptr)
|
||||
|
||||
void* _realloc_r(struct _reent *r, void* ptr, size_t size)
|
||||
{
|
||||
return heap_caps_realloc_default( ptr, size );
|
||||
return heap_caps_realloc_default(ptr, size);
|
||||
}
|
||||
|
||||
void* _calloc_r(struct _reent *r, size_t nmemb, size_t size)
|
||||
|
@ -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
|
||||
*/
|
||||
@ -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
|
||||
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);
|
||||
if (*lock) {
|
||||
/* Lock already initialised (either we didn't check earlier,
|
||||
or it got initialised while we were waiting for the
|
||||
spinlock.) */
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* Create a new semaphore
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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_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_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
|
||||
this!
|
||||
*/
|
||||
void IRAM_ATTR _lock_close(_lock_t *lock) {
|
||||
void IRAM_ATTR _lock_close(_lock_t *lock)
|
||||
{
|
||||
portENTER_CRITICAL(&lock_init_spinlock);
|
||||
if (*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.
|
||||
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);
|
||||
if (!h) {
|
||||
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) {
|
||||
portYIELD_FROM_ISR();
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
/* In task context */
|
||||
if (mutex_type == queueQUEUE_TYPE_RECURSIVE_MUTEX) {
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/* Release the mutex semaphore for lock.
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -242,7 +251,6 @@ _Static_assert(configSUPPORT_STATIC_ALLOCATION,
|
||||
static StaticSemaphore_t s_common_mutex;
|
||||
static StaticSemaphore_t s_common_recursive_mutex;
|
||||
|
||||
|
||||
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||
/* C3 and S3 ROMs are built without Newlib static lock symbols exported, and
|
||||
* 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)
|
||||
#endif // ROM_NEEDS_MUTEX_OVERRIDE
|
||||
|
||||
|
||||
void IRAM_ATTR __retarget_lock_init(_LOCK_T *lock)
|
||||
{
|
||||
*lock = NULL; /* In case lock's memory is uninitialized */
|
||||
|
@ -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
|
||||
*/
|
||||
@ -45,10 +45,9 @@
|
||||
extern int _printf_float(struct _reent *rptr,
|
||||
void *pdata,
|
||||
FILE * fp,
|
||||
int (*pfunc) (struct _reent *, FILE *, const char *, size_t len),
|
||||
int (*pfunc)(struct _reent *, FILE *, const char *, size_t len),
|
||||
va_list * ap);
|
||||
|
||||
|
||||
extern int _scanf_float(struct _reent *rptr,
|
||||
void *pdata,
|
||||
FILE *fp,
|
||||
@ -59,7 +58,7 @@ static void raise_r_stub(struct _reent *rptr)
|
||||
_raise_r(rptr, 0);
|
||||
}
|
||||
|
||||
static void esp_cleanup_r (struct _reent *rptr)
|
||||
static void esp_cleanup_r(struct _reent *rptr)
|
||||
{
|
||||
if (_REENT_STDIN(rptr) != _REENT_STDIN(_GLOBAL_REENT)) {
|
||||
_fclose_r(rptr, _REENT_STDIN(rptr));
|
||||
@ -69,7 +68,7 @@ static void esp_cleanup_r (struct _reent *rptr)
|
||||
_fclose_r(rptr, _REENT_STDOUT(rptr));
|
||||
}
|
||||
|
||||
if (_REENT_STDERR(rptr) !=_REENT_STDERR(_GLOBAL_REENT)) {
|
||||
if (_REENT_STDERR(rptr) != _REENT_STDERR(_GLOBAL_REENT)) {
|
||||
_fclose_r(rptr, _REENT_STDERR(rptr));
|
||||
}
|
||||
}
|
||||
@ -96,9 +95,9 @@ static struct syscall_stub_table s_stub_table = {
|
||||
._exit_r = NULL, // never called in ROM
|
||||
._close_r = &_close_r,
|
||||
._open_r = &_open_r,
|
||||
._write_r = (int (*)(struct _reent *r, int, const void *, int)) &_write_r,
|
||||
._lseek_r = (int (*)(struct _reent *r, int, int, int)) &_lseek_r,
|
||||
._read_r = (int (*)(struct _reent *r, int, void *, int)) &_read_r,
|
||||
._write_r = (int (*)(struct _reent * r, int, const void *, int)) &_write_r,
|
||||
._lseek_r = (int (*)(struct _reent * r, int, int, int)) &_lseek_r,
|
||||
._read_r = (int (*)(struct _reent * r, int, void *, int)) &_read_r,
|
||||
#if ESP_ROM_HAS_RETARGETABLE_LOCKING
|
||||
._retarget_lock_init = &__retarget_lock_init,
|
||||
._retarget_lock_init_recursive = &__retarget_lock_init_recursive,
|
||||
@ -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)
|
||||
{
|
||||
if (stdio_dev == NULL)
|
||||
{
|
||||
if (stdio_dev == NULL) {
|
||||
_GLOBAL_REENT->__cleanup = NULL;
|
||||
_REENT_SDIDINIT(_GLOBAL_REENT) = 0;
|
||||
__sinit(_GLOBAL_REENT);
|
||||
@ -216,7 +214,7 @@ void esp_newlib_init_global_stdio(const char *stdio_dev)
|
||||
file pointers. Thus, the ROM newlib code will never call the ROM version of __swsetup_r().
|
||||
- See IDFGH-7728 for more details
|
||||
*/
|
||||
extern int __swsetup_r (struct _reent *, FILE *);
|
||||
extern int __swsetup_r(struct _reent *, FILE *);
|
||||
__swsetup_r(_GLOBAL_REENT, _REENT_STDIN(_GLOBAL_REENT));
|
||||
__swsetup_r(_GLOBAL_REENT, _REENT_STDOUT(_GLOBAL_REENT));
|
||||
__swsetup_r(_GLOBAL_REENT, _REENT_STDERR(_GLOBAL_REENT));
|
||||
|
@ -4,7 +4,6 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
|
||||
/* This header file wraps newlib's own unmodified assert.h and adds
|
||||
support for silent assertion failure.
|
||||
*/
|
||||
|
@ -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: 2002 Thomas Moestl <tmm@FreeBSD.org>
|
||||
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD AND Apache-2.0
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
*/
|
||||
@ -28,7 +28,6 @@ extern "C" {
|
||||
|
||||
typedef u32_t socklen_t;
|
||||
|
||||
|
||||
unsigned int if_nametoindex(const char *ifname);
|
||||
|
||||
char *if_indextoname(unsigned int ifindex, char *ifname);
|
||||
|
@ -42,7 +42,7 @@ struct dirent {
|
||||
#define DT_DIR 2
|
||||
#if __BSD_VISIBLE
|
||||
#define MAXNAMLEN 255
|
||||
char d_name[MAXNAMLEN+1]; /*!< zero-terminated file name */
|
||||
char d_name[MAXNAMLEN + 1]; /*!< zero-terminated file name */
|
||||
#else
|
||||
char d_name[256];
|
||||
#endif
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -21,14 +21,13 @@
|
||||
|
||||
#include_next<sys/reent.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if __NEWLIB__ > 4 || ( __NEWLIB__ == 4 && __NEWLIB_MINOR__ > 1 ) /* TODO: IDF-8134 */
|
||||
|
||||
extern void __sinit (struct _reent *);
|
||||
extern void __sinit(struct _reent *);
|
||||
|
||||
extern struct _glue __sglue;
|
||||
extern struct _reent * _global_impure_ptr;
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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
|
||||
// in actual implementations.
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include "sdkconfig.h"
|
||||
@ -164,8 +163,7 @@ typedef uint8_t cc_t;
|
||||
typedef uint32_t speed_t;
|
||||
typedef uint16_t tcflag_t;
|
||||
|
||||
struct termios
|
||||
{
|
||||
struct termios {
|
||||
tcflag_t c_iflag; /** Input modes */
|
||||
tcflag_t c_oflag; /** Output modes */
|
||||
tcflag_t c_cflag; /** Control modes */
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -60,7 +60,7 @@ int poll(struct pollfd *fds, nfds_t nfds, int timeout)
|
||||
}
|
||||
}
|
||||
|
||||
const int select_ret = select(max_fd + 1, &readfds, &writefds, &errorfds, timeout < 0 ? NULL: &tv);
|
||||
const int select_ret = select(max_fd + 1, &readfds, &writefds, &errorfds, timeout < 0 ? NULL : &tv);
|
||||
|
||||
if (select_ret > 0) {
|
||||
ret += select_ret;
|
||||
|
@ -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
|
||||
*/
|
||||
@ -50,8 +50,6 @@
|
||||
#include "esp32p4/rtc.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
// Offset between High resolution timer and the RTC.
|
||||
// Initialized after reset or light sleep.
|
||||
#if defined(CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER) && defined(CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER)
|
||||
@ -94,13 +92,12 @@ 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 )
|
||||
|
||||
|
||||
void esp_time_impl_set_boot_time(uint64_t time_us)
|
||||
{
|
||||
_lock_acquire(&s_boot_time_lock);
|
||||
#ifdef CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER
|
||||
REG_WRITE(RTC_BOOT_TIME_LOW_REG, (uint32_t) (time_us & 0xffffffff));
|
||||
REG_WRITE(RTC_BOOT_TIME_HIGH_REG, (uint32_t) (time_us >> 32));
|
||||
REG_WRITE(RTC_BOOT_TIME_LOW_REG, (uint32_t)(time_us & 0xffffffff));
|
||||
REG_WRITE(RTC_BOOT_TIME_HIGH_REG, (uint32_t)(time_us >> 32));
|
||||
#else
|
||||
s_boot_time = time_us;
|
||||
#endif
|
||||
|
@ -43,7 +43,6 @@ char * realpath(const char *file_name, char *resolved_name)
|
||||
/* number of path components in the output buffer */
|
||||
size_t out_depth = 0;
|
||||
|
||||
|
||||
while (*in_ptr) {
|
||||
/* "path component" is the part between two '/' path separators.
|
||||
* locate the next path component in the input path:
|
||||
|
@ -49,7 +49,7 @@ void esp_reent_cleanup(void)
|
||||
|
||||
/* Clean up "glue" (lazily-allocated FILE objects) */
|
||||
struct _glue* prev = &_REENT_SGLUE(_GLOBAL_REENT);
|
||||
for (struct _glue* cur = _REENT_SGLUE(_GLOBAL_REENT)._next; cur != NULL;) {
|
||||
for (struct _glue * cur = _REENT_SGLUE(_GLOBAL_REENT)._next; cur != NULL;) {
|
||||
if (cur->_niobs == 0) {
|
||||
cur = cur->_next;
|
||||
continue;
|
||||
@ -67,7 +67,7 @@ void esp_reent_cleanup(void)
|
||||
cur = cur->_next;
|
||||
continue;
|
||||
}
|
||||
struct _glue* next = cur->_next;
|
||||
struct _glue * next = cur->_next;
|
||||
prev->_next = next;
|
||||
free(cur);
|
||||
cur = next;
|
||||
|
@ -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
|
||||
*/
|
||||
@ -297,7 +297,6 @@ CLANG_DECLARE_ALIAS( __sync_lock_test_and_set_ ## n )
|
||||
} \
|
||||
CLANG_DECLARE_ALIAS( __sync_lock_release_ ## n )
|
||||
|
||||
|
||||
#if !HAS_ATOMICS_32
|
||||
|
||||
_Static_assert(sizeof(unsigned char) == 1, "atomics require a 1-byte type");
|
||||
@ -376,21 +375,21 @@ SYNC_OP_FETCH(sub, 1, unsigned char)
|
||||
SYNC_OP_FETCH(sub, 2, short unsigned int)
|
||||
SYNC_OP_FETCH(sub, 4, unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(and, 1, unsigned char)
|
||||
SYNC_FETCH_OP(and, 2, short unsigned int)
|
||||
SYNC_FETCH_OP(and, 4, unsigned int)
|
||||
SYNC_FETCH_OP( and, 1, unsigned char)
|
||||
SYNC_FETCH_OP( and, 2, short unsigned int)
|
||||
SYNC_FETCH_OP( and, 4, unsigned int)
|
||||
|
||||
SYNC_OP_FETCH(and, 1, unsigned char)
|
||||
SYNC_OP_FETCH(and, 2, short unsigned int)
|
||||
SYNC_OP_FETCH(and, 4, unsigned int)
|
||||
SYNC_OP_FETCH( and, 1, unsigned char)
|
||||
SYNC_OP_FETCH( and, 2, short unsigned int)
|
||||
SYNC_OP_FETCH( and, 4, unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(or, 1, unsigned char)
|
||||
SYNC_FETCH_OP(or, 2, short unsigned int)
|
||||
SYNC_FETCH_OP(or, 4, unsigned int)
|
||||
SYNC_FETCH_OP( or, 1, unsigned char)
|
||||
SYNC_FETCH_OP( or, 2, short unsigned int)
|
||||
SYNC_FETCH_OP( or, 4, unsigned int)
|
||||
|
||||
SYNC_OP_FETCH(or, 1, unsigned char)
|
||||
SYNC_OP_FETCH(or, 2, short unsigned int)
|
||||
SYNC_OP_FETCH(or, 4, unsigned int)
|
||||
SYNC_OP_FETCH( or, 1, unsigned char)
|
||||
SYNC_OP_FETCH( or, 2, short unsigned int)
|
||||
SYNC_OP_FETCH( or, 4, unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(xor, 1, unsigned char)
|
||||
SYNC_FETCH_OP(xor, 2, short unsigned int)
|
||||
@ -416,7 +415,6 @@ SYNC_VAL_CMP_EXCHANGE(1, unsigned char)
|
||||
SYNC_VAL_CMP_EXCHANGE(2, short unsigned int)
|
||||
SYNC_VAL_CMP_EXCHANGE(4, unsigned int)
|
||||
|
||||
|
||||
SYNC_LOCK_TEST_AND_SET(1, unsigned char)
|
||||
SYNC_LOCK_TEST_AND_SET(2, short unsigned int)
|
||||
SYNC_LOCK_TEST_AND_SET(4, unsigned int)
|
||||
@ -436,15 +434,17 @@ ATOMIC_STORE(4, unsigned int)
|
||||
|
||||
#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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
CLANG_DECLARE_ALIAS( __atomic_is_lock_free)
|
||||
CLANG_DECLARE_ALIAS(__atomic_is_lock_free)
|
||||
|
||||
#endif // !HAS_ATOMICS_32
|
||||
|
||||
@ -484,9 +484,9 @@ SYNC_FETCH_OP(add, 8, long long unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(sub, 8, long long unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(and, 8, long long unsigned int)
|
||||
SYNC_FETCH_OP( and, 8, long long unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(or, 8, long long unsigned int)
|
||||
SYNC_FETCH_OP( or, 8, long long unsigned int)
|
||||
|
||||
SYNC_FETCH_OP(xor, 8, long long unsigned int)
|
||||
|
||||
@ -496,9 +496,9 @@ SYNC_OP_FETCH(add, 8, long long unsigned int)
|
||||
|
||||
SYNC_OP_FETCH(sub, 8, long long unsigned int)
|
||||
|
||||
SYNC_OP_FETCH(and, 8, long long unsigned int)
|
||||
SYNC_OP_FETCH( and, 8, long long unsigned int)
|
||||
|
||||
SYNC_OP_FETCH(or, 8, long long unsigned int)
|
||||
SYNC_OP_FETCH( or, 8, long long unsigned int)
|
||||
|
||||
SYNC_OP_FETCH(xor, 8, long long unsigned int)
|
||||
|
||||
@ -519,21 +519,24 @@ ATOMIC_STORE(8, long long unsigned int)
|
||||
#endif // !HAS_ATOMICS_64
|
||||
|
||||
// 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();
|
||||
memcpy(dest, (const void *)src, size);
|
||||
_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();
|
||||
memcpy((void *)dest, (const void *)src, size);
|
||||
_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;
|
||||
unsigned state = _ATOMIC_ENTER_CRITICAL();
|
||||
if (!memcmp((void *)ptr, expected, size)) {
|
||||
@ -545,4 +548,4 @@ bool CLANG_ATOMIC_SUFFIX(__atomic_compare_exchange) (size_t size, volatile void
|
||||
_ATOMIC_EXIT_CRITICAL(state);
|
||||
return ret;
|
||||
}
|
||||
CLANG_DECLARE_ALIAS( __atomic_compare_exchange)
|
||||
CLANG_DECLARE_ALIAS(__atomic_compare_exchange)
|
||||
|
@ -83,20 +83,18 @@ static int _fsync_console(int fd)
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* The following weak definitions of syscalls will be used unless
|
||||
* another definition is provided. That definition may come from
|
||||
* VFS, LWIP, or the application.
|
||||
*/
|
||||
ssize_t _read_r(struct _reent *r, int fd, void * dst, size_t size)
|
||||
__attribute__((weak,alias("_read_r_console")));
|
||||
__attribute__((weak, alias("_read_r_console")));
|
||||
ssize_t _write_r(struct _reent *r, int fd, const void * data, size_t size)
|
||||
__attribute__((weak,alias("_write_r_console")));
|
||||
int _fstat_r (struct _reent *r, int fd, struct stat *st)
|
||||
__attribute__((weak,alias("_fstat_r_console")));
|
||||
__attribute__((weak, alias("_write_r_console")));
|
||||
int _fstat_r(struct _reent *r, int fd, struct stat *st)
|
||||
__attribute__((weak, alias("_fstat_r_console")));
|
||||
int fsync(int fd)
|
||||
__attribute__((weak,alias("_fsync_console")));
|
||||
|
||||
__attribute__((weak, alias("_fsync_console")));
|
||||
|
||||
/* The aliases below are to "syscall_not_implemented", which
|
||||
* doesn't have the same signature as the original function.
|
||||
@ -108,40 +106,39 @@ int fsync(int fd)
|
||||
#endif
|
||||
|
||||
int _open_r(struct _reent *r, const char * path, int flags, int mode)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
int _close_r(struct _reent *r, int fd)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
off_t _lseek_r(struct _reent *r, int fd, off_t size, int mode)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
int _fcntl_r(struct _reent *r, int fd, int cmd, int arg)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
int _stat_r(struct _reent *r, const char * path, struct stat * st)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
int _link_r(struct _reent *r, const char* n1, const char* n2)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
int _unlink_r(struct _reent *r, const char *path)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
int _rename_r(struct _reent *r, const char *src, const char *dst)
|
||||
__attribute__((weak,alias("syscall_not_implemented")));
|
||||
__attribute__((weak, alias("syscall_not_implemented")));
|
||||
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 */
|
||||
int _system_r(struct _reent *r, const char *str)
|
||||
__attribute__((alias("syscall_not_implemented")));
|
||||
__attribute__((alias("syscall_not_implemented")));
|
||||
int raise(int sig)
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
int _raise_r(struct _reent *r, int sig)
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
void* _sbrk_r(struct _reent *r, ptrdiff_t sz)
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
int _getpid_r(struct _reent *r)
|
||||
__attribute__((alias("syscall_not_implemented")));
|
||||
__attribute__((alias("syscall_not_implemented")));
|
||||
int _kill_r(struct _reent *r, int pid, int sig)
|
||||
__attribute__((alias("syscall_not_implemented")));
|
||||
__attribute__((alias("syscall_not_implemented")));
|
||||
void _exit(int __status)
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
__attribute__((alias("syscall_not_implemented_aborts")));
|
||||
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
#pragma GCC diagnostic pop
|
||||
|
@ -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
|
||||
*/
|
||||
@ -14,7 +14,6 @@
|
||||
#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 TEST_TIMES 11
|
||||
|
||||
//Test twice, and only get the result of second time, to avoid influence of cache miss
|
||||
@ -37,11 +36,13 @@ static uint32_t s_t_ref;
|
||||
static void sorted_array_insert(uint32_t* array, int* size, uint32_t item)
|
||||
{
|
||||
int pos;
|
||||
for (pos = *size; pos>0; pos--) {
|
||||
if (array[pos-1] < item) break;
|
||||
array[pos] = array[pos-1];
|
||||
for (pos = *size; pos > 0; pos--) {
|
||||
if (array[pos - 1] < item) {
|
||||
break;
|
||||
}
|
||||
array[pos]=item;
|
||||
array[pos] = array[pos - 1];
|
||||
}
|
||||
array[pos] = item;
|
||||
(*size)++;
|
||||
}
|
||||
|
||||
@ -56,7 +57,7 @@ static void test_flow(const char* name, test_f func)
|
||||
sorted_array_insert(t_flight_sorted, &t_flight_num, t_op);
|
||||
}
|
||||
for (int i = 0; i < TEST_TIMES; i++) {
|
||||
ESP_LOGI(TAG, "%s: %" PRIu32 " ops", name, t_flight_sorted[i]-s_t_ref);
|
||||
ESP_LOGI(TAG, "%s: %" PRIu32 " ops", name, t_flight_sorted[i] - s_t_ref);
|
||||
}
|
||||
}
|
||||
|
||||
@ -126,7 +127,7 @@ static IRAM_ATTR void test_atomic_compare_exchange(uint32_t* t_op)
|
||||
(void) res;
|
||||
}
|
||||
|
||||
TEST_CASE("test atomic","[atomic]")
|
||||
TEST_CASE("test atomic", "[atomic]")
|
||||
{
|
||||
test_flow("ref", test_ref);
|
||||
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_vfs.h"
|
||||
|
||||
|
||||
TEST_CASE("misc - posix_memalign", "[newlib_misc]")
|
||||
{
|
||||
void* outptr = NULL;
|
||||
|
@ -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
|
||||
*/
|
||||
@ -18,12 +18,12 @@
|
||||
|
||||
TEST_CASE("test ctype functions", "[newlib]")
|
||||
{
|
||||
TEST_ASSERT_TRUE( isalnum('a') && isalnum('A') && isalnum('z') && isalnum('Z') && isalnum('0') && isalnum('9') );
|
||||
TEST_ASSERT_FALSE( isalnum('(') || isalnum('-') || isalnum(' ') || isalnum('\x81') || isalnum('.') || isalnum('\\') );
|
||||
TEST_ASSERT_TRUE( isalpha('a') && isalpha('A') && isalpha('z') && isalpha('Z') );
|
||||
TEST_ASSERT_FALSE( isalpha('0') || isalpha('9') || isalpha(')') || isalpha('\t') || isalpha(' ') || isalpha('\x81') );
|
||||
TEST_ASSERT_TRUE( isspace(' ') && isspace('\t') && isspace('\n') && isspace('\r') );
|
||||
TEST_ASSERT_FALSE( isspace('0') || isspace('9') || isspace(')') || isspace('A') || isspace('*') || isspace('\x81') || isspace('a'));
|
||||
TEST_ASSERT_TRUE(isalnum('a') && isalnum('A') && isalnum('z') && isalnum('Z') && isalnum('0') && isalnum('9'));
|
||||
TEST_ASSERT_FALSE(isalnum('(') || isalnum('-') || isalnum(' ') || isalnum('\x81') || isalnum('.') || isalnum('\\'));
|
||||
TEST_ASSERT_TRUE(isalpha('a') && isalpha('A') && isalpha('z') && isalpha('Z'));
|
||||
TEST_ASSERT_FALSE(isalpha('0') || isalpha('9') || isalpha(')') || isalpha('\t') || isalpha(' ') || isalpha('\x81'));
|
||||
TEST_ASSERT_TRUE(isspace(' ') && isspace('\t') && isspace('\n') && isspace('\r'));
|
||||
TEST_ASSERT_FALSE(isspace('0') || isspace('9') || isspace(')') || isspace('A') || isspace('*') || isspace('\x81') || isspace('a'));
|
||||
}
|
||||
|
||||
TEST_CASE("test atoX functions", "[newlib]")
|
||||
@ -74,28 +74,27 @@ TEST_CASE("test time functions", "[newlib]")
|
||||
setenv("TZ", "UTC-8", 1);
|
||||
tzset();
|
||||
struct tm *tm_utc = gmtime(&now);
|
||||
TEST_ASSERT_EQUAL( 28, tm_utc->tm_sec);
|
||||
TEST_ASSERT_EQUAL( 41, tm_utc->tm_min);
|
||||
TEST_ASSERT_EQUAL( 7, tm_utc->tm_hour);
|
||||
TEST_ASSERT_EQUAL( 26, tm_utc->tm_mday);
|
||||
TEST_ASSERT_EQUAL( 4, tm_utc->tm_mon);
|
||||
TEST_ASSERT_EQUAL(28, tm_utc->tm_sec);
|
||||
TEST_ASSERT_EQUAL(41, tm_utc->tm_min);
|
||||
TEST_ASSERT_EQUAL(7, tm_utc->tm_hour);
|
||||
TEST_ASSERT_EQUAL(26, tm_utc->tm_mday);
|
||||
TEST_ASSERT_EQUAL(4, tm_utc->tm_mon);
|
||||
TEST_ASSERT_EQUAL(116, tm_utc->tm_year);
|
||||
TEST_ASSERT_EQUAL( 4, tm_utc->tm_wday);
|
||||
TEST_ASSERT_EQUAL(4, tm_utc->tm_wday);
|
||||
TEST_ASSERT_EQUAL(146, tm_utc->tm_yday);
|
||||
|
||||
struct tm *tm_local = localtime(&now);
|
||||
TEST_ASSERT_EQUAL( 28, tm_local->tm_sec);
|
||||
TEST_ASSERT_EQUAL( 41, tm_local->tm_min);
|
||||
TEST_ASSERT_EQUAL( 15, tm_local->tm_hour);
|
||||
TEST_ASSERT_EQUAL( 26, tm_local->tm_mday);
|
||||
TEST_ASSERT_EQUAL( 4, tm_local->tm_mon);
|
||||
TEST_ASSERT_EQUAL(28, tm_local->tm_sec);
|
||||
TEST_ASSERT_EQUAL(41, tm_local->tm_min);
|
||||
TEST_ASSERT_EQUAL(15, tm_local->tm_hour);
|
||||
TEST_ASSERT_EQUAL(26, tm_local->tm_mday);
|
||||
TEST_ASSERT_EQUAL(4, tm_local->tm_mon);
|
||||
TEST_ASSERT_EQUAL(116, tm_local->tm_year);
|
||||
TEST_ASSERT_EQUAL( 4, tm_local->tm_wday);
|
||||
TEST_ASSERT_EQUAL(4, tm_local->tm_wday);
|
||||
TEST_ASSERT_EQUAL(146, tm_local->tm_yday);
|
||||
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("test asctime", "[newlib]")
|
||||
{
|
||||
char buf[64];
|
||||
@ -204,7 +203,6 @@ TEST_CASE("test 64bit int formats", "[newlib]")
|
||||
}
|
||||
#endif // CONFIG_NEWLIB_NANO_FORMAT
|
||||
|
||||
|
||||
TEST_CASE("fmod and fmodf work as expected", "[newlib]")
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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)
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "unity.h"
|
||||
#include "esp_system.h"
|
||||
|
||||
|
||||
typedef struct {
|
||||
jmp_buf jmp_env;
|
||||
uint32_t retval;
|
||||
|
@ -21,19 +21,18 @@ atomic_uint g_atomic32;
|
||||
atomic_ushort g_atomic16;
|
||||
atomic_uchar g_atomic8;
|
||||
|
||||
|
||||
TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
|
||||
{
|
||||
unsigned long long x64 = 0;
|
||||
g_atomic64 = 0; // calls atomic_store
|
||||
|
||||
x64 += atomic_fetch_or (&g_atomic64, 0x1111111111111111ULL);
|
||||
x64 += atomic_fetch_or(&g_atomic64, 0x1111111111111111ULL);
|
||||
x64 += atomic_fetch_xor(&g_atomic64, 0x3333333333333333ULL);
|
||||
x64 += atomic_fetch_and(&g_atomic64, 0xf0f0f0f0f0f0f0f0ULL);
|
||||
x64 += atomic_fetch_sub(&g_atomic64, 0x0f0f0f0f0f0f0f0fULL);
|
||||
x64 += atomic_fetch_add(&g_atomic64, 0x2222222222222222ULL);
|
||||
#ifndef __clang__
|
||||
x64 += __atomic_fetch_nand_8 (&g_atomic64, 0xAAAAAAAAAAAAAAAAULL, 0);
|
||||
x64 += __atomic_fetch_nand_8(&g_atomic64, 0xAAAAAAAAAAAAAAAAULL, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX64(0x9797979797979797ULL, x64);
|
||||
TEST_ASSERT_EQUAL_HEX64(0xDDDDDDDDDDDDDDDDULL, g_atomic64); // calls atomic_load
|
||||
@ -48,13 +47,13 @@ TEST_CASE("stdatomic - test_32bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned int x32 = 0;
|
||||
g_atomic32 = 0;
|
||||
|
||||
x32 += atomic_fetch_or (&g_atomic32, 0x11111111U);
|
||||
x32 += atomic_fetch_or(&g_atomic32, 0x11111111U);
|
||||
x32 += atomic_fetch_xor(&g_atomic32, 0x33333333U);
|
||||
x32 += atomic_fetch_and(&g_atomic32, 0xf0f0f0f0U);
|
||||
x32 += atomic_fetch_sub(&g_atomic32, 0x0f0f0f0fU);
|
||||
x32 += atomic_fetch_add(&g_atomic32, 0x22222222U);
|
||||
#ifndef __clang__
|
||||
x32 += __atomic_fetch_nand_4 (&g_atomic32, 0xAAAAAAAAU, 0);
|
||||
x32 += __atomic_fetch_nand_4(&g_atomic32, 0xAAAAAAAAU, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX32(0x97979797U, x32);
|
||||
TEST_ASSERT_EQUAL_HEX32(0xDDDDDDDDU, g_atomic32);
|
||||
@ -69,13 +68,13 @@ TEST_CASE("stdatomic - test_16bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned int x16 = 0;
|
||||
g_atomic16 = 0;
|
||||
|
||||
x16 += atomic_fetch_or (&g_atomic16, 0x1111);
|
||||
x16 += atomic_fetch_or(&g_atomic16, 0x1111);
|
||||
x16 += atomic_fetch_xor(&g_atomic16, 0x3333);
|
||||
x16 += atomic_fetch_and(&g_atomic16, 0xf0f0);
|
||||
x16 += atomic_fetch_sub(&g_atomic16, 0x0f0f);
|
||||
x16 += atomic_fetch_add(&g_atomic16, 0x2222);
|
||||
#ifndef __clang__
|
||||
x16 += __atomic_fetch_nand_2 (&g_atomic16, 0xAAAA, 0);
|
||||
x16 += __atomic_fetch_nand_2(&g_atomic16, 0xAAAA, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX16(0x9797, x16);
|
||||
TEST_ASSERT_EQUAL_HEX16(0xDDDD, g_atomic16);
|
||||
@ -90,13 +89,13 @@ TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned int x8 = 0;
|
||||
g_atomic8 = 0;
|
||||
|
||||
x8 += atomic_fetch_or (&g_atomic8, 0x11);
|
||||
x8 += atomic_fetch_or(&g_atomic8, 0x11);
|
||||
x8 += atomic_fetch_xor(&g_atomic8, 0x33);
|
||||
x8 += atomic_fetch_and(&g_atomic8, 0xf0);
|
||||
x8 += atomic_fetch_sub(&g_atomic8, 0x0f);
|
||||
x8 += atomic_fetch_add(&g_atomic8, 0x22);
|
||||
#ifndef __clang__
|
||||
x8 += __atomic_fetch_nand_1 (&g_atomic8, 0xAA, 0);
|
||||
x8 += __atomic_fetch_nand_1(&g_atomic8, 0xAA, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX8(0x97, x8);
|
||||
TEST_ASSERT_EQUAL_HEX8(0xDD, g_atomic8);
|
||||
@ -112,7 +111,7 @@ TEST_CASE("stdatomic - test_64bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned long long x64 = 0;
|
||||
g_atomic64 = 0; // calls atomic_store
|
||||
|
||||
x64 += __atomic_or_fetch_8 (&g_atomic64, 0x1111111111111111ULL, 0);
|
||||
x64 += __atomic_or_fetch_8(&g_atomic64, 0x1111111111111111ULL, 0);
|
||||
x64 += __atomic_xor_fetch_8(&g_atomic64, 0x3333333333333333ULL, 0);
|
||||
x64 += __atomic_and_fetch_8(&g_atomic64, 0xf0f0f0f0f0f0f0f0ULL, 0);
|
||||
x64 += __atomic_sub_fetch_8(&g_atomic64, 0x0f0f0f0f0f0f0f0fULL, 0);
|
||||
@ -128,12 +127,12 @@ TEST_CASE("stdatomic - test_32bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned int x32 = 0;
|
||||
g_atomic32 = 0;
|
||||
|
||||
x32 += __atomic_or_fetch_4 (&g_atomic32, 0x11111111U, 0);
|
||||
x32 += __atomic_or_fetch_4(&g_atomic32, 0x11111111U, 0);
|
||||
x32 += __atomic_xor_fetch_4(&g_atomic32, 0x33333333U, 0);
|
||||
x32 += __atomic_and_fetch_4(&g_atomic32, 0xf0f0f0f0U, 0);
|
||||
x32 += __atomic_sub_fetch_4(&g_atomic32, 0x0f0f0f0fU, 0);
|
||||
x32 += __atomic_add_fetch_4(&g_atomic32, 0x22222222U, 0);
|
||||
x32 += __atomic_nand_fetch_4 (&g_atomic32, 0xAAAAAAAAU, 0);
|
||||
x32 += __atomic_nand_fetch_4(&g_atomic32, 0xAAAAAAAAU, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX32(0x75757574U, x32);
|
||||
TEST_ASSERT_EQUAL_HEX32(0xDDDDDDDDU, g_atomic32);
|
||||
@ -144,12 +143,12 @@ TEST_CASE("stdatomic - test_16bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned int x16 = 0;
|
||||
g_atomic16 = 0;
|
||||
|
||||
x16 += __atomic_or_fetch_2 (&g_atomic16, 0x1111, 0);
|
||||
x16 += __atomic_or_fetch_2(&g_atomic16, 0x1111, 0);
|
||||
x16 += __atomic_xor_fetch_2(&g_atomic16, 0x3333, 0);
|
||||
x16 += __atomic_and_fetch_2(&g_atomic16, 0xf0f0, 0);
|
||||
x16 += __atomic_sub_fetch_2(&g_atomic16, 0x0f0f, 0);
|
||||
x16 += __atomic_add_fetch_2(&g_atomic16, 0x2222, 0);
|
||||
x16 += __atomic_nand_fetch_2 (&g_atomic16, 0xAAAA, 0);
|
||||
x16 += __atomic_nand_fetch_2(&g_atomic16, 0xAAAA, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX16(0x7574, x16);
|
||||
TEST_ASSERT_EQUAL_HEX16(0xDDDD, g_atomic16);
|
||||
@ -160,12 +159,12 @@ TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
|
||||
unsigned int x8 = 0;
|
||||
g_atomic8 = 0;
|
||||
|
||||
x8 += __atomic_or_fetch_1 (&g_atomic8, 0x11, 0);
|
||||
x8 += __atomic_or_fetch_1(&g_atomic8, 0x11, 0);
|
||||
x8 += __atomic_xor_fetch_1(&g_atomic8, 0x33, 0);
|
||||
x8 += __atomic_and_fetch_1(&g_atomic8, 0xf0, 0);
|
||||
x8 += __atomic_sub_fetch_1(&g_atomic8, 0x0f, 0);
|
||||
x8 += __atomic_add_fetch_1(&g_atomic8, 0x22, 0);
|
||||
x8 += __atomic_nand_fetch_1 (&g_atomic8, 0xAA, 0);
|
||||
x8 += __atomic_nand_fetch_1(&g_atomic8, 0xAA, 0);
|
||||
|
||||
TEST_ASSERT_EQUAL_HEX8(0x74, x8);
|
||||
TEST_ASSERT_EQUAL_HEX8(0xDD, g_atomic8);
|
||||
@ -173,7 +172,6 @@ TEST_CASE("stdatomic - test_8bit_atomics", "[newlib_stdatomic]")
|
||||
|
||||
#endif // #ifndef __clang__
|
||||
|
||||
|
||||
#define TEST_EXCLUSION(n) TEST_CASE("stdatomic - test_" #n "bit_exclusion", "[newlib_stdatomic]") \
|
||||
{ \
|
||||
g_atomic ## n = 0; \
|
||||
@ -216,7 +214,6 @@ TEST_EXCLUSION(16)
|
||||
TEST_EXCLUSION_TASK(8)
|
||||
TEST_EXCLUSION(8)
|
||||
|
||||
|
||||
#define ITER_COUNT 20000
|
||||
|
||||
#define TEST_RACE_OPERATION(ASSERT_SUFFIX, NAME, LHSTYPE, PRE, POST, INIT, FINAL) \
|
||||
@ -283,75 +280,75 @@ TEST_CASE("stdatomic - test_" #NAME, "[newlib_stdatomic]") \
|
||||
TEST_ASSERT(EXPECTED == var_##NAME); \
|
||||
}
|
||||
|
||||
TEST_RACE_OPERATION ( ,uint8_add, uint8_t, , += 1, 0, (uint8_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_add_3, uint8_t, , += 3, 0, (uint8_t) (6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_postinc, uint8_t, , ++, 0, (uint8_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_preinc, uint8_t, ++, , 0, (uint8_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_sub, uint8_t, , -= 1, 0, (uint8_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_sub_3, uint8_t, , -= 3, 0, (uint8_t) -(6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_postdec, uint8_t, , --, 0, (uint8_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_predec, uint8_t, --, , 0, (uint8_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint8_mul, uint8_t, , *= 3, 1, (uint8_t) 0x1)
|
||||
TEST_RACE_OPERATION(, uint8_add, uint8_t,, += 1, 0, (uint8_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_add_3, uint8_t,, += 3, 0, (uint8_t)(6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_postinc, uint8_t,, ++, 0, (uint8_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_preinc, uint8_t, ++,, 0, (uint8_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_sub, uint8_t,, -= 1, 0, (uint8_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_sub_3, uint8_t,, -= 3, 0, (uint8_t) - (6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_postdec, uint8_t,, --, 0, (uint8_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_predec, uint8_t, --,, 0, (uint8_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint8_mul, uint8_t,, *= 3, 1, (uint8_t) 0x1)
|
||||
|
||||
TEST_RACE_OPERATION ( ,uint16_add, uint16_t, , += 1, 0, (uint16_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_add_3, uint16_t, , += 3, 0, (uint16_t) (6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_postinc, uint16_t, , ++, 0, (uint16_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_preinc, uint16_t, ++, , 0, (uint16_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_sub, uint16_t, , -= 1, 0, (uint16_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_sub_3, uint16_t, , -= 3, 0, (uint16_t) -(6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_postdec, uint16_t, , --, 0, (uint16_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_predec, uint16_t, --, , 0, (uint16_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint16_mul, uint16_t, , *= 3, 1, (uint16_t) 0x6D01)
|
||||
TEST_RACE_OPERATION(, uint16_add, uint16_t,, += 1, 0, (uint16_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_add_3, uint16_t,, += 3, 0, (uint16_t)(6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_postinc, uint16_t,, ++, 0, (uint16_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_preinc, uint16_t, ++,, 0, (uint16_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_sub, uint16_t,, -= 1, 0, (uint16_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_sub_3, uint16_t,, -= 3, 0, (uint16_t) - (6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_postdec, uint16_t,, --, 0, (uint16_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_predec, uint16_t, --,, 0, (uint16_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint16_mul, uint16_t,, *= 3, 1, (uint16_t) 0x6D01)
|
||||
|
||||
TEST_RACE_OPERATION ( ,uint32_add, uint32_t, , += 1, 0, (uint32_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_add_3, uint32_t, , += 3, 0, (uint32_t) (6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_postinc, uint32_t, , ++, 0, (uint32_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_preinc, uint32_t, ++, , 0, (uint32_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_sub, uint32_t, , -= 1, 0, (uint32_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_sub_3, uint32_t, , -= 3, 0, (uint32_t) -(6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_postdec, uint32_t, , --, 0, (uint32_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_predec, uint32_t, --, , 0, (uint32_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint32_mul, uint32_t, , *= 3, 1, (uint32_t) 0xC1E36D01U)
|
||||
TEST_RACE_OPERATION(, uint32_add, uint32_t,, += 1, 0, (uint32_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_add_3, uint32_t,, += 3, 0, (uint32_t)(6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_postinc, uint32_t,, ++, 0, (uint32_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_preinc, uint32_t, ++,, 0, (uint32_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_sub, uint32_t,, -= 1, 0, (uint32_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_sub_3, uint32_t,, -= 3, 0, (uint32_t) - (6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_postdec, uint32_t,, --, 0, (uint32_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_predec, uint32_t, --,, 0, (uint32_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint32_mul, uint32_t,, *= 3, 1, (uint32_t) 0xC1E36D01U)
|
||||
|
||||
TEST_RACE_OPERATION ( ,uint64_add, uint64_t, , += 1, 0, (uint64_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_add_3, uint64_t, , += 3, 0, (uint64_t) (6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_add_neg, uint64_t, , += 1, -10000, (uint64_t) (2*ITER_COUNT-10000))
|
||||
TEST_RACE_OPERATION ( ,uint64_postinc, uint64_t, , ++, 0, (uint64_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_postinc_neg, uint64_t, , ++, -10000, (uint64_t) (2*ITER_COUNT-10000))
|
||||
TEST_RACE_OPERATION ( ,uint64_preinc, uint64_t, ++, , 0, (uint64_t) (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_preinc_neg, uint64_t, ++, , -10000, (uint64_t) (2*ITER_COUNT-10000))
|
||||
TEST_RACE_OPERATION ( ,uint64_sub, uint64_t, , -= 1, 0, (uint64_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_sub_3, uint64_t, , -= 3, 0, (uint64_t) -(6*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_sub_neg, uint64_t, , -= 1, 10000, (uint64_t) ((-2*ITER_COUNT)+10000))
|
||||
TEST_RACE_OPERATION ( ,uint64_postdec, uint64_t, , --, 0, (uint64_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_postdec_neg, uint64_t, , --, 10000, (uint64_t) ((-2*ITER_COUNT)+10000))
|
||||
TEST_RACE_OPERATION ( ,uint64_predec, uint64_t, --, , 0, (uint64_t) -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION ( ,uint64_predec_neg, uint64_t, --, , 10000, (uint64_t) ((-2*ITER_COUNT)+10000))
|
||||
TEST_RACE_OPERATION ( ,uint64_mul, uint64_t, , *= 3, 1, (uint64_t) 0x988EE974C1E36D01ULL)
|
||||
TEST_RACE_OPERATION(, uint64_add, uint64_t,, += 1, 0, (uint64_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_add_3, uint64_t,, += 3, 0, (uint64_t)(6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_add_neg, uint64_t,, += 1, -10000, (uint64_t)(2 * ITER_COUNT - 10000))
|
||||
TEST_RACE_OPERATION(, uint64_postinc, uint64_t,, ++, 0, (uint64_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_postinc_neg, uint64_t,, ++, -10000, (uint64_t)(2 * ITER_COUNT - 10000))
|
||||
TEST_RACE_OPERATION(, uint64_preinc, uint64_t, ++,, 0, (uint64_t)(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_preinc_neg, uint64_t, ++,, -10000, (uint64_t)(2 * ITER_COUNT - 10000))
|
||||
TEST_RACE_OPERATION(, uint64_sub, uint64_t,, -= 1, 0, (uint64_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_sub_3, uint64_t,, -= 3, 0, (uint64_t) - (6 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_sub_neg, uint64_t,, -= 1, 10000, (uint64_t)((-2 * ITER_COUNT) + 10000))
|
||||
TEST_RACE_OPERATION(, uint64_postdec, uint64_t,, --, 0, (uint64_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_postdec_neg, uint64_t,, --, 10000, (uint64_t)((-2 * ITER_COUNT) + 10000))
|
||||
TEST_RACE_OPERATION(, uint64_predec, uint64_t, --,, 0, (uint64_t) - (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(, uint64_predec_neg, uint64_t, --,, 10000, (uint64_t)((-2 * ITER_COUNT) + 10000))
|
||||
TEST_RACE_OPERATION(, uint64_mul, uint64_t,, *= 3, 1, (uint64_t) 0x988EE974C1E36D01ULL)
|
||||
|
||||
TEST_RACE_OPERATION (_FLOAT ,float_add, float, , += 1, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,complex_float_add, _Complex float, , += 1, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,float_postinc, float, , ++, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,float_preinc, float, ++, , 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,float_sub, float, , -= 1, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,complex_float_sub, _Complex float, , -= 1, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,float_postdec, float, , --, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_FLOAT ,float_predec, float, --, , 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, float_add, float,, += 1, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, complex_float_add, _Complex float,, += 1, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, float_postinc, float,, ++, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, float_preinc, float, ++,, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, float_sub, float,, -= 1, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, complex_float_sub, _Complex float,, -= 1, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, float_postdec, float,, --, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_FLOAT, float_predec, float, --,, 0, -(2 * ITER_COUNT))
|
||||
|
||||
TEST_RACE_OPERATION (_DOUBLE ,double_add, double, , += 1, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,complex_double_add, _Complex double, , += 1, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,double_postinc, double, , ++, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,double_preinc, double, ++, , 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,double_sub, double, , -= 1, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,complex_double_sub, _Complex double, , -= 1, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,double_postdec, double, , --, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION (_DOUBLE ,double_predec, double, --, , 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, double_add, double,, += 1, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, complex_double_add, _Complex double,, += 1, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, double_postinc, double,, ++, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, double_preinc, double, ++,, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, double_sub, double,, -= 1, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, complex_double_sub, _Complex double,, -= 1, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, double_postdec, double,, --, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION(_DOUBLE, double_predec, double, --,, 0, -(2 * ITER_COUNT))
|
||||
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (long_double_add, long double, , += 1, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (complex_long_double_add, _Complex long double, , += 1, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (long_double_postinc, long double, , ++, 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (long_double_sub, long double, , -= 1, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (long_double_preinc, long double, ++, , 0, (2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (complex_long_double_sub, _Complex long double, , -= 1, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (long_double_postdec, long double, , --, 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE (long_double_predec, long double, --, , 0, -(2*ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(long_double_add, long double,, += 1, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(complex_long_double_add, _Complex long double,, += 1, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(long_double_postinc, long double,, ++, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(long_double_sub, long double,, -= 1, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(long_double_preinc, long double, ++,, 0, (2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(complex_long_double_sub, _Complex long double,, -= 1, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(long_double_postdec, long double,, --, 0, -(2 * ITER_COUNT))
|
||||
TEST_RACE_OPERATION_LONG_DOUBLE(long_double_predec, long double, --,, 0, -(2 * ITER_COUNT))
|
||||
|
@ -72,7 +72,6 @@ static void time_adc_test_task(void* arg)
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]")
|
||||
{
|
||||
SemaphoreHandle_t done = xSemaphoreCreateBinary();
|
||||
@ -82,7 +81,7 @@ TEST_CASE("Reading RTC registers on APP CPU doesn't affect clock", "[newlib]")
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
struct timeval tv_start;
|
||||
gettimeofday(&tv_start, NULL);
|
||||
vTaskDelay(1000/portTICK_PERIOD_MS);
|
||||
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
||||
struct timeval tv_stop;
|
||||
gettimeofday(&tv_stop, NULL);
|
||||
float time_sec = tv_stop.tv_sec - tv_start.tv_sec + 1e-6f * (tv_stop.tv_usec - tv_start.tv_usec);
|
||||
@ -190,7 +189,9 @@ static void adjtimeTask2(void *pvParameters)
|
||||
while (exit_flag == false) {
|
||||
delta.tv_sec += 1;
|
||||
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);
|
||||
}
|
||||
xSemaphoreGive(*sema);
|
||||
@ -242,7 +243,7 @@ TEST_CASE("test for no interlocking adjtime, gettimeofday and settimeofday funct
|
||||
// set exit flag to let thread exit
|
||||
exit_flag = true;
|
||||
for (int i = 0; i < max_tasks; ++i) {
|
||||
if (!xSemaphoreTake(exit_sema[i], 2000/portTICK_PERIOD_MS)) {
|
||||
if (!xSemaphoreTake(exit_sema[i], 2000 / portTICK_PERIOD_MS)) {
|
||||
TEST_FAIL_MESSAGE("exit_sema not released by test task");
|
||||
}
|
||||
vSemaphoreDelete(exit_sema[i]);
|
||||
@ -349,7 +350,7 @@ TEST_CASE("test time adjustment happens linearly", "[newlib][timeout=15]")
|
||||
exit_flag = true;
|
||||
|
||||
for (int i = 0; i < 2; ++i) {
|
||||
if (!xSemaphoreTake(exit_sema[i], 2100/portTICK_PERIOD_MS)) {
|
||||
if (!xSemaphoreTake(exit_sema[i], 2100 / portTICK_PERIOD_MS)) {
|
||||
TEST_FAIL_MESSAGE("exit_sema not released by test task");
|
||||
}
|
||||
}
|
||||
@ -360,7 +361,7 @@ TEST_CASE("test time adjustment happens linearly", "[newlib][timeout=15]")
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_posix_timers_clock (void)
|
||||
void test_posix_timers_clock(void)
|
||||
{
|
||||
#ifndef _POSIX_TIMERS
|
||||
TEST_ASSERT_MESSAGE(false, "_POSIX_TIMERS - is not defined");
|
||||
@ -475,7 +476,7 @@ static struct timeval get_time(const char *desc, char *buffer)
|
||||
TEST_CASE("test time_t wide 64 bits", "[newlib]")
|
||||
{
|
||||
static char buffer[32];
|
||||
ESP_LOGI("TAG", "sizeof(time_t): %d (%d-bit)", sizeof(time_t), sizeof(time_t)*8);
|
||||
ESP_LOGI("TAG", "sizeof(time_t): %d (%d-bit)", sizeof(time_t), sizeof(time_t) * 8);
|
||||
TEST_ASSERT_EQUAL(8, sizeof(time_t));
|
||||
|
||||
// mktime takes current timezone into account, this test assumes it's UTC+0
|
||||
@ -563,7 +564,6 @@ TEST_CASE("test time functions wide 64 bits", "[newlib]")
|
||||
extern int64_t s_microseconds_offset;
|
||||
static const uint64_t s_start_timestamp = 1606838354;
|
||||
|
||||
|
||||
static __NOINIT_ATTR uint64_t s_saved_time;
|
||||
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_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_timestamp3, check_time);
|
||||
|
@ -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
|
||||
*/
|
||||
@ -45,7 +45,7 @@ static _lock_t s_time_lock;
|
||||
// This function gradually changes boot_time to the correction value and immediately updates it.
|
||||
static uint64_t adjust_boot_time(void)
|
||||
{
|
||||
#define ADJTIME_CORRECTION_FACTOR 6
|
||||
#define ADJTIME_CORRECTION_FACTOR 6
|
||||
|
||||
uint64_t boot_time = esp_time_impl_get_boot_time();
|
||||
if ((boot_time == 0) || (esp_time_impl_get_time_since_boot() < s_adjtime_start_us)) {
|
||||
@ -83,7 +83,6 @@ static uint64_t adjust_boot_time(void)
|
||||
return boot_time;
|
||||
}
|
||||
|
||||
|
||||
// Get the adjusted boot time.
|
||||
static uint64_t get_adjusted_boot_time(void)
|
||||
{
|
||||
@ -94,10 +93,10 @@ static uint64_t get_adjusted_boot_time(void)
|
||||
}
|
||||
|
||||
// Applying the accumulated correction to base_time and stopping the smooth time adjustment.
|
||||
static void adjtime_corr_stop (void)
|
||||
static void adjtime_corr_stop(void)
|
||||
{
|
||||
_lock_acquire(&s_time_lock);
|
||||
if (s_adjtime_start_us != 0){
|
||||
if (s_adjtime_start_us != 0) {
|
||||
adjust_boot_time();
|
||||
s_adjtime_start_us = 0;
|
||||
}
|
||||
@ -108,7 +107,7 @@ static void adjtime_corr_stop (void)
|
||||
int adjtime(const struct timeval *delta, struct timeval *outdelta)
|
||||
{
|
||||
#if IMPL_NEWLIB_TIME_FUNCS
|
||||
if(outdelta != NULL){
|
||||
if (outdelta != NULL) {
|
||||
_lock_acquire(&s_time_lock);
|
||||
adjust_boot_time();
|
||||
if (s_adjtime_start_us != 0) {
|
||||
@ -120,10 +119,10 @@ int adjtime(const struct timeval *delta, struct timeval *outdelta)
|
||||
}
|
||||
_lock_release(&s_time_lock);
|
||||
}
|
||||
if(delta != NULL){
|
||||
if (delta != NULL) {
|
||||
int64_t sec = delta->tv_sec;
|
||||
int64_t usec = delta->tv_usec;
|
||||
if(llabs(sec) > ((INT_MAX / 1000000L) - 1L)) {
|
||||
if (llabs(sec) > ((INT_MAX / 1000000L) - 1L)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
@ -208,7 +207,7 @@ int usleep(useconds_t us)
|
||||
|
||||
unsigned int sleep(unsigned int seconds)
|
||||
{
|
||||
usleep(seconds*1000000UL);
|
||||
usleep(seconds * 1000000UL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -237,7 +236,7 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp)
|
||||
#endif
|
||||
}
|
||||
|
||||
int clock_gettime (clockid_t clock_id, struct timespec *tp)
|
||||
int clock_gettime(clockid_t clock_id, struct timespec *tp)
|
||||
{
|
||||
#if IMPL_NEWLIB_TIME_FUNCS
|
||||
if (tp == NULL) {
|
||||
@ -268,7 +267,7 @@ int clock_gettime (clockid_t clock_id, struct timespec *tp)
|
||||
#endif
|
||||
}
|
||||
|
||||
int clock_getres (clockid_t clock_id, struct timespec *res)
|
||||
int clock_getres(clockid_t clock_id, struct timespec *res)
|
||||
{
|
||||
#if IMPL_NEWLIB_TIME_FUNCS
|
||||
if (res == NULL) {
|
||||
|
@ -65,7 +65,6 @@ static SLIST_HEAD(esp_thread_list_head, esp_pthread_entry) s_threads_list
|
||||
= SLIST_HEAD_INITIALIZER(s_threads_list);
|
||||
static pthread_key_t s_pthread_cfg_key;
|
||||
|
||||
|
||||
static int pthread_mutex_lock_internal(esp_pthread_mutex_t *mux, TickType_t tmo);
|
||||
|
||||
static void esp_pthread_cfg_key_destructor(void *value)
|
||||
@ -248,7 +247,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
TaskHandle_t * const pxCreatedTask)
|
||||
{
|
||||
#if CONFIG_SPIRAM
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
#if CONFIG_FREERTOS_SMP
|
||||
return prvTaskCreateDynamicAffinitySetWithCaps(pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
@ -257,7 +256,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
coreID_to_AffinityMask(core_id),
|
||||
uxStackMemoryCaps,
|
||||
pxCreatedTask);
|
||||
#else
|
||||
#else
|
||||
return prvTaskCreateDynamicPinnedToCoreWithCaps(pxTaskCode,
|
||||
pcName,
|
||||
usStackDepth,
|
||||
@ -266,7 +265,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
core_id,
|
||||
uxStackMemoryCaps,
|
||||
pxCreatedTask);
|
||||
#endif
|
||||
#endif
|
||||
#else
|
||||
return xTaskCreatePinnedToCore(pxTaskCode,
|
||||
pcName,
|
||||
@ -279,7 +278,7 @@ static BaseType_t pthread_create_freertos_task_with_caps(TaskFunction_t pxTaskCo
|
||||
}
|
||||
|
||||
int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
void *(*start_routine) (void *), void *arg)
|
||||
void *(*start_routine)(void *), void *arg)
|
||||
{
|
||||
TaskHandle_t xHandle = NULL;
|
||||
|
||||
@ -549,7 +548,7 @@ int pthread_cancel(pthread_t thread)
|
||||
return ENOSYS;
|
||||
}
|
||||
|
||||
int sched_yield( void )
|
||||
int sched_yield(void)
|
||||
{
|
||||
vTaskDelay(0);
|
||||
return 0;
|
||||
@ -740,8 +739,8 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *timeo
|
||||
|
||||
struct timespec currtime;
|
||||
clock_gettime(CLOCK_REALTIME, &currtime);
|
||||
TickType_t tmo = ((timeout->tv_sec - currtime.tv_sec)*1000 +
|
||||
(timeout->tv_nsec - currtime.tv_nsec)/1000000)/portTICK_PERIOD_MS;
|
||||
TickType_t tmo = ((timeout->tv_sec - currtime.tv_sec) * 1000 +
|
||||
(timeout->tv_nsec - currtime.tv_nsec) / 1000000) / portTICK_PERIOD_MS;
|
||||
|
||||
res = pthread_mutex_lock_internal((esp_pthread_mutex_t *)*mutex, tmo);
|
||||
if (res == EBUSY) {
|
||||
|
@ -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
|
||||
*/
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
/* Sanity check to ensure that the number of FreeRTOS TLSPs is at least 1 */
|
||||
#if (CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS < 1)
|
||||
#error "CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS cannot be 0 for pthread TLS"
|
||||
#error "CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS cannot be 0 for pthread TLS"
|
||||
#endif
|
||||
|
||||
#define PTHREAD_TLS_INDEX 0
|
||||
@ -77,7 +77,7 @@ static key_entry_t *find_key(pthread_key_t key)
|
||||
portENTER_CRITICAL(&s_keys_lock);
|
||||
key_entry_t *result = NULL;;
|
||||
SLIST_FOREACH(result, &s_keys, next) {
|
||||
if(result->key == key) {
|
||||
if (result->key == key) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -171,7 +171,7 @@ static value_entry_t *find_value(const values_list_t *list, pthread_key_t key)
|
||||
{
|
||||
value_entry_t *result = NULL;;
|
||||
SLIST_FOREACH(result, list, next) {
|
||||
if(result->key == key) {
|
||||
if (result->key == key) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -186,7 +186,7 @@ void *pthread_getspecific(pthread_key_t key)
|
||||
}
|
||||
|
||||
value_entry_t *entry = find_value(tls, key);
|
||||
if(entry != NULL) {
|
||||
if (entry != NULL) {
|
||||
return entry->value;
|
||||
}
|
||||
return NULL;
|
||||
|
@ -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
|
||||
*/
|
||||
@ -23,7 +23,6 @@
|
||||
#include "esp_log.h"
|
||||
const static char *TAG = "pthread_rw_lock";
|
||||
|
||||
|
||||
/** pthread rw_mutex FreeRTOS wrapper */
|
||||
typedef struct {
|
||||
/**
|
||||
@ -46,7 +45,7 @@ typedef struct {
|
||||
#define WRITER_QUEUE_SIZE 4
|
||||
#define READER_QUEUE_SIZE 4
|
||||
|
||||
int pthread_rwlock_init (pthread_rwlock_t *rwlock,
|
||||
int pthread_rwlock_init(pthread_rwlock_t *rwlock,
|
||||
const pthread_rwlockattr_t *attr)
|
||||
{
|
||||
int result;
|
||||
@ -99,7 +98,7 @@ static int pthread_rwlock_init_if_static(pthread_rwlock_t *rwlock)
|
||||
return res;
|
||||
}
|
||||
|
||||
int pthread_rwlock_destroy (pthread_rwlock_t *rwlock)
|
||||
int pthread_rwlock_destroy(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
esp_pthread_rwlock_t *esp_rwlock;
|
||||
|
||||
@ -158,7 +157,7 @@ static int checkrw_lock(pthread_rwlock_t *rwlock)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
esp_pthread_rwlock_t *esp_rwlock;
|
||||
int res;
|
||||
@ -191,7 +190,7 @@ int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock)
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
esp_pthread_rwlock_t *esp_rwlock;
|
||||
int res;
|
||||
@ -247,7 +246,8 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) {
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
esp_pthread_rwlock_t *esp_rwlock;
|
||||
int res;
|
||||
|
||||
@ -276,7 +276,7 @@ int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock) {
|
||||
return res;
|
||||
}
|
||||
|
||||
int pthread_rwlock_unlock (pthread_rwlock_t *rwlock)
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t *rwlock)
|
||||
{
|
||||
esp_pthread_rwlock_t *esp_rwlock;
|
||||
int res;
|
||||
|
@ -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
|
||||
*/
|
||||
@ -24,7 +24,7 @@ int sem_destroy(sem_t * semaphore)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) *semaphore;
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) * semaphore;
|
||||
vSemaphoreDelete(freertos_semaphore);
|
||||
return 0;
|
||||
}
|
||||
@ -60,7 +60,7 @@ int sem_post(sem_t * semaphore)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) *semaphore;
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) * semaphore;
|
||||
BaseType_t ret = xSemaphoreGive(freertos_semaphore);
|
||||
|
||||
if (ret == pdFALSE) {
|
||||
@ -112,7 +112,7 @@ int sem_timedwait(sem_t * restrict semaphore, const struct timespec *restrict ab
|
||||
timeout_ticks += 1;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) *semaphore;
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) * semaphore;
|
||||
BaseType_t sem_take_result;
|
||||
sem_take_result = xSemaphoreTake(freertos_semaphore, timeout_ticks);
|
||||
if (sem_take_result == pdFALSE) {
|
||||
@ -130,7 +130,7 @@ int sem_trywait(sem_t * semaphore)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) *semaphore;
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) * semaphore;
|
||||
|
||||
BaseType_t ret = xSemaphoreTake(freertos_semaphore, 0);
|
||||
|
||||
@ -149,7 +149,7 @@ int sem_wait(sem_t * semaphore)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) *semaphore;
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) * semaphore;
|
||||
|
||||
// Only returns failure if block time expires, but we block indefinitely, hence not return code check
|
||||
xSemaphoreTake(freertos_semaphore, portMAX_DELAY);
|
||||
@ -168,7 +168,7 @@ int sem_getvalue(sem_t *restrict semaphore, int *restrict sval)
|
||||
return -1;
|
||||
}
|
||||
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) *semaphore;
|
||||
SemaphoreHandle_t freertos_semaphore = (SemaphoreHandle_t) * semaphore;
|
||||
*sval = uxSemaphoreGetCount(freertos_semaphore);
|
||||
return 0;
|
||||
}
|
||||
|
@ -11,7 +11,6 @@
|
||||
#include "unity_test_runner.h"
|
||||
#include "esp_heap_caps.h"
|
||||
|
||||
|
||||
// Some resources are lazy allocated (e.g. newlib locks), the threshold is left for that case
|
||||
#define TEST_MEMORY_LEAK_THRESHOLD (-200)
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
@ -24,10 +24,13 @@ static void waits(int idx, int timeout_ms)
|
||||
std::unique_lock<std::mutex> lk(cv_m);
|
||||
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';
|
||||
else
|
||||
else {
|
||||
std::cout << "Thread " << idx << " timed out. i == " << i << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
static void signals(int signal_ms)
|
||||
@ -53,7 +56,6 @@ TEST_CASE("C++ condition_variable", "[std::condition_variable]")
|
||||
std::cout << "All threads joined\n";
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("cxx: condition_variable can timeout", "[cxx]")
|
||||
{
|
||||
std::condition_variable cv;
|
||||
@ -76,7 +78,7 @@ TEST_CASE("cxx: condition_variable timeout never before deadline", "[cxx]")
|
||||
std::unique_lock<std::mutex> lock(mutex);
|
||||
|
||||
for (int i = 0; i < 25; ++i) {
|
||||
auto timeout = std::chrono::milliseconds(portTICK_PERIOD_MS * (i+1));
|
||||
auto timeout = std::chrono::milliseconds(portTICK_PERIOD_MS * (i + 1));
|
||||
auto deadline = SysClock::now() + timeout;
|
||||
|
||||
auto secs = std::chrono::time_point_cast<std::chrono::seconds>(deadline);
|
||||
@ -84,7 +86,8 @@ TEST_CASE("cxx: condition_variable timeout never before deadline", "[cxx]")
|
||||
(deadline - secs);
|
||||
struct timespec ts = {
|
||||
.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(),
|
||||
lock.mutex()->native_handle(), &ts);
|
||||
auto status = (rc == ETIMEDOUT) ? std::cv_status::timeout :
|
||||
|
@ -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
|
||||
*/
|
||||
@ -12,17 +12,17 @@
|
||||
TEST_CASE("C++ future", "[std::future]")
|
||||
{
|
||||
// future from a packaged_task
|
||||
std::packaged_task<int()> task([]{ return 7; }); // wrap the function
|
||||
std::packaged_task<int()> task([] { return 7; }); // wrap the function
|
||||
std::future<int> f1 = task.get_future(); // get a future
|
||||
std::thread t(std::move(task)); // launch on a thread
|
||||
|
||||
// future from an async()
|
||||
std::future<int> f2 = std::async(std::launch::async, []{ return 8; });
|
||||
std::future<int> f2 = std::async(std::launch::async, [] { return 8; });
|
||||
|
||||
// future from a promise
|
||||
std::promise<int> p;
|
||||
std::future<int> f3 = p.get_future();
|
||||
std::thread( [&p]{ p.set_value_at_thread_exit(9); }).detach();
|
||||
std::thread([&p] { p.set_value_at_thread_exit(9); }).detach();
|
||||
|
||||
std::cout << "Waiting..." << std::flush;
|
||||
f1.wait();
|
||||
|
@ -232,7 +232,7 @@ static void test_mutex_lock_unlock(int mutex_type)
|
||||
|
||||
res = pthread_mutex_lock(&mutex);
|
||||
|
||||
if(mutex_type == PTHREAD_MUTEX_ERRORCHECK) {
|
||||
if (mutex_type == PTHREAD_MUTEX_ERRORCHECK) {
|
||||
TEST_ASSERT_EQUAL_INT(EDEADLK, res);
|
||||
} else {
|
||||
TEST_ASSERT_EQUAL_INT(0, res);
|
||||
|
@ -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
|
||||
*/
|
||||
@ -114,7 +114,7 @@ TEST_CASE("pthread local storage destructor in FreeRTOS task", "[thread-specific
|
||||
TEST_ASSERT_EQUAL(0, pthread_key_create(&key, test_pthread_destructor));
|
||||
|
||||
xTaskCreate(task_test_pthread_destructor,
|
||||
"ptdest", 8192, (void *)key, UNITY_FREERTOS_PRIORITY+1,
|
||||
"ptdest", 8192, (void *)key, UNITY_FREERTOS_PRIORITY + 1,
|
||||
NULL);
|
||||
|
||||
// Above task has higher priority to us, so should run immediately
|
||||
@ -146,14 +146,13 @@ static void *thread_stress_test(void *v_key)
|
||||
|
||||
pthread_setspecific(key, tls_value);
|
||||
|
||||
for(int i = 0; i < STRESS_NUMITER; i++) {
|
||||
for (int i = 0; i < STRESS_NUMITER; i++) {
|
||||
TEST_ASSERT_EQUAL_HEX32(pthread_getspecific(key), tls_value);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// This test case added to reproduce issues with unpinned tasks and TLS
|
||||
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_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
|
||||
} destr_test_state_t;
|
||||
|
||||
|
||||
static void s_test_repeat_destructor(void *vp_state);
|
||||
static void *s_test_repeat_destructor_thread(void *vp_state);
|
||||
|
||||
@ -202,7 +199,7 @@ TEST_CASE("pthread local storage 'repeat' destructor test", "[thread-specific]")
|
||||
TEST_ASSERT_EQUAL(0, r);
|
||||
|
||||
r = pthread_join(thread, NULL);
|
||||
TEST_ASSERT_EQUAL(0 ,r);
|
||||
TEST_ASSERT_EQUAL(0, r);
|
||||
|
||||
// Cheating here to make sure compiler reads the value of 'count' from memory not from a register
|
||||
//
|
||||
|
@ -80,7 +80,6 @@ components_not_formatted_temporary:
|
||||
- "/components/lwip/"
|
||||
- "/components/mbedtls/"
|
||||
- "/components/mqtt/"
|
||||
- "/components/newlib/"
|
||||
- "/components/nvs_flash/"
|
||||
- "/components/nvs_sec_provider/"
|
||||
- "/components/openthread/"
|
||||
@ -88,7 +87,6 @@ components_not_formatted_temporary:
|
||||
- "/components/perfmon/"
|
||||
- "/components/protobuf-c/"
|
||||
- "/components/protocomm/"
|
||||
- "/components/pthread/"
|
||||
- "/components/riscv/"
|
||||
- "/components/sdmmc/"
|
||||
- "/components/soc/"
|
||||
|
Loading…
Reference in New Issue
Block a user