From 4f9d013f1be4faec16456f505d4d69b08ce891de Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Tue, 24 Dec 2024 11:22:40 +0100 Subject: [PATCH] threads-h: Support several gnulib-tool invocations better. * lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): Rename to a macro that depends on GUARD_PREFIX. (struct thrd_with_exitcode): Avoid duplicate definition. --- ChangeLog | 7 +++++++ lib/threads.in.h | 11 +++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fcf94b367c..e51329096c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2024-12-24 Bruno Haible + + threads-h: Support several gnulib-tool invocations better. + * lib/threads.in.h (_GL_ALREADY_INCLUDING_THREADS_H): Rename to a macro + that depends on GUARD_PREFIX. + (struct thrd_with_exitcode): Avoid duplicate definition. + 2024-12-24 Bruno Haible sys_socket: Support several gnulib-tool invocations better. diff --git a/lib/threads.in.h b/lib/threads.in.h index b4f5b65c63..a0ff2cb951 100644 --- a/lib/threads.in.h +++ b/lib/threads.in.h @@ -20,7 +20,7 @@ #endif @PRAGMA_COLUMNS@ -#if defined _GL_ALREADY_INCLUDING_THREADS_H +#if defined _@GUARD_PREFIX@_ALREADY_INCLUDING_THREADS_H /* Special invocation convention: - On Android we have a sequence of nested includes -> @@ -35,14 +35,14 @@ #ifndef _@GUARD_PREFIX@_THREADS_H -#define _GL_ALREADY_INCLUDING_THREADS_H +#define _@GUARD_PREFIX@_ALREADY_INCLUDING_THREADS_H /* The include_next requires a split double-inclusion guard. */ #if @HAVE_THREADS_H@ # @INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_AS_FIRST_DIRECTIVE_THREADS_H@ #endif -#undef _GL_ALREADY_INCLUDING_THREADS_H +#undef _@GUARD_PREFIX@_ALREADY_INCLUDING_THREADS_H #ifndef _@GUARD_PREFIX@_THREADS_H #define _@GUARD_PREFIX@_THREADS_H @@ -144,6 +144,7 @@ typedef pthread_t thrd_t; #endif #if @BROKEN_THRD_START_T@ || @BROKEN_THRD_JOIN@ /* Need to override thrd_t, to make thrd_join work. */ +# if !defined GNULIB_defined_struct_thrd_with_exitcode struct thrd_with_exitcode { thrd_t volatile tid; @@ -151,7 +152,9 @@ struct thrd_with_exitcode int volatile exitcode; }; typedef struct thrd_with_exitcode *rpl_thrd_t; -# define thrd_t rpl_thrd_t +# define thrd_t rpl_thrd_t +# define GNULIB_defined_struct_thrd_with_exitcode 1 +# endif #endif /* Type of the main function of a thread. */ #if !@HAVE_THREADS_H@ || @BROKEN_THRD_START_T@ -- 2.39.5