1 /* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr) */
3 /* This program is free software; you can redistribute it and/or */
4 /* modify it under the terms of the GNU Library General Public License */
5 /* as published by the Free Software Foundation; either version 2 */
6 /* of the License, or (at your option) any later version. */
8 /* This program is distributed in the hope that it will be useful, */
9 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
10 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
11 /* GNU Library General Public License for more details. */
13 /* 2008 Alexander Warg --- L4 adaption */
18 #include <l4/sys/types.h>
19 #include <l4/sys/scheduler.h>
21 #define __need_schedparam
22 #include <bits/sched.h>
24 /* Fast locks (not abstract because mutexes and conditions aren't abstract). */
25 struct _pthread_fastlock
27 long int __status; /* "Free" or "taken" or head of waiting list */
28 int __spinlock; /* Used by compare_and_swap emulation. Also,
29 adaptive SMP lock stores spin count here. */
32 #ifndef _PTHREAD_DESCR_DEFINED
33 /* Thread descriptors */
34 typedef struct pthread *_pthread_descr;
35 # define _PTHREAD_DESCR_DEFINED
39 /* Attributes for threads. */
40 typedef struct __pthread_attr_s
44 struct __sched_param __schedparam;
53 l4_sched_cpu_set_t affinity;
54 unsigned create_flags;
59 /* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
61 #ifdef __GLIBC_HAVE_LONG_LONG
62 __extension__ typedef long long __pthread_cond_align_t;
64 typedef long __pthread_cond_align_t;
69 struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
70 _pthread_descr __c_waiting; /* Threads waiting on this condition */
71 char __padding[48 - sizeof (struct _pthread_fastlock)
72 - sizeof (_pthread_descr) - sizeof (__pthread_cond_align_t)];
73 __pthread_cond_align_t __align;
77 /* Attribute for conditionally variables. */
83 /* Keys for thread-specific data */
84 typedef unsigned int pthread_key_t;
87 /* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER). */
88 /* (The layout is unnatural to maintain binary compatibility
89 with earlier releases of LinuxThreads.) */
92 int __m_reserved; /* Reserved for future use */
93 int __m_count; /* Depth of recursive locking */
94 _pthread_descr __m_owner; /* Owner thread (if recursive or errcheck) */
95 int __m_kind; /* Mutex kind: fast, recursive or errcheck */
96 struct _pthread_fastlock __m_lock; /* Underlying fast lock */
100 /* Attribute for mutex. */
104 } pthread_mutexattr_t;
107 /* Once-only execution */
108 typedef int pthread_once_t;
111 #if defined __USE_UNIX98 || defined __USE_XOPEN2K
112 /* Read-write locks. */
113 typedef struct _pthread_rwlock_t
115 struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
116 int __rw_readers; /* Number of readers */
117 _pthread_descr __rw_writer; /* Identity of writer, or NULL if none */
118 _pthread_descr __rw_read_waiting; /* Threads waiting for reading */
119 _pthread_descr __rw_write_waiting; /* Threads waiting for writing */
120 int __rw_kind; /* Reader/Writer preference selection */
121 int __rw_pshared; /* Shared between processes or not */
125 /* Attribute for read-write locks. */
130 } pthread_rwlockattr_t;
134 /* POSIX spinlock data type. */
135 typedef __volatile__ int pthread_spinlock_t;
139 struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
140 int __ba_required; /* Threads needed for completion */
141 int __ba_present; /* Threads waiting */
142 _pthread_descr __ba_waiting; /* Queue of waiting threads */
145 /* barrier attribute */
148 } pthread_barrierattr_t;
153 /* Thread identifiers */
154 typedef void *pthread_t;