From 72691d57e79adbf864801cd58f980da2ccc25809 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Thu, 18 Jul 2024 13:06:27 +0200 Subject: [PATCH] stdlib: Don't define print_stack_trace unconditionally. * modules/stack-trace (configure.ac): Invoke gl_MODULE_INDICATOR. * lib/stdlib.in.h (print_stack_trace): Don't define if module 'stack-trace' is not present. * tests/macros.h (print_stack_trace): Define as a fallback if module 'stack-trace' is not present. --- ChangeLog | 9 +++++++++ lib/stdlib.in.h | 14 +++++++++----- modules/stack-trace | 1 + tests/macros.h | 6 ++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8aa53c8792..dbdc2e0740 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2024-07-18 Bruno Haible + + stdlib: Don't define print_stack_trace unconditionally. + * modules/stack-trace (configure.ac): Invoke gl_MODULE_INDICATOR. + * lib/stdlib.in.h (print_stack_trace): Don't define if module + 'stack-trace' is not present. + * tests/macros.h (print_stack_trace): Define as a fallback if module + 'stack-trace' is not present. + 2024-07-18 Bruno Haible stack-trace: Don't use NetBSD's broken libasan. diff --git a/lib/stdlib.in.h b/lib/stdlib.in.h index 3de9eba245..7c6daa58b8 100644 --- a/lib/stdlib.in.h +++ b/lib/stdlib.in.h @@ -1600,12 +1600,16 @@ _GL_WARN_ON_USE (setenv, "setenv is unportable - " # endif #endif -#if @GNULIB_STACK_TRACE@ && @CAN_PRINT_STACK_TRACE@ +#if @GNULIB_STACK_TRACE@ +/* Prints a stack trace of the current thread to standard error, + if possible. */ +# if @CAN_PRINT_STACK_TRACE@ _GL_EXTERN_C void print_stack_trace (void); -#else -# if !GNULIB_defined_print_stack_trace -# define print_stack_trace() /* nothing */ -# define GNULIB_defined_print_stack_trace 1 +# else +# if !GNULIB_defined_print_stack_trace +# define print_stack_trace() /* nothing */ +# define GNULIB_defined_print_stack_trace 1 +# endif # endif #endif diff --git a/modules/stack-trace b/modules/stack-trace index 122845d610..8dfb87908b 100644 --- a/modules/stack-trace +++ b/modules/stack-trace @@ -18,6 +18,7 @@ configure.ac: gl_STACK_TRACE gl_CONDITIONAL([GL_COND_OBJ_STACK_TRACE], [test $CAN_PRINT_STACK_TRACE = 1]) gl_STDLIB_MODULE_INDICATOR([stack-trace]) +gl_MODULE_INDICATOR([stack-trace]) Makefile.am: if GL_COND_OBJ_STACK_TRACE diff --git a/tests/macros.h b/tests/macros.h index 3121b21820..55163c65a3 100644 --- a/tests/macros.h +++ b/tests/macros.h @@ -45,6 +45,12 @@ # define ASSERT_STREAM stderr #endif +/* Define print_stack_trace() to a no-op, if the module 'stack-trace' is not + in use. */ +#if !GNULIB_STACK_TRACE +# define print_stack_trace() /* nothing */ +#endif + /* Exit status of the test. Initialized to EXIT_SUCCESS. Set to EXIT_FAILURE when an ASSERT or ASSERT_NO_STDIO fails. */ -- 2.39.5