Back to index

glibc  2.9
internaltypes.h
Go to the documentation of this file.
00001 /* Copyright (C) 2002, 2003, 2004, 2007 Free Software Foundation, Inc.
00002    This file is part of the GNU C Library.
00003    Contributed by Ulrich Drepper <drepper@redhat.com>, 2002.
00004 
00005    The GNU C Library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public
00007    License as published by the Free Software Foundation; either
00008    version 2.1 of the License, or (at your option) any later version.
00009 
00010    The GNU C Library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Lesser General Public License for more details.
00014 
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with the GNU C Library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA.  */
00019 
00020 #ifndef _INTERNALTYPES_H
00021 #define _INTERNALTYPES_H    1
00022 
00023 #include <stdint.h>
00024 
00025 
00026 struct pthread_attr
00027 {
00028   /* Scheduler parameters and priority.  */
00029   struct sched_param schedparam;
00030   int schedpolicy;
00031   /* Various flags like detachstate, scope, etc.  */
00032   int flags;
00033   /* Size of guard area.  */
00034   size_t guardsize;
00035   /* Stack handling.  */
00036   void *stackaddr;
00037   size_t stacksize;
00038   /* Affinity map.  */
00039   cpu_set_t *cpuset;
00040   size_t cpusetsize;
00041 };
00042 
00043 #define ATTR_FLAG_DETACHSTATE             0x0001
00044 #define ATTR_FLAG_NOTINHERITSCHED  0x0002
00045 #define ATTR_FLAG_SCOPEPROCESS            0x0004
00046 #define ATTR_FLAG_STACKADDR        0x0008
00047 #define ATTR_FLAG_OLDATTR          0x0010
00048 #define ATTR_FLAG_SCHED_SET        0x0020
00049 #define ATTR_FLAG_POLICY_SET              0x0040
00050 
00051 
00052 /* Mutex attribute data structure.  */
00053 struct pthread_mutexattr
00054 {
00055   /* Identifier for the kind of mutex.
00056 
00057      Bit 31 is set if the mutex is to be shared between processes.
00058 
00059      Bit 0 to 30 contain one of the PTHREAD_MUTEX_ values to identify
00060      the type of the mutex.  */
00061   int mutexkind;
00062 };
00063 
00064 
00065 /* Conditional variable attribute data structure.  */
00066 struct pthread_condattr
00067 {
00068   /* Combination of values:
00069 
00070      Bit 0  : flag whether coditional variable will be shareable between
00071              processes.
00072 
00073      Bit 1-7: clock ID.  */
00074   int value;
00075 };
00076 
00077 
00078 /* The __NWAITERS field is used as a counter and to house the number
00079    of bits for other purposes.  COND_CLOCK_BITS is the number
00080    of bits needed to represent the ID of the clock.  COND_NWAITERS_SHIFT
00081    is the number of bits reserved for other purposes like the clock.  */
00082 #define COND_CLOCK_BITS            1
00083 #define COND_NWAITERS_SHIFT 1
00084 
00085 
00086 /* Read-write lock variable attribute data structure.  */
00087 struct pthread_rwlockattr
00088 {
00089   int lockkind;
00090   int pshared;
00091 };
00092 
00093 
00094 /* Barrier data structure.  */
00095 struct pthread_barrier
00096 {
00097   unsigned int curr_event;
00098   int lock;
00099   unsigned int left;
00100   unsigned int init_count;
00101   int private;
00102 };
00103 
00104 
00105 /* Barrier variable attribute data structure.  */
00106 struct pthread_barrierattr
00107 {
00108   int pshared;
00109 };
00110 
00111 
00112 /* Thread-local data handling.  */
00113 struct pthread_key_struct
00114 {
00115   /* Sequence numbers.  Even numbers indicated vacant entries.  Note
00116      that zero is even.  We use uintptr_t to not require padding on
00117      32- and 64-bit machines.  On 64-bit machines it helps to avoid
00118      wrapping, too.  */
00119   uintptr_t seq;
00120 
00121   /* Destructor for the data.  */
00122   void (*destr) (void *);
00123 };
00124 
00125 /* Check whether an entry is unused.  */
00126 #define KEY_UNUSED(p) (((p) & 1) == 0)
00127 /* Check whether a key is usable.  We cannot reuse an allocated key if
00128    the sequence counter would overflow after the next destroy call.
00129    This would mean that we potentially free memory for a key with the
00130    same sequence.  This is *very* unlikely to happen, A program would
00131    have to create and destroy a key 2^31 times (on 32-bit platforms,
00132    on 64-bit platforms that would be 2^63).  If it should happen we
00133    simply don't use this specific key anymore.  */
00134 #define KEY_USABLE(p) (((uintptr_t) (p)) < ((uintptr_t) ((p) + 2)))
00135 
00136 
00137 /* Handling of read-write lock data.  */
00138 // XXX For now there is only one flag.  Maybe more in future.
00139 #define RWLOCK_RECURSIVE(rwlock) ((rwlock)->__data.__flags != 0)
00140 
00141 
00142 /* Semaphore variable structure.  */
00143 struct new_sem
00144 {
00145   unsigned int value;
00146   int private;
00147   unsigned long int nwaiters;
00148 };
00149 
00150 struct old_sem
00151 {
00152   unsigned int value;
00153 };
00154 
00155 
00156 /* Compatibility type for old conditional variable interfaces.  */
00157 typedef struct
00158 {
00159   pthread_cond_t *cond;
00160 } pthread_cond_2_0_t;
00161 
00162 #endif /* internaltypes.h */