Skip to content

Commit

Permalink
[libunwind] Fflush stderr after each log message
Browse files Browse the repository at this point in the history
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 2ec75a0 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
  • Loading branch information
mstorsjo committed Apr 6, 2023
1 parent a017aef commit a33d5a9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions libunwind/src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a33d5a9

Please sign in to comment.