]> Savannah Git Hosting - gnulib.git/commitdiff
pthread: Fix compilation error on Android.
authorBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 23:02:02 +0000 (01:02 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 13 May 2018 23:02:02 +0000 (01:02 +0200)
* lib/pthread.in.h: Use _GL_ALREADY_INCLUDING_PTHREAD_H to shortcut
recursive inclusion of this file.

ChangeLog
lib/pthread.in.h

index 30e0ab0dd36a752721ea5eb8ab3eeed43fb08a03..e77208127fa3d2ff83a41285ca8d741fe7d2830c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2018-05-13  Bruno Haible  <bruno@clisp.org>
+
+       pthread: Fix compilation error on Android.
+       * lib/pthread.in.h: Use _GL_ALREADY_INCLUDING_PTHREAD_H to shortcut
+       recursive inclusion of this file.
+
 2018-05-13  Bruno Haible  <bruno@clisp.org>
 
        posix_spawn: Fix compilation error on Android.
index 73a98e28468a2d595c5732d28c7ec50b45e6895e..69d643af5cdc9754c2e98e57ac8cfe492d2b6e70 100644 (file)
 
 /* Written by Paul Eggert and Glen Lenker.  */
 
-#ifndef _@GUARD_PREFIX@_PTHREAD_H_
-
 #if __GNUC__ >= 3
 @PRAGMA_SYSTEM_HEADER@
 #endif
 @PRAGMA_COLUMNS@
 
-/* The include_next requires a split double-inclusion guard.  */
+#if defined _GL_ALREADY_INCLUDING_PTHREAD_H
+/* Special invocation convention:
+   On Android, we have a sequence of nested includes
+   <pthread.h> -> <time.h> -> <sys/time.h> -> <sys/select.h> ->
+   <signal.h> -> <pthread.h>.
+   In this situation, PTHREAD_COND_INITIALIZER is not yet defined,
+   therefore we should not attempt to define PTHREAD_MUTEX_NORMAL etc.  */
+
+#@INCLUDE_NEXT@ @NEXT_PTHREAD_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef _@GUARD_PREFIX@_PTHREAD_H_
+
 #if @HAVE_PTHREAD_H@
+
+# define _GL_ALREADY_INCLUDING_PTHREAD_H
+
+/* The include_next requires a split double-inclusion guard.  */
 # @INCLUDE_NEXT@ @NEXT_PTHREAD_H@
+
+# undef _GL_ALREADY_INCLUDING_PTHREAD_H
+
 #endif
 
 #ifndef _@GUARD_PREFIX@_PTHREAD_H_
@@ -293,3 +312,4 @@ _GL_INLINE_HEADER_END
 
 #endif /* _@GUARD_PREFIX@_PTHREAD_H_ */
 #endif /* _@GUARD_PREFIX@_PTHREAD_H_ */
+#endif