2.9
[glibc/nacl-glibc.git] / nptl / sysdeps / unix / sysv / linux / internaltypes.h
blobadd20b6f728e44a5494ee60a0d0175b822ea0294
1 /* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library 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 GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #ifndef _INTERNALTYPES_H
21 #define _INTERNALTYPES_H 1
23 #include <stdint.h>
26 struct pthread_attr
28 /* Scheduler parameters and priority. */
29 struct sched_param schedparam;
30 int schedpolicy;
31 /* Various flags like detachstate, scope, etc. */
32 int flags;
33 /* Size of guard area. */
34 size_t guardsize;
35 /* Stack handling. */
36 void *stackaddr;
37 size_t stacksize;
38 /* Affinity map. */
39 cpu_set_t *cpuset;
40 size_t cpusetsize;
43 #define ATTR_FLAG_DETACHSTATE 0x0001
44 #define ATTR_FLAG_NOTINHERITSCHED 0x0002
45 #define ATTR_FLAG_SCOPEPROCESS 0x0004
46 #define ATTR_FLAG_STACKADDR 0x0008
47 #define ATTR_FLAG_OLDATTR 0x0010
48 #define ATTR_FLAG_SCHED_SET 0x0020
49 #define ATTR_FLAG_POLICY_SET 0x0040
52 /* Mutex attribute data structure. */
53 struct pthread_mutexattr
55 /* Identifier for the kind of mutex.
57 Bit 31 is set if the mutex is to be shared between processes.
59 Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
60 the type of the mutex. */
61 int mutexkind;
65 /* Conditional variable attribute data structure. */
66 struct pthread_condattr
68 /* Combination of values:
70 Bit 0 : flag whether coditional variable will be shareable between
71 processes.
73 Bit 1-7: clock ID. */
74 int value;
78 /* The __NWAITERS field is used as a counter and to house the number
79 of bits for other purposes. COND_CLOCK_BITS is the number
80 of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT
81 is the number of bits reserved for other purposes like the clock. */
82 #define COND_CLOCK_BITS 1
83 #define COND_NWAITERS_SHIFT 1
86 /* Read-write lock variable attribute data structure. */
87 struct pthread_rwlockattr
89 int lockkind;
90 int pshared;
94 /* Barrier data structure. */
95 struct pthread_barrier
97 unsigned int curr_event;
98 int lock;
99 unsigned int left;
100 unsigned int init_count;
101 int private;
105 /* Barrier variable attribute data structure. */
106 struct pthread_barrierattr
108 int pshared;
112 /* Thread-local data handling. */
113 struct pthread_key_struct
115 /* Sequence numbers. Even numbers indicated vacant entries. Note
116 that zero is even. We use uintptr_t to not require padding on
117 32- and 64-bit machines. On 64-bit machines it helps to avoid
118 wrapping, too. */
119 uintptr_t seq;
121 /* Destructor for the data. */
122 void (*destr) (void *);
125 /* Check whether an entry is unused. */
126 #define KEY_UNUSED(p) (((p) & 1) == 0)
127 /* Check whether a key is usable. We cannot reuse an allocated key if
128 the sequence counter would overflow after the next destroy call.
129 This would mean that we potentially free memory for a key with the
130 same sequence. This is *very* unlikely to happen, A program would
131 have to create and destroy a key 2^31 times (on 32-bit platforms,
132 on 64-bit platforms that would be 2^63). If it should happen we
133 simply don't use this specific key anymore. */
134 #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
137 /* Handling of read-write lock data. */
138 // XXX For now there is only one flag. Maybe more in future.
139 #define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
142 /* Semaphore variable structure. */
143 struct new_sem
145 unsigned int value;
146 int private;
147 unsigned long int nwaiters;
150 struct old_sem
152 unsigned int value;
156 /* Compatibility type for old conditional variable interfaces. */
157 typedef struct
159 pthread_cond_t *cond;
160 } pthread_cond_2_0_t;
162 #endif /* internaltypes.h */