1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/esp32: update sys/lock.h for retargetable locking

ESP-IDF version 4.4 already provide all locking definitions if retargetable locking is enabled.
This commit is contained in:
Gunar Schorcht 2022-02-01 21:15:43 +01:00
parent bf0b1716fc
commit 357eaa434a

View File

@ -24,34 +24,18 @@
#ifndef DOXYGEN
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
#include_next <sys/lock.h>
#if !defined(_RETARGETABLE_LOCKING)
#if defined(_RETARGETABLE_LOCKING)
typedef void * _lock_t;
/*
* The structured lock type has to be large enough to hold a recursive mutex.
* Since `rmutex.h` cannot be included in this stage of header inclusion,
* `sizeof` cannot be used here and an array of sufficient size has to be
* defined. This is ensured by a `static_assert` in `cpu/esp_common/syscalls.c`.
*/
typedef struct __lock {
void *reserved[2];
} __lock_t;
#endif /* defined(_RETARGETABLE_LOCKING) */
/*
* Declarations for source code compatibility. These functions were used
* in earlier newlib versions. In newer newlib versions, either the
* __lock_* or __retarget_* functions are used. They are still used in
* ESP-IDF.
*/
typedef _LOCK_T _lock_t;
#define _LOCK_T _lock_t
#define _LOCK_RECURSIVE_T _lock_t
void _lock_init(_lock_t *lock);
void _lock_init_recursive(_lock_t *lock);
@ -64,6 +48,12 @@ int _lock_try_acquire_recursive(_lock_t *lock);
void _lock_release(_lock_t *lock);
void _lock_release_recursive(_lock_t *lock);
#else /* !defined(_RETARGETABLE_LOCKING) */
#include_next <sys/lock.h>
#endif /* !defined(_RETARGETABLE_LOCKING) */
#ifdef __cplusplus
}
#endif