1 /* 2 * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 #pragma once 7 8 #include_next <sys/lock.h> 9 10 #ifdef _RETARGETABLE_LOCKING 11 12 /* Actual platfrom-specific definition of struct __lock. 13 * The size here should be sufficient for a FreeRTOS mutex. 14 * This is checked by a static assertion in locks.c 15 * 16 * Note 1: this might need to be made dependent on whether FreeRTOS 17 * is included in the build. 18 * 19 * Note 2: the size is made sufficient for the case when 20 * configUSE_TRACE_FACILITY is enabled. If it is disabled, 21 * this definition wastes 8 bytes. 22 */ 23 struct __lock { 24 int reserved[23]; 25 }; 26 27 /* Compatibility definitions for the legacy ESP-specific locking implementation. 28 * These used to be provided by libc/sys/xtensa/sys/lock.h in newlib. 29 * Newer versions of newlib don't have this ESP-specific lock.h header, and are 30 * built with _RETARGETABLE_LOCKING enabled, instead. 31 */ 32 33 typedef _LOCK_T _lock_t; 34 35 void _lock_init(_lock_t *plock); 36 void _lock_init_recursive(_lock_t *plock); 37 void _lock_close(_lock_t *plock); 38 void _lock_close_recursive(_lock_t *plock); 39 void _lock_acquire(_lock_t *plock); 40 void _lock_acquire_recursive(_lock_t *plock); 41 int _lock_try_acquire(_lock_t *plock); 42 int _lock_try_acquire_recursive(_lock_t *plock); 43 void _lock_release(_lock_t *plock); 44 void _lock_release_recursive(_lock_t *plock); 45 46 #endif // _RETARGETABLE_LOCKING 47