]> Savannah Git Hosting - gnulib.git/commitdiff
threads-h: Fix compilation errors in C++ mode on Android.
authorBruno Haible <bruno@clisp.org>
Mon, 9 Jan 2023 18:12:49 +0000 (19:12 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 9 Jan 2023 20:28:13 +0000 (21:28 +0100)
* lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): New macro.

ChangeLog
lib/threads.in.h

index 7554f5ba0300f5964a4ae47157acc07bc5844dcd..84226bb5e737a5736afc91e8f40496d63065ce62 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-01-09  Bruno Haible  <bruno@clisp.org>
+
+       threads-h: Fix compilation errors in C++ mode on Android.
+       * lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): New macro.
+
 2023-01-09  Bruno Haible  <bruno@clisp.org>
 
        aligned-malloc: Don't disturb the module aligned_alloc.
index b1e213fd2cdc1060ab87367ad8a11aebed66a6f2..5786101d8206e58781bc1f21b452c69dbb507676 100644 (file)
 #endif
 @PRAGMA_COLUMNS@
 
+#if defined _GL_ALREADY_INCLUDING_THREADS_H
+/* Special invocation convention:
+   - On Android we have a sequence of nested includes
+     <threads.h> -> <android/legacy_threads_inlines.h>
+     -> <bits/threads_inlines.h> -> "threads.h"
+     In this situation, the functions are not yet declared, therefore we cannot
+     provide the C++ aliases.  */
+
+#@INCLUDE_NEXT@ @NEXT_THREADS_H@
+
+#else
+/* Normal invocation convention.  */
+
 #ifndef _@GUARD_PREFIX@_THREADS_H
 
+#define _GL_ALREADY_INCLUDING_THREADS_H
+
 /* The include_next requires a split double-inclusion guard.  */
 #if @HAVE_THREADS_H@
 # @INCLUDE_NEXT@ @NEXT_THREADS_H@
 #endif
 
+#undef _GL_ALREADY_INCLUDING_THREADS_H
+
 #ifndef _@GUARD_PREFIX@_THREADS_H
 #define _@GUARD_PREFIX@_THREADS_H
 
@@ -662,3 +679,4 @@ _GL_WARN_ON_USE (tss_delete, "tss_delete is unportable - "
 
 #endif /* _@GUARD_PREFIX@_THREADS_H */
 #endif /* _@GUARD_PREFIX@_THREADS_H */
+#endif