libc-lock.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /* libc-internal interface for mutex locks. Stub version.
  2. Copyright (C) 1996-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #ifndef _LIBC_LOCK_H
  16. #define _LIBC_LOCK_H 1
  17. /* Define a lock variable NAME with storage class CLASS. The lock must be
  18. initialized with __libc_lock_init before it can be used (or define it
  19. with __libc_lock_define_initialized, below). Use `extern' for CLASS to
  20. declare a lock defined in another module. In public structure
  21. definitions you must use a pointer to the lock structure (i.e., NAME
  22. begins with a `*'), because its storage size will not be known outside
  23. of libc. */
  24. #define __libc_lock_define(CLASS,NAME)
  25. #define __libc_lock_define_recursive(CLASS,NAME)
  26. #define __rtld_lock_define_recursive(CLASS,NAME)
  27. #define __libc_rwlock_define(CLASS,NAME)
  28. /* Define an initialized lock variable NAME with storage class CLASS. */
  29. #define __libc_lock_define_initialized(CLASS,NAME)
  30. #define __libc_rwlock_define_initialized(CLASS,NAME)
  31. /* Define an initialized recursive lock variable NAME with storage
  32. class CLASS. */
  33. #define __libc_lock_define_initialized_recursive(CLASS,NAME)
  34. #define __rtld_lock_define_initialized_recursive(CLASS,NAME)
  35. /* Initialize the named lock variable, leaving it in a consistent, unlocked
  36. state. */
  37. #define __libc_lock_init(NAME)
  38. #define __rtld_lock_initialize(NAME)
  39. #define __libc_rwlock_init(NAME)
  40. /* Same as last but this time we initialize a recursive mutex. */
  41. #define __libc_lock_init_recursive(NAME)
  42. /* Finalize the named lock variable, which must be locked. It cannot be
  43. used again until __libc_lock_init is called again on it. This must be
  44. called on a lock variable before the containing storage is reused. */
  45. #define __libc_lock_fini(NAME)
  46. #define __libc_rwlock_fini(NAME)
  47. /* Finalize recursive named lock. */
  48. #define __libc_lock_fini_recursive(NAME)
  49. /* Lock the named lock variable. */
  50. #define __libc_lock_lock(NAME)
  51. #define __libc_rwlock_rdlock(NAME)
  52. #define __libc_rwlock_wrlock(NAME)
  53. /* Lock the recursive named lock variable. */
  54. #define __libc_lock_lock_recursive(NAME)
  55. #define __rtld_lock_lock_recursive(NAME)
  56. /* Try to lock the named lock variable. */
  57. #define __libc_lock_trylock(NAME) 0
  58. #define __libc_rwlock_tryrdlock(NAME) 0
  59. #define __libc_rwlock_trywrlock(NAME) 0
  60. /* Try to lock the recursive named lock variable. */
  61. #define __libc_lock_trylock_recursive(NAME) 0
  62. /* Unlock the named lock variable. */
  63. #define __libc_lock_unlock(NAME)
  64. #define __libc_rwlock_unlock(NAME)
  65. /* Unlock the recursive named lock variable. */
  66. #define __libc_lock_unlock_recursive(NAME)
  67. #define __rtld_lock_unlock_recursive(NAME)
  68. /* Define once control variable. */
  69. #define __libc_once_define(CLASS, NAME) CLASS int NAME = 0
  70. /* Call handler iff the first call. */
  71. #define __libc_once(ONCE_CONTROL, INIT_FUNCTION) \
  72. do { \
  73. if ((ONCE_CONTROL) == 0) { \
  74. INIT_FUNCTION (); \
  75. (ONCE_CONTROL) = 1; \
  76. } \
  77. } while (0)
  78. /* Get once control variable. */
  79. #define __libc_once_get(ONCE_CONTROL) \
  80. ((ONCE_CONTROL) == 1)
  81. /* Start a critical region with a cleanup function */
  82. #define __libc_cleanup_region_start(DOIT, FCT, ARG) \
  83. { \
  84. typeof (***(FCT)) *__save_FCT = (DOIT) ? (FCT) : 0; \
  85. typeof (ARG) __save_ARG = ARG; \
  86. /* close brace is in __libc_cleanup_region_end below. */
  87. /* End a critical region started with __libc_cleanup_region_start. */
  88. #define __libc_cleanup_region_end(DOIT) \
  89. if ((DOIT) && __save_FCT != 0) \
  90. (*__save_FCT)(__save_ARG); \
  91. }
  92. /* Sometimes we have to exit the block in the middle. */
  93. #define __libc_cleanup_end(DOIT) \
  94. if ((DOIT) && __save_FCT != 0) \
  95. (*__save_FCT)(__save_ARG); \
  96. #define __libc_cleanup_push(fct, arg) __libc_cleanup_region_start (1, fct, arg)
  97. #define __libc_cleanup_pop(execute) __libc_cleanup_region_end (execute)
  98. /* We need portable names for some of the functions. */
  99. #define __libc_mutex_unlock
  100. /* Type for key of thread specific data. */
  101. typedef int __libc_key_t;
  102. /* Create key for thread specific data. */
  103. #define __libc_key_create(KEY,DEST) ((void) (KEY), (void) (DEST), -1)
  104. /* Set thread-specific data associated with KEY to VAL. */
  105. #define __libc_setspecific(KEY,VAL) ((void) (KEY), (void) (VAL))
  106. /* Get thread-specific data associated with KEY. */
  107. #define __libc_getspecific(KEY) ((void) (KEY), (void *) 0)
  108. #endif /* libc-lock.h */