pthreadtypes.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Linuxthreads - a simple clone()-based implementation of Posix */
  2. /* threads for Linux. */
  3. /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
  4. /* */
  5. /* This program is free software; you can redistribute it and/or */
  6. /* modify it under the terms of the GNU Library General Public License */
  7. /* as published by the Free Software Foundation; either version 2 */
  8. /* of the License, or (at your option) any later version. */
  9. /* */
  10. /* This program is distributed in the hope that it will be useful, */
  11. /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
  12. /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
  13. /* GNU Library General Public License for more details. */
  14. #if !defined _BITS_TYPES_H && !defined _PTHREAD_H
  15. # error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
  16. #endif
  17. #ifndef _BITS_PTHREADTYPES_H
  18. #define _BITS_PTHREADTYPES_H 1
  19. #define __need_schedparam
  20. #include <bits/sched.h>
  21. /* Fast locks (not abstract because mutexes and conditions aren't abstract). */
  22. struct _pthread_fastlock
  23. {
  24. long int __status; /* "Free" or "taken" or head of waiting list */
  25. int __spinlock; /* For compare-and-swap emulation */
  26. };
  27. #ifndef _PTHREAD_DESCR_DEFINED
  28. /* Thread descriptors */
  29. typedef struct _pthread_descr_struct *_pthread_descr;
  30. # define _PTHREAD_DESCR_DEFINED
  31. #endif
  32. /* Attributes for threads. */
  33. typedef struct
  34. {
  35. int __detachstate;
  36. int __schedpolicy;
  37. struct __sched_param __schedparam;
  38. int __inheritsched;
  39. int __scope;
  40. size_t __guardsize;
  41. int __stackaddr_set;
  42. void *__stackaddr;
  43. size_t __stacksize;
  44. } pthread_attr_t;
  45. /* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
  46. typedef struct
  47. {
  48. struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
  49. _pthread_descr __c_waiting; /* Threads waiting on this condition */
  50. } pthread_cond_t;
  51. /* Attribute for conditionally variables. */
  52. typedef struct
  53. {
  54. int __dummy;
  55. } pthread_condattr_t;
  56. /* Keys for thread-specific data */
  57. typedef unsigned int pthread_key_t;
  58. /* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */
  59. /* (The layout is unnatural to maintain binary compatibility
  60. with earlier releases of LinuxThreads.) */
  61. typedef struct
  62. {
  63. int __m_reserved; /* Reserved for future use */
  64. int __m_count; /* Depth of recursive locking */
  65. _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */
  66. int __m_kind; /* Mutex kind: fast, recursive or errcheck */
  67. struct _pthread_fastlock __m_lock; /* Underlying fast lock */
  68. } pthread_mutex_t;
  69. /* Attribute for mutex. */
  70. typedef struct
  71. {
  72. int __mutexkind;
  73. } pthread_mutexattr_t;
  74. /* Once-only execution */
  75. typedef int pthread_once_t;
  76. #ifdef __USE_UNIX98
  77. /* Read-write locks. */
  78. typedef struct _pthread_rwlock_t
  79. {
  80. struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
  81. int __rw_readers; /* Number of readers */
  82. _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */
  83. _pthread_descr __rw_read_waiting; /* Threads waiting for reading */
  84. _pthread_descr __rw_write_waiting; /* Threads waiting for writing */
  85. int __rw_kind; /* Reader/Writer preference selection */
  86. int __rw_pshared; /* Shared between processes or not */
  87. } pthread_rwlock_t;
  88. /* Attribute for read-write locks. */
  89. typedef struct
  90. {
  91. int __lockkind;
  92. int __pshared;
  93. } pthread_rwlockattr_t;
  94. #endif
  95. /* Thread identifiers */
  96. typedef unsigned long int pthread_t;
  97. #endif /* bits/pthreadtypes.h */