bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

pthread: Fix compilation error on Android


From: Bruno Haible
Subject: pthread: Fix compilation error on Android
Date: Mon, 14 May 2018 01:02:23 +0200
User-agent: KMail/5.1.3 (Linux/4.4.0-119-generic; KDE/5.18.0; x86_64; ; )

This error

In file included from ./signal.h:67:0,
                 from 
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/sys/select.h:36,
                 from ./sys/select.h:100,
                 from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/sys/time.h:37,
                 from ./sys/time.h:39,
                 from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/time.h:33,
                 from ./time.h:41,
                 from /ANDROID_SDK/ndk-bundle/sysroot/usr/include/pthread.h:37,
                 from ./pthread.h:30,
                 from glthread/threadlib.c:27:
/ANDROID_SDK/ndk-bundle/sysroot/usr/include/pthread.h:42:3: error: expected 
identifier before numeric constant
   PTHREAD_MUTEX_NORMAL = 0,
   ^

is a consequence of recursive inclusion of the same file. The fix is to
use the same idiom as in locale.in.h, signal.in.h, stdio.in.h, string.in.h,
sys_socket.in.h, wchar.in.h.


2018-05-13  Bruno Haible  <address@hidden>

        pthread: Fix compilation error on Android.
        * lib/pthread.in.h: Use _GL_ALREADY_INCLUDING_PTHREAD_H to shortcut
        recursive inclusion of this file.

diff --git a/lib/pthread.in.h b/lib/pthread.in.h
index 73a98e2..69d643a 100644
--- a/lib/pthread.in.h
+++ b/lib/pthread.in.h
@@ -17,16 +17,35 @@
 
 /* Written by Paul Eggert and Glen Lenker.  */
 
-#ifndef address@hidden@_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.  */
+
address@hidden@ @NEXT_PTHREAD_H@
+
+#else
+/* Normal invocation convention.  */
+
+#ifndef address@hidden@_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 address@hidden@_PTHREAD_H_
@@ -293,3 +312,4 @@ _GL_INLINE_HEADER_END
 
 #endif /* address@hidden@_PTHREAD_H_ */
 #endif /* address@hidden@_PTHREAD_H_ */
+#endif




reply via email to

[Prev in Thread] Current Thread [Next in Thread]