Update.
[glibc.git] / linuxthreads / sysdeps / pthread / bits / pthreadtypes.h
blob04dbe35ff76ea6f9e165b07745f8973f776dbd7e
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. */
15 #if !defined _BITS_TYPES_H && !defined _PTHREAD_H
16 # error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
17 #endif
19 #ifndef _BITS_PTHREADTYPES_H
20 #define _BITS_PTHREADTYPES_H 1
22 #define __need_schedparam
23 #include <bits/sched.h>
25 /* Fast locks (not abstract because mutexes and conditions aren't abstract). */
26 struct _pthread_fastlock
28 long int __status; /* "Free" or "taken" or head of waiting list */
29 int __spinlock; /* For compare-and-swap emulation */
32 /* Thread descriptors */
33 typedef struct _pthread_descr_struct *_pthread_descr;
36 /* Attributes for threads. */
37 typedef struct
39 int __detachstate;
40 int __schedpolicy;
41 struct __sched_param __schedparam;
42 int __inheritsched;
43 int __scope;
44 size_t __guardsize;
45 int __stackaddr_set;
46 void *__stackaddr;
47 size_t __stacksize;
48 } pthread_attr_t;
51 /* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
52 typedef struct
54 struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
55 _pthread_descr __c_waiting; /* Threads waiting on this condition */
56 } pthread_cond_t;
59 /* Attribute for conditionally variables. */
60 typedef struct
62 int __dummy;
63 } pthread_condattr_t;
65 /* Keys for thread-specific data */
66 typedef unsigned int pthread_key_t;
69 /* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */
70 /* (The layout is unnatural to maintain binary compatibility
71 with earlier releases of LinuxThreads.) */
72 typedef struct
74 int __m_reserved; /* Reserved for future use */
75 int __m_count; /* Depth of recursive locking */
76 _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */
77 int __m_kind; /* Mutex kind: fast, recursive or errcheck */
78 struct _pthread_fastlock __m_lock; /* Underlying fast lock */
79 } pthread_mutex_t;
82 /* Attribute for mutex. */
83 typedef struct
85 int __mutexkind;
86 } pthread_mutexattr_t;
89 /* Once-only execution */
90 typedef int pthread_once_t;
93 #ifdef __USE_UNIX98
94 /* Read-write locks. */
95 typedef struct
97 struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
98 int __rw_readers; /* Number of readers */
99 _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */
100 _pthread_descr __rw_read_waiting; /* Threads waiting for reading */
101 _pthread_descr __rw_write_waiting; /* Threads waiting for writing */
102 int __rw_kind; /* Reader/Writer preference selection */
103 int __rw_pshared; /* Shared between processes or not */
104 } pthread_rwlock_t;
107 /* Attribute for read-write locks. */
108 typedef struct
110 int __lockkind;
111 int __pshared;
112 } pthread_rwlockattr_t;
113 #endif
116 /* Thread identifiers */
117 typedef unsigned long int pthread_t;
119 #endif /* bits/pthreadtypes.h */