struct_mutex.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* x86 internal mutex struct definitions.
  2. Copyright (C) 2019-2026 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 _THREAD_MUTEX_INTERNAL_H
  16. #define _THREAD_MUTEX_INTERNAL_H 1
  17. struct __pthread_mutex_s
  18. {
  19. int __lock;
  20. unsigned int __count;
  21. int __owner;
  22. #ifdef __x86_64__
  23. unsigned int __nusers;
  24. #endif
  25. /* KIND must stay at this position in the structure to maintain
  26. binary compatibility with static initializers. */
  27. int __kind;
  28. #ifdef __x86_64__
  29. short __spins;
  30. short __unused;
  31. __pthread_list_t __list;
  32. # define __PTHREAD_MUTEX_HAVE_PREV 1
  33. #else
  34. unsigned int __nusers;
  35. __extension__ union
  36. {
  37. struct
  38. {
  39. short __data_spins;
  40. short __data_unused;
  41. # define __spins __data.__data_spins
  42. } __data;
  43. __pthread_slist_t __list;
  44. };
  45. # define __PTHREAD_MUTEX_HAVE_PREV 0
  46. #endif
  47. };
  48. #ifdef __x86_64__
  49. # define __PTHREAD_MUTEX_INITIALIZER(__kind) \
  50. 0, 0, 0, 0, __kind, 0, 0, { NULL, NULL }
  51. #else
  52. # define __PTHREAD_MUTEX_INITIALIZER(__kind) \
  53. 0, 0, 0, __kind, 0, { { 0, 0 } }
  54. #endif
  55. #endif