Skip to contentSkip to conversation

win32: Set unbuffered stdout

PATCH Applied Stefan Weil 2 participants 2 messages Oct 7, 2010 – Oct 9, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 win32: Set unbuffered stdout

Win32 does not support line-buffering, but it allows unbuffered output.

Unbuffered output is a good approximation. For typical output statements which usually end with '\n', it's even identical.

Buffered output is unusable for program traces because of its large delay.

---
 os-win32.c      |    6 ++++++
 qemu-os-win32.h |    3 +--
 2 files changed, 7 insertions(+), 2 deletions(-)
os-win32.c +6 -0
index dd46bf4..3c6f50f 100644
@@ -221,6 +221,12 @@ char *os_find_datadir(const char *argv0)
     return NULL;
 }
 
+void os_set_line_buffering(void)
+{
+    setbuf(stdout, NULL);
+    setbuf(stderr, NULL);
+}
+
 /*
  * Parse OS specific command line options.
  * return 0 if option handled, -1 otherwise
qemu-os-win32.h +1 -2
index 2ff9f45..c63778d 100644
@@ -45,8 +45,7 @@ void os_host_main_loop_wait(int *timeout);
 static inline void os_setup_signal_handling(void) {}
 static inline void os_daemonize(void) {}
 static inline void os_setup_post(void) {}
-/* Win32 doesn't support line-buffering and requires size >= 2 */
-static inline void os_set_line_buffering(void) {}
+void os_set_line_buffering(void);
 static inline void os_set_proc_name(const char *dummy) {}
 
 #if !defined(EPROTONOSUPPORT)
Signature · 1 line
1.7.1
Applied
#1 lore raw

Thanks, applied.

Quoted 51 lines · Stefan Weil

Win32 does not support line-buffering, but it allows unbuffered output.

Unbuffered output is a good approximation. For typical output statements which usually end with '\n', it's even identical.

Buffered output is unusable for program traces because of its large delay.

---
 os-win32.c      |    6 ++++++
 qemu-os-win32.h |    3 +--

 2 files changed, 7 insertions(+), 2 deletions(-)
os-win32.c +6 -0
index dd46bf4..3c6f50f 100644
@@ -221,6 +221,12 @@ char *os_find_datadir(const char *argv0)
     return NULL;
  }
 
+void os_set_line_buffering(void)
+{
+    setbuf(stdout, NULL);
+    setbuf(stderr, NULL);
+}
+
  /*
  * Parse OS specific command line options.
  * return 0 if option handled, -1 otherwise
qemu-os-win32.h +1 -3
index 2ff9f45..c63778d 100644
@@ -45,8 +45,7 @@ void os_host_main_loop_wait(int *timeout);
  static inline void os_setup_signal_handling(void) {}
  static inline void os_daemonize(void) {}
  static inline void os_setup_post(void) {}
-/* Win32 doesn't support line-buffering and requires size >= 2 */
-static inline void os_set_line_buffering(void) {}
+void os_set_line_buffering(void);
  static inline void os_set_proc_name(const char *dummy) {}
 
  #if !defined(EPROTONOSUPPORT)
--

1.7.1