commit-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[hurd] 42/53: mach-defpager: add and use synchronized_printf for dprintf


From: Samuel Thibault
Subject: [hurd] 42/53: mach-defpager: add and use synchronized_printf for dprintf
Date: Thu, 20 Mar 2014 02:23:52 +0000

This is an automated email from the git hooks/post-receive script.

sthibault pushed a commit to branch upstream
in repository hurd.

commit 727d2825675e9d67999a15d2e9903bf8af854395
Author: Justus Winter <address@hidden>
Date:   Wed Mar 12 12:20:00 2014 +0100

    mach-defpager: add and use synchronized_printf for dprintf
    
    * mach-defpager/default_pager.c (synchronized_printf): New function.
    (printf_lock): Move to synchronized_printf.
    (dprintf): Use synchronized_printf.
    (ddprintf): Likewise.
---
 mach-defpager/default_pager.c | 29 ++++++++++++++++++-----------
 1 file changed, 18 insertions(+), 11 deletions(-)

diff --git a/mach-defpager/default_pager.c b/mach-defpager/default_pager.c
index df0200d..ebbff60 100644
--- a/mach-defpager/default_pager.c
+++ b/mach-defpager/default_pager.c
@@ -51,6 +51,7 @@
 #include <errno.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdarg.h>
 
 #include <file_io.h>
 
@@ -63,24 +64,30 @@
 
 static char my_name[] = "(default pager):";
 
-static pthread_mutex_t printf_lock = PTHREAD_MUTEX_INITIALIZER;
+static void __attribute__ ((format (printf, 1, 2), unused))
+synchronized_printf (const char *fmt, ...)
+{
+       static pthread_mutex_t printf_lock = PTHREAD_MUTEX_INITIALIZER;
+       va_list ap;
+
+       va_start (ap, fmt);
+       pthread_mutex_lock (&printf_lock);
+
+       vprintf (fmt, ap);
+       fflush (stdout);
+
+       pthread_mutex_unlock (&printf_lock);
+       va_end (ap);
+}
 
 #if 0
-#define dprintf(f, x...)                       \
-  ({ pthread_mutex_lock (&printf_lock);                \
-     printf (f , ##x);                         \
-     fflush (stdout);                          \
-     pthread_mutex_unlock (&printf_lock); })
+#define dprintf(f, x...)       synchronized_printf (f, ##x)
 #else
 #define dprintf(f, x...)
 #endif
 
 #if 0
-#define ddprintf(f, x...)                      \
-  ({ pthread_mutex_lock (&printf_lock);                \
-     printf (f , ##x);                         \
-     fflush (stdout);                          \
-     pthread_mutex_unlock (&printf_lock); })
+#define ddprintf(f, x...)      synchronized_printf (f, ##x)
 #else
 #define ddprintf(f, x...)
 #endif

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-hurd/hurd.git



reply via email to

[Prev in Thread] Current Thread [Next in Thread]