[libunwind] [libunwind] Remove unnecessary dependencies on fprintf and stdio.h for increased baremetal friendliness (PR #72040)

Michael Kenzel via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 18 12:38:35 PST 2025


================
@@ -223,6 +221,41 @@
     } while (0)
 #endif
 
+#define _LIBUNWIND_TRACING_COMPACT_UNWIND (0)
+#if !_LIBUNWIND_TRACING_COMPACT_UNWIND
+#define _LIBUNWIND_TRACE_COMPACT_UNWIND0(msg)
+#define _LIBUNWIND_TRACE_COMPACT_UNWIND(msg, ...)
+#else
+#define _LIBUNWIND_TRACE_COMPACT_UNWIND0(msg)                                  \
+  do {                                                                         \
+    fprintf(stderr, msg);                                                      \
+  } while (0)
+#define _LIBUNWIND_TRACE_COMPACT_UNWIND(msg, ...)                              \
+  do {                                                                         \
+    fprintf(stderr, msg, __VA_ARGS__);                                         \
+  } while (0)
----------------
michael-kenzel wrote:

It probably would; the reason why I did it the way I did was consistency with the existing `_LIBUNWIND_LOG`/`_LIBUNWIND_LOG0` macros. I guess best would be to just rewrite those in your suggested way as well. But maybe this should be done in a separate PR to keep this one focused on just replacing `fprintf`?

https://github.com/llvm/llvm-project/pull/72040


More information about the cfe-commits mailing list