lock.h 1.4 KB

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