]> Savannah Git Hosting - gnulib.git/commitdiff
stdlib: Don't define print_stack_trace unconditionally.
authorBruno Haible <bruno@clisp.org>
Thu, 18 Jul 2024 11:06:27 +0000 (13:06 +0200)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jul 2024 11:06:27 +0000 (13:06 +0200)
* 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
lib/stdlib.in.h
modules/stack-trace
tests/macros.h

index 8aa53c8792834726233af6df579387ff076b4441..dbdc2e0740b11bd39437d2ec9463e6051d20a111 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-07-18  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        stack-trace: Don't use NetBSD's broken libasan.
index 3de9eba245a12e86d296f01c4b6ae934f41dafc6..7c6daa58b8b33201943e6b8291f0853599e99538 100644 (file)
@@ -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
 
index 122845d6108d455e90e44ba7f0fcc0ed80e91af3..8dfb87908b1e016f28e0a1db722fe93ac0f9cdfe 100644 (file)
@@ -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
index 3121b218203e1f97ed29931412d62232d87e9ac4..55163c65a3aaff8aa3168bf2a958f53d2e1beae2 100644 (file)
 # 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.  */