summaryrefslogtreecommitdiff
path: root/modules/pthread
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2010-09-22 01:32:19 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2010-09-22 01:33:51 -0700
commit66cc02681886cc3da705d0efb7a30a54bc8ce6b4 (patch)
treee492cb4a94a2723a071e9394be6d4701005eb9f3 /modules/pthread
parent3fdb706a2a7464a81025bfd07d06c867130f9f1f (diff)
downloadgnulib-66cc02681886cc3da705d0efb7a30a54bc8ce6b4.tar.gz
pthread: add to system <pthread.h> instead of replacing it all, for MacOS
* lib/pthread.in.h: Add split double-inclusion guard, and include system <pthread.h> if there is one. Use @@-style as in other .in.h files. Define PTHREAD_COND_INITIALIZER etc. only if system pthread.h doesn't. (pthread_mutexattr_destroy, pthread_mutexattr_init): (pthread_mutexattr_settype, pthread_mutex_trylock): New static inline functions, if there's no system <pthread.h>. (pthread_spinlock_t, pthread_spin_init, pthread_spin_destroy): (pthread_spin_lock, pthread_spin_trylock, pthread_spin_unlock): Approximate with mutexes if the system lacks spinlocks, as in MacOS. * m4/pthread.m4 (gl_PTHREAD_CHECK): Require gl_PTHREAD_DEFAULTS. Add gl_CHECK_NEXT_HEADERS for pthread.h, and support the usual @@-style. Check for spinlocks separately. (gl_PTHREAD_DEFAULTS): New macro. * modules/pthread: Redo to use a more typical style for in.h files.
Diffstat (limited to 'modules/pthread')
-rw-r--r--modules/pthread15
1 files changed, 12 insertions, 3 deletions
diff --git a/modules/pthread b/modules/pthread
index 51d5dbb9d9..6d064649f0 100644
--- a/modules/pthread
+++ b/modules/pthread
@@ -18,9 +18,18 @@ BUILT_SOURCES += $(PTHREAD_H)
# We need the following in order to create <pthread.h> when the system
# doesn't have one that works with the given compiler.
pthread.h: pthread.in.h
- $(AM_V_GEN)ln -f $(srcdir)/pthread.in.h $@ \
- || cp $(srcdir)/pthread.in.h $@
-MOSTLYCLEANFILES += pthread.h
+ $(AM_V_GEN)rm -f $@-t $@ && \
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's|@''HAVE_PTHREAD_H''@|$(HAVE_PTHREAD_H)|g' \
+ -e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
+ -e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
+ -e 's|@''NEXT_PTHREAD_H''@|$(NEXT_PTHREAD_H)|g' \
+ -e 's|@''HAVE_PTHREAD_T''@|$(HAVE_PTHREAD_T)|g' \
+ -e 's|@''HAVE_PTHREAD_SPINLOCK_T''@|$(HAVE_PTHREAD_SPINLOCK_T)|g' \
+ < $(srcdir)/pthread.in.h; \
+ } > $@-t && \
+ mv $@-t $@
+MOSTLYCLEANFILES += pthread.h pthread.h-t
Include:
<pthread.h>