X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fpthread.in.h;h=7fcfb0b3b64113081ea3ef9e5e58c5ce8cfa7e2f;hb=9e801adc214e131c6ea4c667407f54aa62888913;hp=66847f818bd8427a2aedcb380cc791ef7a928fd5;hpb=8c4874e600742f95ad38fbd6f518a3005ac4283c;p=gnulib.git diff --git a/lib/pthread.in.h b/lib/pthread.in.h index 66847f818..7fcfb0b3b 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -1,6 +1,6 @@ /* Implement a trivial subset of POSIX 1003.1-2008 pthread.h. - Copyright (C) 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 2009-2013 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -13,12 +13,11 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ + along with this program; if not, see . */ /* Written by Paul Eggert and Glen Lenker. */ -#ifndef _GL_PTHREAD_H_ +#ifndef _@GUARD_PREFIX@_PTHREAD_H_ #if __GNUC__ >= 3 @PRAGMA_SYSTEM_HEADER@ @@ -30,16 +29,25 @@ # @INCLUDE_NEXT@ @NEXT_PTHREAD_H@ #endif -#ifndef _GL_PTHREAD_H_ -#define _GL_PTHREAD_H_ +#ifndef _@GUARD_PREFIX@_PTHREAD_H_ +#define _@GUARD_PREFIX@_PTHREAD_H_ -#include +#define __need_system_stdlib_h #include +#undef __need_system_stdlib_h + +#include #include #include #include +_GL_INLINE_HEADER_BEGIN +#ifndef _GL_PTHREAD_INLINE +# define _GL_PTHREAD_INLINE _GL_INLINE +#endif + #if ! @HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_types typedef int pthread_t; typedef int pthread_attr_t; typedef int pthread_barrier_t; @@ -52,6 +60,8 @@ typedef int pthread_once_t; typedef int pthread_rwlock_t; typedef int pthread_rwlockattr_t; +# define GNULIB_defined_pthread_types 1 +# endif #endif #ifndef PTHREAD_COND_INITIALIZER @@ -97,6 +107,8 @@ #if ! @HAVE_PTHREAD_T@ +# if !GNULIB_defined_pthread_functions + /* Provide substitutes for the thread functions that should work adequately on a single-threaded implementation, where pthread_create always fails. The goal is to let programs compile @@ -106,14 +118,14 @@ know what to do, so that they elicit a compile-time error for now. */ -static inline int +_GL_PTHREAD_INLINE int pthread_cond_destroy (pthread_cond_t *cond) { /* COND is never seriously used. */ return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_cond_init (pthread_cond_t *restrict cond, pthread_condattr_t const *restrict attr) { @@ -121,14 +133,14 @@ pthread_cond_init (pthread_cond_t *restrict cond, return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_cond_signal (pthread_cond_t *cond) { /* No threads can currently be blocked on COND. */ return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_cond_wait (pthread_cond_t *restrict cond, pthread_mutex_t *restrict mutex) { @@ -137,7 +149,7 @@ pthread_cond_wait (pthread_cond_t *restrict cond, return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_create (pthread_t *restrict thread, pthread_attr_t const *restrict attr, void * (*start_routine) (void*), void *restrict arg) @@ -146,14 +158,14 @@ pthread_create (pthread_t *restrict thread, return EAGAIN; } -static inline void +_GL_PTHREAD_INLINE void pthread_exit (void *value) { /* There is just one thread, so the process exits. */ exit (0); } -static inline int +_GL_PTHREAD_INLINE int pthread_join (pthread_t thread, void **pvalue) { /* Properly-written applications never come here. */ @@ -161,32 +173,32 @@ pthread_join (pthread_t thread, void **pvalue) return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutexattr_destroy (pthread_mutexattr_t *attr) { return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutexattr_init (pthread_mutexattr_t *attr) { return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutexattr_settype (pthread_mutexattr_t *attr, int attr_type) { return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutex_destroy (pthread_mutex_t *mutex) { /* MUTEX is never seriously used. */ return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutex_init (pthread_mutex_t *restrict mutex, pthread_mutexattr_t const *restrict attr) { @@ -194,7 +206,7 @@ pthread_mutex_init (pthread_mutex_t *restrict mutex, return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutex_lock (pthread_mutex_t *mutex) { /* There is only one thread, so it always gets the lock. This @@ -202,13 +214,13 @@ pthread_mutex_lock (pthread_mutex_t *mutex) return 0; } -static inline int +_GL_PTHREAD_INLINE int pthread_mutex_trylock (pthread_mutex_t *mutex) { return pthread_mutex_lock (mutex); } -static inline int +_GL_PTHREAD_INLINE int pthread_mutex_unlock (pthread_mutex_t *mutex) { /* There is only one thread, so it always unlocks successfully. @@ -217,44 +229,55 @@ pthread_mutex_unlock (pthread_mutex_t *mutex) return 0; } +# define GNULIB_defined_pthread_functions 1 +# endif + #endif #if ! @HAVE_PTHREAD_SPINLOCK_T@ +# if !GNULIB_defined_pthread_spinlock_t + /* Approximate spinlocks with mutexes. */ typedef pthread_mutex_t pthread_spinlock_t; -static inline int +_GL_PTHREAD_INLINE int pthread_spin_init (pthread_spinlock_t *lock, int pshared) { return pthread_mutex_init (lock, NULL); } -static inline int +_GL_PTHREAD_INLINE int pthread_spin_destroy (pthread_spinlock_t *lock) { return pthread_mutex_destroy (lock); } -static inline int +_GL_PTHREAD_INLINE int pthread_spin_lock (pthread_spinlock_t *lock) { return pthread_mutex_lock (lock); } -static inline int +_GL_PTHREAD_INLINE int pthread_spin_trylock (pthread_spinlock_t *lock) { return pthread_mutex_trylock (lock); } -static inline int +_GL_PTHREAD_INLINE int pthread_spin_unlock (pthread_spinlock_t *lock) { return pthread_mutex_unlock (lock); } + +# define GNULIB_defined_pthread_spinlock_t 1 +# endif + #endif -#endif /* _GL_PTHREAD_H_ */ -#endif /* _GL_PTHREAD_H_ */ +_GL_INLINE_HEADER_END + +#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */ +#endif /* _@GUARD_PREFIX@_PTHREAD_H_ */