Mercurial > hg > octave-shane > gnulib-hg
annotate lib/pthread.in.h @ 13706:b236a91e37b9
pthread: add pthread_spin_destroy
* lib/pthread.in.h (pthread_spin_destroy): New function.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 20 Sep 2010 16:14:49 -0700 |
parents | 8a0b8adde2be |
children | b747a553a8bb |
rev | line source |
---|---|
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
1 /* Implement a trivial subset of POSIX 1003.1-2008 pthread.h. |
11431 | 2 |
12559
c2cbabec01dd
update nearly all FSF copyright year lists to include 2010
Jim Meyering <meyering@redhat.com>
parents:
12421
diff
changeset
|
3 Copyright (C) 2009, 2010 Free Software Foundation, Inc. |
11431 | 4 |
5 This program is free software; you can redistribute it and/or modify | |
6 it under the terms of the GNU General Public License as published by | |
7 the Free Software Foundation; either version 2, or (at your option) | |
8 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 General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU General Public License | |
16 along with this program; if not, write to the Free Software Foundation, | |
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ | |
18 | |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
19 /* Written by Paul Eggert and Glen Lenker. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
20 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
21 #ifndef _GL_PTHREAD_H_ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
22 #define _GL_PTHREAD_H_ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
23 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
24 #include <errno.h> |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
25 #include <stdlib.h> |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
26 #include <sched.h> |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
27 #include <sys/types.h> |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
28 #include <time.h> |
11431 | 29 |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
30 #ifndef HAVE_PTHREAD_T |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
31 typedef int pthread_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
32 typedef int pthread_attr_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
33 typedef int pthread_barrier_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
34 typedef int pthread_barrierattr_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
35 typedef int pthread_cond_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
36 typedef int pthread_condattr_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
37 typedef int pthread_key_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
38 typedef int pthread_mutex_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
39 typedef int pthread_mutexattr_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
40 typedef int pthread_once_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
41 typedef int pthread_rwlock_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
42 typedef int pthread_rwlockattr_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
43 typedef int pthread_spinlock_t; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
44 #endif |
11431 | 45 |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
46 #define PTHREAD_COND_INITIALIZER { 0 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
47 #define PTHREAD_MUTEX_INITIALIZER { 0 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
48 #define PTHREAD_ONCE_INIT { 0 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
49 #define PTHREAD_RWLOCK_INITIALIZER { 0 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
50 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
51 #define PTHREAD_BARRIER_SERIAL_THREAD (-1) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
52 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
53 #define PTHREAD_CANCEL_DEFERRED 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
54 #define PTHREAD_CANCEL_ASYNCHRONOUS 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
55 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
56 #define PTHREAD_CANCEL_ENABLE 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
57 #define PTHREAD_CANCEL_DISABLE 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
58 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
59 #define PTHREAD_CANCELED ((void *) -1) |
11431 | 60 |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
61 #define PTHREAD_CREATE_JOINABLE 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
62 #define PTHREAD_CREATE_DETACHED 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
63 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
64 #define PTHREAD_INHERIT_SCHED 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
65 #define PTHREAD_EXPLICIT_SCHED 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
66 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
67 #define PTHREAD_MUTEX_DEFAULT PTHREAD_MUTEX_NORMAL |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
68 #define PTHREAD_MUTEX_NORMAL 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
69 #define PTHREAD_MUTEX_ERRORCHECK 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
70 #define PTHREAD_MUTEX_RECURSIVE 2 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
71 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
72 #define PTHREAD_MUTEX_STALLED 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
73 #define PTHREAD_MUTEX_ROBUST 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
74 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
75 #define PTHREAD_PRIO_NONE 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
76 #define PTHREAD_PRIO_INHERIT 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
77 #define PTHREAD_PRIO_PROTECT 2 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
78 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
79 #define PTHREAD_PROCESS_PRIVATE 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
80 #define PTHREAD_PROCESS_SHARED 1 |
11431 | 81 |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
82 #define PTHREAD_SCOPE_SYSTEM 0 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
83 #define PTHREAD_SCOPE_PROCESS 1 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
84 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
85 /* Provide substitutes for the thread functions that should work |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
86 adequately on a single-threaded implementation, where |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
87 pthread_create always fails. The goal is to let programs compile |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
88 on non-pthread hosts with minimal runtime overhead. |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
89 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
90 Omit interfaces that have not been analyzed and for which we do not |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
91 know what to do, so that they elicit a compile-time error for |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
92 now. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
93 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
94 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
95 pthread_cond_destroy (pthread_cond_t *cond) |
11431 | 96 { |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
97 /* COND is never seriously used. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
98 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
99 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
100 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
101 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
102 pthread_cond_init (pthread_cond_t *restrict cond, |
13479
8a0b8adde2be
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
13467
diff
changeset
|
103 pthread_condattr_t const *restrict attr) |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
104 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
105 /* COND is never seriously used. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
106 return 0; |
11431 | 107 } |
108 | |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
109 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
110 pthread_cond_signal (pthread_cond_t *cond) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
111 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
112 /* No threads can currently be blocked on COND. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
113 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
114 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
115 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
116 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
117 pthread_cond_wait (pthread_cond_t *restrict cond, |
13479
8a0b8adde2be
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
13467
diff
changeset
|
118 pthread_mutex_t *restrict mutex) |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
119 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
120 /* Properly-written applications never come here. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
121 abort (); |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
122 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
123 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
124 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
125 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
126 pthread_create (pthread_t *restrict thread, |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
127 pthread_attr_t const *restrict attr, |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
128 void * (*start_routine) (void*), void *restrict arg) |
11431 | 129 { |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
130 /* Do not create a thread. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
131 return EAGAIN; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
132 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
133 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
134 static inline void |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
135 pthread_exit (void *value) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
136 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
137 /* There is just one thread, so the process exits. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
138 exit (0); |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
139 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
140 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
141 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
142 pthread_join (pthread_t thread, void **pvalue) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
143 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
144 /* Properly-written applications never come here. */ |
11431 | 145 abort (); |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
146 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
147 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
148 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
149 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
150 pthread_mutex_destroy (pthread_mutex_t *mutex) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
151 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
152 /* MUTEX is never seriously used. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
153 return 0; |
11431 | 154 } |
155 | |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
156 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
157 pthread_mutex_init (pthread_mutex_t *restrict mutex, |
13479
8a0b8adde2be
Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents:
13467
diff
changeset
|
158 pthread_mutexattr_t const *restrict attr) |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
159 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
160 /* MUTEX is never seriously used. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
161 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
162 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
163 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
164 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
165 pthread_mutex_lock (pthread_mutex_t *mutex) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
166 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
167 /* There is only one thread, so it always gets the lock. This |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
168 implementation does not support PTHREAD_MUTEX_ERRORCHECK. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
169 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
170 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
171 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
172 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
173 pthread_mutex_unlock (pthread_mutex_t *mutex) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
174 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
175 /* There is only one thread, so it always unlocks successfully. |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
176 This implementation does not support robust mutexes or |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
177 PTHREAD_MUTEX_ERRORCHECK. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
178 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
179 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
180 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
181 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
182 pthread_spin_init (pthread_spinlock_t *lock, int pshared) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
183 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
184 /* LOCK is never seriously used. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
185 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
186 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
187 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
188 static inline int |
13706
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
189 pthread_spin_destroy (pthread_spinlock_t *lock) |
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
190 { |
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
191 /* LOCK is never seriously used. */ |
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
192 return 0; |
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
193 } |
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
194 |
b236a91e37b9
pthread: add pthread_spin_destroy
Paul Eggert <eggert@cs.ucla.edu>
parents:
13479
diff
changeset
|
195 static inline int |
13467
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
196 pthread_spin_lock (pthread_spinlock_t *lock) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
197 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
198 /* Only one thread, so it always gets the lock. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
199 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
200 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
201 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
202 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
203 pthread_spin_trylock (pthread_spinlock_t *lock) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
204 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
205 /* Only one thread, so it always gets the lock. Assume that a |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
206 thread never tries a lock that it already holds. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
207 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
208 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
209 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
210 static inline int |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
211 pthread_spin_unlock (pthread_spinlock_t *lock) |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
212 { |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
213 /* Only one thread, so spin locks are no-ops. */ |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
214 return 0; |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
215 } |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
216 |
b3e78c51aab6
pthread: Add enough so that coreutils/src/sort.c compiles.
Paul R. Eggert <eggert@cs.ucla.edu>
parents:
12559
diff
changeset
|
217 #endif /* _GL_PTHREAD_H_ */ |