summaryrefslogtreecommitdiff
path: root/libunwind
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2023-04-05 10:18:38 +0300
committerMartin Storsjö <martin@martin.st>2023-04-06 11:07:41 +0300
commita33d5a9939aa3c0bcdb0f951c0bc4b96071bda2c (patch)
tree7d31c3be5ea2e0bb1353f2d4444104c82c4c26d9 /libunwind
parenta017aefeac9c7128b5fd702098381abc09508e45 (diff)
downloadllvm-a33d5a9939aa3c0bcdb0f951c0bc4b96071bda2c.tar.gz
[libunwind] Fflush stderr after each log message
In most configs, stderr is line buffered by default, but in some cases on Windows (running in git bash, or running in Wine) stderr can end up fully buffered. See 2ec75a0869ab01fa9caf310e8a31eb7716182d30 for a similar change for the output from lit itself. This has no effect on libunwind when the log messages aren't enabled via the environment variables. Differential Revision: https://reviews.llvm.org/D147632
Diffstat (limited to 'libunwind')
-rw-r--r--libunwind/src/config.h12
1 files changed, 8 insertions, 4 deletions
diff --git a/libunwind/src/config.h b/libunwind/src/config.h
index 4bbac951624f..6707d591361d 100644
--- a/libunwind/src/config.h
+++ b/libunwind/src/config.h
@@ -162,10 +162,14 @@
#define _LIBUNWIND_LOG0(msg)
#define _LIBUNWIND_LOG(msg, ...)
#else
-#define _LIBUNWIND_LOG0(msg) \
- fprintf(stderr, "libunwind: " msg "\n")
-#define _LIBUNWIND_LOG(msg, ...) \
- fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__)
+#define _LIBUNWIND_LOG0(msg) do { \
+ fprintf(stderr, "libunwind: " msg "\n"); \
+ fflush(stderr); \
+ } while (0)
+#define _LIBUNWIND_LOG(msg, ...) do { \
+ fprintf(stderr, "libunwind: " msg "\n", __VA_ARGS__); \
+ fflush(stderr); \
+ } while (0)
#endif
#if defined(NDEBUG)