source: trunk/libs/newlib/src/newlib/libc/sys/linux/linuxthreads/bits/pthreadtypes.h @ 444

Last change on this file since 444 was 444, checked in by satin@…, 6 years ago

add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc

File size: 4.4 KB
Line 
1/* Linuxthreads - a simple clone()-based implementation of Posix        */
2/* threads for Linux.                                                   */
3/* Copyright (C) 1996 Xavier Leroy (Xavier.Leroy@inria.fr)              */
4/*                                                                      */
5/* This program is free software; you can redistribute it and/or        */
6/* modify it under the terms of the GNU Library General Public License  */
7/* as published by the Free Software Foundation; either version 2       */
8/* of the License, or (at your option) any later version.               */
9/*                                                                      */
10/* This program 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        */
13/* GNU Library General Public License for more details.                 */
14
15#if !defined _BITS_TYPES_H && !defined _PTHREAD_H
16# error "Never include <bits/pthreadtypes.h> directly; use <sys/types.h> instead."
17#endif
18
19#ifndef _BITS_PTHREADTYPES_H
20#define _BITS_PTHREADTYPES_H    1
21
22#define __need_schedparam
23#include <bits/sched.h>
24
25/* Fast locks (not abstract because mutexes and conditions aren't abstract). */
26struct _pthread_fastlock
27{
28  long int __status;   /* "Free" or "taken" or head of waiting list */
29  int __spinlock;      /* Used by compare_and_swap emulation. Also,
30                          adaptive SMP lock stores spin count here. */
31};
32
33#ifndef _PTHREAD_DESCR_DEFINED
34/* Thread descriptors */
35typedef struct _pthread_descr_struct *_pthread_descr;
36# define _PTHREAD_DESCR_DEFINED
37#endif
38
39
40/* Attributes for threads.  */
41typedef struct __pthread_attr_s
42{
43  int __detachstate;
44  int __schedpolicy;
45  struct __sched_param __schedparam;
46  int __inheritsched;
47  int __scope;
48  size_t __guardsize;
49  int __stackaddr_set;
50  void *__stackaddr;
51  size_t __stacksize;
52} pthread_attr_t;
53
54
55/* Conditions (not abstract because of PTHREAD_COND_INITIALIZER */
56typedef struct
57{
58  struct _pthread_fastlock __c_lock; /* Protect against concurrent access */
59  _pthread_descr __c_waiting;        /* Threads waiting on this condition */
60} pthread_cond_t;
61
62
63/* Attribute for conditionally variables.  */
64typedef struct
65{
66  int __dummy;
67} pthread_condattr_t;
68
69/* Keys for thread-specific data */
70typedef unsigned int pthread_key_t;
71
72
73/* Mutexes (not abstract because of PTHREAD_MUTEX_INITIALIZER).  */
74/* (The layout is unnatural to maintain binary compatibility
75    with earlier releases of LinuxThreads.) */
76typedef struct
77{
78  int __m_reserved;               /* Reserved for future use */
79  int __m_count;                  /* Depth of recursive locking */
80  _pthread_descr __m_owner;       /* Owner thread (if recursive or errcheck) */
81  int __m_kind;                   /* Mutex kind: fast, recursive or errcheck */
82  struct _pthread_fastlock __m_lock; /* Underlying fast lock */
83} pthread_mutex_t;
84
85
86/* Attribute for mutex.  */
87typedef struct
88{
89  int __mutexkind;
90} pthread_mutexattr_t;
91
92
93/* Once-only execution */
94typedef int pthread_once_t;
95
96
97#ifdef __USE_UNIX98
98/* Read-write locks.  */
99typedef struct _pthread_rwlock_t
100{
101  struct _pthread_fastlock __rw_lock; /* Lock to guarantee mutual exclusion */
102  int __rw_readers;                   /* Number of readers */
103  _pthread_descr __rw_writer;         /* Identity of writer, or NULL if none */
104  _pthread_descr __rw_read_waiting;   /* Threads waiting for reading */
105  _pthread_descr __rw_write_waiting;  /* Threads waiting for writing */
106  int __rw_kind;                      /* Reader/Writer preference selection */
107  int __rw_pshared;                   /* Shared between processes or not */
108} pthread_rwlock_t;
109
110
111/* Attribute for read-write locks.  */
112typedef struct
113{
114  int __lockkind;
115  int __pshared;
116} pthread_rwlockattr_t;
117#endif
118
119#ifdef __USE_XOPEN2K
120/* POSIX spinlock data type.  */
121typedef volatile int pthread_spinlock_t;
122
123/* POSIX barrier. */
124typedef struct {
125  struct _pthread_fastlock __ba_lock; /* Lock to guarantee mutual exclusion */
126  int __ba_required;                  /* Threads needed for completion */
127  int __ba_present;                   /* Threads waiting */
128  _pthread_descr __ba_waiting;        /* Queue of waiting threads */
129} pthread_barrier_t;
130
131/* barrier attribute */
132typedef struct {
133  int __pshared;
134} pthread_barrierattr_t;
135
136#endif
137
138
139/* Thread identifiers */
140typedef unsigned long int pthread_t;
141
142#endif  /* bits/pthreadtypes.h */
Note: See TracBrowser for help on using the repository browser.