lock.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef __SYS_LOCK_H__
  2. #define __SYS_LOCK_H__
  3. /* dummy lock routines for single-threaded aps */
  4. #include <newlib.h>
  5. #include <_ansi.h>
  6. #if !defined(_RETARGETABLE_LOCKING)
  7. typedef int _LOCK_T;
  8. typedef int _LOCK_RECURSIVE_T;
  9. #define __LOCK_INIT(class,lock) static int lock = 0;
  10. #define __LOCK_INIT_RECURSIVE(class,lock) static int lock = 0;
  11. #define __lock_init(lock) ((void) 0)
  12. #define __lock_init_recursive(lock) ((void) 0)
  13. #define __lock_close(lock) ((void) 0)
  14. #define __lock_close_recursive(lock) ((void) 0)
  15. #define __lock_acquire(lock) ((void) 0)
  16. #define __lock_acquire_recursive(lock) ((void) 0)
  17. #define __lock_try_acquire(lock) ((void) 0)
  18. #define __lock_try_acquire_recursive(lock) ((void) 0)
  19. #define __lock_release(lock) ((void) 0)
  20. #define __lock_release_recursive(lock) ((void) 0)
  21. #else
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. struct __lock;
  26. typedef struct __lock * _LOCK_T;
  27. #define _LOCK_RECURSIVE_T _LOCK_T
  28. #define __LOCK_INIT(class,lock) extern struct __lock __lock_ ## lock; \
  29. class _LOCK_T lock = &__lock_ ## lock
  30. #define __LOCK_INIT_RECURSIVE(class,lock) __LOCK_INIT(class,lock)
  31. extern void __retarget_lock_init(_LOCK_T *lock);
  32. #define __lock_init(lock) __retarget_lock_init(&lock)
  33. extern void __retarget_lock_init_recursive(_LOCK_T *lock);
  34. #define __lock_init_recursive(lock) __retarget_lock_init_recursive(&lock)
  35. extern void __retarget_lock_close(_LOCK_T lock);
  36. #define __lock_close(lock) __retarget_lock_close(lock)
  37. extern void __retarget_lock_close_recursive(_LOCK_T lock);
  38. #define __lock_close_recursive(lock) __retarget_lock_close_recursive(lock)
  39. extern void __retarget_lock_acquire(_LOCK_T lock);
  40. #define __lock_acquire(lock) __retarget_lock_acquire(lock)
  41. extern void __retarget_lock_acquire_recursive(_LOCK_T lock);
  42. #define __lock_acquire_recursive(lock) __retarget_lock_acquire_recursive(lock)
  43. extern int __retarget_lock_try_acquire(_LOCK_T lock);
  44. #define __lock_try_acquire(lock) __retarget_lock_try_acquire(lock)
  45. extern int __retarget_lock_try_acquire_recursive(_LOCK_T lock);
  46. #define __lock_try_acquire_recursive(lock) \
  47. __retarget_lock_try_acquire_recursive(lock)
  48. extern void __retarget_lock_release(_LOCK_T lock);
  49. #define __lock_release(lock) __retarget_lock_release(lock)
  50. extern void __retarget_lock_release_recursive(_LOCK_T lock);
  51. #define __lock_release_recursive(lock) __retarget_lock_release_recursive(lock)
  52. #ifdef __cplusplus
  53. }
  54. #endif
  55. #endif /* !defined(_RETARGETABLE_LOCKING) */
  56. #endif /* __SYS_LOCK_H__ */