From d1c1f3aea9e962382b52d9ec38d28da6b60a2e8f Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 14 May 2018 01:02:02 +0200 Subject: [PATCH] pthread: Fix compilation error on Android. * lib/pthread.in.h: Use _GL_ALREADY_INCLUDING_PTHREAD_H to shortcut recursive inclusion of this file. --- ChangeLog | 6 ++++++ lib/pthread.in.h | 26 +++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30e0ab0dd3..e77208127f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2018-05-13 Bruno Haible + + 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 posix_spawn: Fix compilation error on Android. diff --git a/lib/pthread.in.h b/lib/pthread.in.h index 73a98e2846..69d643af5c 100644 --- a/lib/pthread.in.h +++ b/lib/pthread.in.h @@ -17,16 +17,35 @@ /* 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 + -> -> -> -> + -> . + 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 -- 2.39.5