lock.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef _XTENSA_LOCK_H__
  2. #define _XTENSA_LOCK_H__
  3. /* generic lock implementation.
  4. Weak linked stub _lock functions in lock.c, can be
  5. replaced with a lock implementation at link time.
  6. */
  7. typedef int _lock_t;
  8. typedef _lock_t _LOCK_RECURSIVE_T;
  9. typedef _lock_t _LOCK_T;
  10. #include <_ansi.h>
  11. /* NOTE: some parts of newlib statically initialise locks via
  12. __LOCK_INIT, some initialise at runtime via __lock_init. So need to
  13. support possibility that a _lock_t is null during first call to
  14. _lock_acquire or _lock_try_acquire.
  15. Lock functions all take a pointer to the _lock_t entry, so the
  16. value stored there can be manipulated.
  17. */
  18. #define __LOCK_INIT(CLASS,NAME) CLASS _lock_t NAME = 0;
  19. #define __LOCK_INIT_RECURSIVE(CLASS,NAME) CLASS _lock_t NAME = 0;
  20. void _lock_init(_lock_t *lock);
  21. void _lock_init_recursive(_lock_t *lock);
  22. void _lock_close(_lock_t *lock);
  23. void _lock_close_recursive(_lock_t *lock);
  24. void _lock_acquire(_lock_t *lock);
  25. void _lock_acquire_recursive(_lock_t *lock);
  26. int _lock_try_acquire(_lock_t *lock);
  27. int _lock_try_acquire_recursive(_lock_t *lock);
  28. void _lock_release(_lock_t *lock);
  29. void _lock_release_recursive(_lock_t *lock);
  30. #define __lock_init(lock) _lock_init(&(lock))
  31. #define __lock_init_recursive(lock) _lock_init_recursive(&(lock))
  32. #define __lock_close(lock) _lock_close(&(lock))
  33. #define __lock_close_recursive(lock) _lock_close_recursive(&(lock))
  34. #define __lock_acquire(lock) _lock_acquire(&(lock))
  35. #define __lock_acquire_recursive(lock) _lock_acquire_recursive(&(lock))
  36. #define __lock_try_acquire(lock) _lock_try_acquire(&(lock))
  37. #define __lock_try_acquire_recursive(lock) _lock_try_acquire_recursive(&(lock))
  38. #define __lock_release(lock) _lock_release(&(lock))
  39. #define __lock_release_recursive(lock) _lock_release_recursive(&(lock))
  40. #endif /* _XTENSA_LOCK_H__ */