>From ede58b7442f9ff1e63cb5e6c391a039d8f00dc79 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 9 Jan 2023 19:12:49 +0100 Subject: [PATCH 1/2] threads-h: Fix compilation errors in C++ mode on Android. * lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): New macro. --- ChangeLog | 5 +++++ lib/threads.in.h | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7554f5ba03..84226bb5e7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-01-09 Bruno Haible + + 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 aligned-malloc: Don't disturb the module aligned_alloc. diff --git a/lib/threads.in.h b/lib/threads.in.h index b1e213fd2c..5786101d82 100644 --- a/lib/threads.in.h +++ b/lib/threads.in.h @@ -20,13 +20,30 @@ #endif @PRAGMA_COLUMNS@ +#if defined _GL_ALREADY_INCLUDING_THREADS_H +/* Special invocation convention: + - On Android we have a sequence of nested includes + -> + -> -> "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 -- 2.34.1