2022-06-17 10:59:56 -04:00
|
|
|
/*
|
2023-11-03 03:55:44 -04:00
|
|
|
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
2022-06-17 10:59:56 -04:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-06-10 14:03:32 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include_next <sys/lock.h>
|
2023-11-03 03:55:44 -04:00
|
|
|
#include "sdkconfig.h"
|
2020-06-10 14:03:32 -04:00
|
|
|
|
|
|
|
#ifdef _RETARGETABLE_LOCKING
|
|
|
|
|
|
|
|
/* Actual platfrom-specific definition of struct __lock.
|
|
|
|
* The size here should be sufficient for a FreeRTOS mutex.
|
|
|
|
* This is checked by a static assertion in locks.c
|
|
|
|
*
|
2023-11-03 03:55:44 -04:00
|
|
|
* Note: this might need to be made dependent on whether FreeRTOS
|
2020-06-10 14:03:32 -04:00
|
|
|
* is included in the build.
|
|
|
|
*/
|
|
|
|
struct __lock {
|
2023-11-03 03:55:44 -04:00
|
|
|
#if (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
|
|
|
int reserved[29];
|
|
|
|
#elif (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && !CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
|
|
|
int reserved[27];
|
|
|
|
#elif (!CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY)
|
2020-06-10 14:03:32 -04:00
|
|
|
int reserved[23];
|
2023-11-03 03:55:44 -04:00
|
|
|
#else
|
|
|
|
int reserved[21];
|
|
|
|
#endif /* #if (CONFIG_FREERTOS_USE_LIST_DATA_INTEGRITY_CHECK_BYTES && CONFIG_FREERTOS_USE_TRACE_FACILITY) */
|
2020-06-10 14:03:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Compatibility definitions for the legacy ESP-specific locking implementation.
|
|
|
|
* These used to be provided by libc/sys/xtensa/sys/lock.h in newlib.
|
|
|
|
* Newer versions of newlib don't have this ESP-specific lock.h header, and are
|
|
|
|
* built with _RETARGETABLE_LOCKING enabled, instead.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef _LOCK_T _lock_t;
|
|
|
|
|
|
|
|
void _lock_init(_lock_t *plock);
|
|
|
|
void _lock_init_recursive(_lock_t *plock);
|
|
|
|
void _lock_close(_lock_t *plock);
|
|
|
|
void _lock_close_recursive(_lock_t *plock);
|
|
|
|
void _lock_acquire(_lock_t *plock);
|
|
|
|
void _lock_acquire_recursive(_lock_t *plock);
|
|
|
|
int _lock_try_acquire(_lock_t *plock);
|
|
|
|
int _lock_try_acquire_recursive(_lock_t *plock);
|
|
|
|
void _lock_release(_lock_t *plock);
|
|
|
|
void _lock_release_recursive(_lock_t *plock);
|
|
|
|
|
|
|
|
#endif // _RETARGETABLE_LOCKING
|