]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/linuxthreads/sysdeps/pthread/bits/pthreadtypes.h
update
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / linuxthreads / sysdeps / pthread / bits / pthreadtypes.h
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
15 #if !defined _BITS_TYPES_H && !defined _PTHREAD_H
16 # error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
17 #endif
18
19 #ifndef _BITS_PTHREADTYPES_H
20 #define _BITS_PTHREADTYPES_H    1
21
22 #define __need_size_t
23 #include <stddef.h>
24
25 #define __need_schedparam
26 #include <bits/sched.h>
27
28 /* Fast locks (not abstract because mutexes and conditions aren't abstract). */
29 struct _pthread_fastlock
30 {
31   long int __status;   /* "Free" or "taken" or head of waiting list */
32   int __spinlock;      /* Used by compare_and_swap emulation. Also,
33                           adaptive SMP lock stores spin count here. */
34 };
35
36 #ifndef _PTHREAD_DESCR_DEFINED
37 /* Thread descriptors */
38 typedef struct _pthread_descr_struct *_pthread_descr;
39 # define _PTHREAD_DESCR_DEFINED
40 #endif
41
42
43 /* Attributes for threads.  */
44 typedef struct __pthread_attr_s
45 {
46   int __detachstate;
47   int __schedpolicy;
48   struct __sched_param __schedparam;
49   int __inheritsched;
50   int __scope;
51   size_t __guardsize;
52   int __stackaddr_set;
53   void *__stackaddr;
54   size_t __stacksize;
55 } pthread_attr_t;
56
57
58 /* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
59
60 #ifdef __GLIBC_HAVE_LONG_LONG
61 __extension__ typedef long long __pthread_cond_align_t;
62 #else
63 typedef long __pthread_cond_align_t;
64 #endif
65
66 typedef struct
67 {
68   struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
69   _pthread_descr __c_waiting;        /* Threads waiting on this condition */
70   char __padding[48 - sizeof (struct _pthread_fastlock)
71                  - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
72   __pthread_cond_align_t __align;
73 } pthread_cond_t;
74
75
76 /* Attribute for conditionally variables.  */
77 typedef struct
78 {
79   int __dummy;
80 } pthread_condattr_t;
81
82 /* Keys for thread-specific data */
83 typedef unsigned int pthread_key_t;
84
85
86 /* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER).  */
87 /* (The layout is unnatural to maintain binary compatibility
88     with earlier releases of LinuxThreads.) */
89 typedef struct
90 {
91   int __m_reserved;               /* Reserved for future use */
92   int __m_count;                  /* Depth of recursive locking */
93   _pthread_descr __m_owner;       /* Owner thread (if recursive or errcheck) */
94   int __m_kind;                   /* Mutex kind: fast, recursive or errcheck */
95   struct _pthread_fastlock __m_lock; /* Underlying fast lock */
96 } pthread_mutex_t;
97
98
99 /* Attribute for mutex.  */
100 typedef struct
101 {
102   int __mutexkind;
103 } pthread_mutexattr_t;
104
105
106 /* Once-only execution */
107 typedef int pthread_once_t;
108
109
110 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
111 /* Read-write locks.  */
112 typedef struct _pthread_rwlock_t
113 {
114   struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
115   int __rw_readers;                   /* Number of readers */
116   _pthread_descr __rw_writer;         /* Identity of writer, or NULL if none */
117   _pthread_descr __rw_read_waiting;   /* Threads waiting for reading */
118   _pthread_descr __rw_write_waiting;  /* Threads waiting for writing */
119   int __rw_kind;                      /* Reader/Writer preference selection */
120   int __rw_pshared;                   /* Shared between processes or not */
121 } pthread_rwlock_t;
122
123
124 /* Attribute for read-write locks.  */
125 typedef struct
126 {
127   int __lockkind;
128   int __pshared;
129 } pthread_rwlockattr_t;
130 #endif
131
132 #ifdef __USE_XOPEN2K
133 /* POSIX spinlock data type.  */
134 typedef __volatile__ int pthread_spinlock_t;
135
136 /* POSIX barrier. */
137 typedef struct {
138   struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
139   int __ba_required;                  /* Threads needed for completion */
140   int __ba_present;                   /* Threads waiting */
141   _pthread_descr __ba_waiting;        /* Queue of waiting threads */
142 } pthread_barrier_t;
143
144 /* barrier attribute */
145 typedef struct {
146   int __pshared;
147 } pthread_barrierattr_t;
148
149 #endif
150
151
152 /* Thread identifiers */
153 typedef unsigned long int pthread_t;
154
155 #endif  /* bits/pthreadtypes.h */