1 /* Copyright (C) 2002-2020 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 <https://www.gnu.org/licenses/>. */
19 #ifndef _INTERNALTYPES_H
20 #define _INTERNALTYPES_H 1
29 /* Scheduler parameters and priority. */
30 struct sched_param schedparam
;
32 /* Various flags like detachstate, scope, etc. */
34 /* Size of guard area. */
40 /* Allocated via a call to __pthread_attr_extension once needed. */
41 struct pthread_attr_extension
*extension
;
45 #define ATTR_FLAG_DETACHSTATE 0x0001
46 #define ATTR_FLAG_NOTINHERITSCHED 0x0002
47 #define ATTR_FLAG_SCOPEPROCESS 0x0004
48 #define ATTR_FLAG_STACKADDR 0x0008
49 #define ATTR_FLAG_OLDATTR 0x0010
50 #define ATTR_FLAG_SCHED_SET 0x0020
51 #define ATTR_FLAG_POLICY_SET 0x0040
53 /* Used to allocate a pthread_attr_t object which is also accessed
55 union pthread_attr_transparent
57 pthread_attr_t external
;
58 struct pthread_attr internal
;
61 /* Extension space for pthread attributes. Referenced by the
62 extension member of struct pthread_attr. */
63 struct pthread_attr_extension
73 /* Mutex attribute data structure. */
74 struct pthread_mutexattr
76 /* Identifier for the kind of mutex.
78 Bit 31 is set if the mutex is to be shared between processes.
80 Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
81 the type of the mutex. */
86 /* Conditional variable attribute data structure. */
87 struct pthread_condattr
89 /* Combination of values:
91 Bit 0 : flag whether conditional variable will be
92 sharable between processes.
93 Bit 1-COND_CLOCK_BITS: Clock ID. COND_CLOCK_BITS is the number of bits
94 needed to represent the ID of the clock. */
97 #define COND_CLOCK_BITS 1
100 /* Read-write lock variable attribute data structure. */
101 struct pthread_rwlockattr
108 /* Barrier data structure. See pthread_barrier_wait for a description
109 of how these fields are used. */
110 struct pthread_barrier
113 unsigned int current_round
;
118 /* See pthread_barrier_wait for a description. */
119 #define BARRIER_IN_THRESHOLD (UINT_MAX/2)
122 /* Barrier variable attribute data structure. */
123 struct pthread_barrierattr
129 /* Thread-local data handling. */
130 struct pthread_key_struct
132 /* Sequence numbers. Even numbers indicated vacant entries. Note
133 that zero is even. We use uintptr_t to not require padding on
134 32- and 64-bit machines. On 64-bit machines it helps to avoid
138 /* Destructor for the data. */
139 void (*destr
) (void *);
142 /* Check whether an entry is unused. */
143 #define KEY_UNUSED(p) (((p) & 1) == 0)
144 /* Check whether a key is usable. We cannot reuse an allocated key if
145 the sequence counter would overflow after the next destroy call.
146 This would mean that we potentially free memory for a key with the
147 same sequence. This is *very* unlikely to happen, A program would
148 have to create and destroy a key 2^31 times (on 32-bit platforms,
149 on 64-bit platforms that would be 2^63). If it should happen we
150 simply don't use this specific key anymore. */
151 #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
154 /* Handling of read-write lock data. */
155 // XXX For now there is only one flag. Maybe more in future.
156 #define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
159 /* Semaphore variable structure. */
162 #if __HAVE_64B_ATOMICS
163 /* The data field holds both value (in the least-significant 32 bits) and
165 # if __BYTE_ORDER == __LITTLE_ENDIAN
166 # define SEM_VALUE_OFFSET 0
167 # elif __BYTE_ORDER == __BIG_ENDIAN
168 # define SEM_VALUE_OFFSET 1
170 # error Unsupported byte order.
172 # define SEM_NWAITERS_SHIFT 32
173 # define SEM_VALUE_MASK (~(unsigned int)0)
178 # define SEM_VALUE_SHIFT 1
179 # define SEM_NWAITERS_MASK ((unsigned int)1)
183 unsigned int nwaiters
;
193 /* Compatibility type for old conditional variable interfaces. */
196 pthread_cond_t
*cond
;
197 } pthread_cond_2_0_t
;
199 #endif /* internaltypes.h */