Update copyright notices with scripts/update-copyrights
[glibc.git] / nptl / sysdeps / unix / sysv / linux / internaltypes.h
blobd127f688cf32315df9c89b70faac9ee768926205
1 /* Copyright (C) 2002-2014 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, see
17 <http://www.gnu.org/licenses/>. */
19 #ifndef _INTERNALTYPES_H
20 #define _INTERNALTYPES_H 1
22 #include <stdint.h>
25 struct pthread_attr
27 /* Scheduler parameters and priority. */
28 struct sched_param schedparam;
29 int schedpolicy;
30 /* Various flags like detachstate, scope, etc. */
31 int flags;
32 /* Size of guard area. */
33 size_t guardsize;
34 /* Stack handling. */
35 void *stackaddr;
36 size_t stacksize;
37 /* Affinity map. */
38 cpu_set_t *cpuset;
39 size_t cpusetsize;
42 #define ATTR_FLAG_DETACHSTATE 0x0001
43 #define ATTR_FLAG_NOTINHERITSCHED 0x0002
44 #define ATTR_FLAG_SCOPEPROCESS 0x0004
45 #define ATTR_FLAG_STACKADDR 0x0008
46 #define ATTR_FLAG_OLDATTR 0x0010
47 #define ATTR_FLAG_SCHED_SET 0x0020
48 #define ATTR_FLAG_POLICY_SET 0x0040
51 /* Mutex attribute data structure. */
52 struct pthread_mutexattr
54 /* Identifier for the kind of mutex.
56 Bit 31 is set if the mutex is to be shared between processes.
58 Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
59 the type of the mutex. */
60 int mutexkind;
64 /* Conditional variable attribute data structure. */
65 struct pthread_condattr
67 /* Combination of values:
69 Bit 0 : flag whether conditional variable will be sharable between
70 processes.
72 Bit 1-7: clock ID. */
73 int value;
77 /* The __NWAITERS field is used as a counter and to house the number
78 of bits for other purposes. COND_CLOCK_BITS is the number
79 of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT
80 is the number of bits reserved for other purposes like the clock. */
81 #define COND_CLOCK_BITS 1
82 #define COND_NWAITERS_SHIFT 1
85 /* Read-write lock variable attribute data structure. */
86 struct pthread_rwlockattr
88 int lockkind;
89 int pshared;
93 /* Barrier data structure. */
94 struct pthread_barrier
96 unsigned int curr_event;
97 int lock;
98 unsigned int left;
99 unsigned int init_count;
100 int private;
104 /* Barrier variable attribute data structure. */
105 struct pthread_barrierattr
107 int pshared;
111 /* Thread-local data handling. */
112 struct pthread_key_struct
114 /* Sequence numbers. Even numbers indicated vacant entries. Note
115 that zero is even. We use uintptr_t to not require padding on
116 32- and 64-bit machines. On 64-bit machines it helps to avoid
117 wrapping, too. */
118 uintptr_t seq;
120 /* Destructor for the data. */
121 void (*destr) (void *);
124 /* Check whether an entry is unused. */
125 #define KEY_UNUSED(p) (((p) & 1) == 0)
126 /* Check whether a key is usable. We cannot reuse an allocated key if
127 the sequence counter would overflow after the next destroy call.
128 This would mean that we potentially free memory for a key with the
129 same sequence. This is *very* unlikely to happen, A program would
130 have to create and destroy a key 2^31 times (on 32-bit platforms,
131 on 64-bit platforms that would be 2^63). If it should happen we
132 simply don't use this specific key anymore. */
133 #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
136 /* Handling of read-write lock data. */
137 // XXX For now there is only one flag. Maybe more in future.
138 #define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
141 /* Semaphore variable structure. */
142 struct new_sem
144 unsigned int value;
145 int private;
146 unsigned long int nwaiters;
149 struct old_sem
151 unsigned int value;
155 /* Compatibility type for old conditional variable interfaces. */
156 typedef struct
158 pthread_cond_t *cond;
159 } pthread_cond_2_0_t;
161 #endif /* internaltypes.h */