~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to lib/pthread.in.h

  • Committer: Colin Watson
  • Date: 2013-10-30 15:48:33 UTC
  • mfrom: (8.3.5 sid)
  • Revision ID: cjwatson@canonical.com-20131030154833-xdt6e1yfffqom1c4
merge from Debian 8.21-1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Implement a trivial subset of POSIX 1003.1-2008 pthread.h.
2
2
 
3
 
   Copyright (C) 2009-2012 Free Software Foundation, Inc.
 
3
   Copyright (C) 2009-2013 Free Software Foundation, Inc.
4
4
 
5
5
   This program is free software; you can redistribute it and/or modify
6
6
   it under the terms of the GNU General Public License as published by
32
32
#ifndef _@GUARD_PREFIX@_PTHREAD_H_
33
33
#define _@GUARD_PREFIX@_PTHREAD_H_
34
34
 
 
35
#define __need_system_stdlib_h
 
36
#include <stdlib.h>
 
37
#undef __need_system_stdlib_h
 
38
 
35
39
#include <errno.h>
36
 
#include <stdlib.h>
37
40
#include <sched.h>
38
41
#include <sys/types.h>
39
42
#include <time.h>
40
43
 
 
44
_GL_INLINE_HEADER_BEGIN
 
45
#ifndef _GL_PTHREAD_INLINE
 
46
# define _GL_PTHREAD_INLINE _GL_INLINE
 
47
#endif
 
48
 
41
49
#if ! @HAVE_PTHREAD_T@
42
50
# if !GNULIB_defined_pthread_types
43
51
 typedef int pthread_t;
110
118
   know what to do, so that they elicit a compile-time error for
111
119
   now.  */
112
120
 
113
 
static inline int
 
121
_GL_PTHREAD_INLINE int
114
122
pthread_cond_destroy (pthread_cond_t *cond)
115
123
{
116
124
  /* COND is never seriously used.  */
117
125
  return 0;
118
126
}
119
127
 
120
 
static inline int
 
128
_GL_PTHREAD_INLINE int
121
129
pthread_cond_init (pthread_cond_t *restrict cond,
122
130
                   pthread_condattr_t const *restrict attr)
123
131
{
125
133
  return 0;
126
134
}
127
135
 
128
 
static inline int
 
136
_GL_PTHREAD_INLINE int
129
137
pthread_cond_signal (pthread_cond_t *cond)
130
138
{
131
139
  /* No threads can currently be blocked on COND.  */
132
140
  return 0;
133
141
}
134
142
 
135
 
static inline int
 
143
_GL_PTHREAD_INLINE int
136
144
pthread_cond_wait (pthread_cond_t *restrict cond,
137
145
                   pthread_mutex_t *restrict mutex)
138
146
{
141
149
  return 0;
142
150
}
143
151
 
144
 
static inline int
 
152
_GL_PTHREAD_INLINE int
145
153
pthread_create (pthread_t *restrict thread,
146
154
                pthread_attr_t const *restrict attr,
147
155
                void * (*start_routine) (void*), void *restrict arg)
150
158
  return EAGAIN;
151
159
}
152
160
 
153
 
static inline void
 
161
_GL_PTHREAD_INLINE void
154
162
pthread_exit (void *value)
155
163
{
156
164
  /* There is just one thread, so the process exits.  */
157
165
  exit (0);
158
166
}
159
167
 
160
 
static inline int
 
168
_GL_PTHREAD_INLINE int
161
169
pthread_join (pthread_t thread, void **pvalue)
162
170
{
163
171
  /* Properly-written applications never come here.  */
165
173
  return 0;
166
174
}
167
175
 
168
 
static inline int
 
176
_GL_PTHREAD_INLINE int
169
177
pthread_mutexattr_destroy (pthread_mutexattr_t *attr)
170
178
{
171
179
  return 0;
172
180
}
173
181
 
174
 
static inline int
 
182
_GL_PTHREAD_INLINE int
175
183
pthread_mutexattr_init (pthread_mutexattr_t *attr)
176
184
{
177
185
  return 0;
178
186
}
179
187
 
180
 
static inline int
 
188
_GL_PTHREAD_INLINE int
181
189
pthread_mutexattr_settype (pthread_mutexattr_t *attr, int attr_type)
182
190
{
183
191
  return 0;
184
192
}
185
193
 
186
 
static inline int
 
194
_GL_PTHREAD_INLINE int
187
195
pthread_mutex_destroy (pthread_mutex_t *mutex)
188
196
{
189
197
  /* MUTEX is never seriously used.  */
190
198
  return 0;
191
199
}
192
200
 
193
 
static inline int
 
201
_GL_PTHREAD_INLINE int
194
202
pthread_mutex_init (pthread_mutex_t *restrict mutex,
195
203
                    pthread_mutexattr_t const *restrict attr)
196
204
{
198
206
  return 0;
199
207
}
200
208
 
201
 
static inline int
 
209
_GL_PTHREAD_INLINE int
202
210
pthread_mutex_lock (pthread_mutex_t *mutex)
203
211
{
204
212
  /* There is only one thread, so it always gets the lock.  This
206
214
  return 0;
207
215
}
208
216
 
209
 
static inline int
 
217
_GL_PTHREAD_INLINE int
210
218
pthread_mutex_trylock (pthread_mutex_t *mutex)
211
219
{
212
220
  return pthread_mutex_lock (mutex);
213
221
}
214
222
 
215
 
static inline int
 
223
_GL_PTHREAD_INLINE int
216
224
pthread_mutex_unlock (pthread_mutex_t *mutex)
217
225
{
218
226
  /* There is only one thread, so it always unlocks successfully.
234
242
 
235
243
typedef pthread_mutex_t pthread_spinlock_t;
236
244
 
237
 
static inline int
 
245
_GL_PTHREAD_INLINE int
238
246
pthread_spin_init (pthread_spinlock_t *lock, int pshared)
239
247
{
240
248
  return pthread_mutex_init (lock, NULL);
241
249
}
242
250
 
243
 
static inline int
 
251
_GL_PTHREAD_INLINE int
244
252
pthread_spin_destroy (pthread_spinlock_t *lock)
245
253
{
246
254
  return pthread_mutex_destroy (lock);
247
255
}
248
256
 
249
 
static inline int
 
257
_GL_PTHREAD_INLINE int
250
258
pthread_spin_lock (pthread_spinlock_t *lock)
251
259
{
252
260
  return pthread_mutex_lock (lock);
253
261
}
254
262
 
255
 
static inline int
 
263
_GL_PTHREAD_INLINE int
256
264
pthread_spin_trylock (pthread_spinlock_t *lock)
257
265
{
258
266
  return pthread_mutex_trylock (lock);
259
267
}
260
268
 
261
 
static inline int
 
269
_GL_PTHREAD_INLINE int
262
270
pthread_spin_unlock (pthread_spinlock_t *lock)
263
271
{
264
272
  return pthread_mutex_unlock (lock);
269
277
 
270
278
#endif
271
279
 
 
280
_GL_INLINE_HEADER_END
 
281
 
272
282
#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */
273
283
#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */