1 /* Copyright (C) 2002, 2003, 2004, 2007, 2008 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
3 Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
4 OpenSolaris bits contributed by David Bartley
5 <dtbartle@csclub.uwaterloo.ca>, 2008.
7 The GNU C Library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or (at your option) any later version.
12 The GNU C Library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
17 You should have received a copy of the GNU Lesser General Public
18 License along with the GNU C Library; if not, write to the Free
19 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
22 #ifndef _INTERNALTYPES_H
23 #define _INTERNALTYPES_H 1
32 /* Scheduler parameters and priority. */
33 struct sched_param schedparam;
35 /* Various flags like detachstate, scope, etc. */
37 /* Size of guard area. */
47 #define ATTR_FLAG_DETACHSTATE 0x0001
48 #define ATTR_FLAG_NOTINHERITSCHED 0x0002
49 #define ATTR_FLAG_SCOPEPROCESS 0x0004
50 #define ATTR_FLAG_STACKADDR 0x0008
51 #define ATTR_FLAG_OLDATTR 0x0010
52 #define ATTR_FLAG_SCHED_SET 0x0020
53 #define ATTR_FLAG_POLICY_SET 0x0040
54 #define ATTR_FLAG_DAEMON 0x0080
55 #define ATTR_FLAG_SUSPENDED 0x0100
56 #define ATTR_FLAG_THR_CREATE 0x0200
57 #define ATTR_FLAG_CREATE_FAILED 0x0400
60 /* Mutex attribute data structure. */
61 struct pthread_mutexattr
63 /* Identifier for the kind of mutex.
65 Bit 31 is set if the mutex is to be shared between processes.
67 Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
68 the type of the mutex. */
73 /* Conditional variable attribute data structure. */
74 struct pthread_condattr
76 /* Combination of values:
78 Bit 0 : flag whether coditional variable will be shareable between
86 /* The __NWAITERS field is used as a counter and to house the number
87 of bits for other purposes. COND_CLOCK_BITS is the number
88 of bits needed to represent the ID of the clock. COND_NWAITERS_SHIFT
89 is the number of bits reserved for other purposes like the clock. */
90 #define COND_CLOCK_BITS 3
91 #define COND_NWAITERS_SHIFT 3
94 /* Read-write lock variable attribute data structure. */
95 struct pthread_rwlockattr
101 #define BARRIER_EXITING 0x01
103 /* Barrier data structure. */
104 struct pthread_barrier
106 pthread_mutex_t mutex;
108 unsigned int curr_event;
110 unsigned int init_count;
115 /* Barrier variable attribute data structure. */
116 struct pthread_barrierattr
122 /* Thread-local data handling. */
123 struct pthread_key_struct
125 /* Sequence numbers. Even numbers indicated vacant entries. Note
126 that zero is even. We use uintptr_t to not require padding on
127 32- and 64-bit machines. On 64-bit machines it helps to avoid
131 /* Destructor for the data. */
132 void (*destr) (void *);
135 /* Check whether an entry is unused. */
136 #define KEY_UNUSED(p) (((p) & 1) == 0)
137 /* Check whether a key is usable. We cannot reuse an allocated key if
138 the sequence counter would overflow after the next destroy call.
139 This would mean that we potentially free memory for a key with the
140 same sequence. This is *very* unlikely to happen, A program would
141 have to create and destroy a key 2^31 times (on 32-bit platforms,
142 on 64-bit platforms that would be 2^63). If it should happen we
143 simply don't use this specific key anymore. */
144 #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
147 /* Handling of read-write lock data. */
148 // XXX For now there is only one flag. Maybe more in future.
149 //#define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
152 /* Compatibility type for old conditional variable interfaces. */
155 pthread_cond_t *cond;
156 } pthread_cond_2_0_t;
158 #endif /* internaltypes.h */