[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
stdlib: Don't define print_stack_trace unconditionally
From: |
Bruno Haible |
Subject: |
stdlib: Don't define print_stack_trace unconditionally |
Date: |
Thu, 18 Jul 2024 13:24:51 +0200 |
Yesterday I renamed _gl_pre_abort() to print_stack_trace(). But the latter
is a symbol that could collide with some symbol defined by the application,
and should therefore not be defined by gnulib's <stdlib.h> override
unconditionally. This patch fixes that.
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.
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. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- stdlib: Don't define print_stack_trace unconditionally,
Bruno Haible <=