[syslinux:elflink] dprintf: add the ability to log to stdio

syslinux-bot for H. Peter Anvin hpa at zytor.com
Fri May 18 16:06:03 PDT 2012


Commit-ID:  df61c3b05b3a42b4202b74c1239576103b153e50
Gitweb:     http://www.syslinux.org/commit/df61c3b05b3a42b4202b74c1239576103b153e50
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Mon, 20 Jun 2011 21:19:17 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Fri, 18 May 2012 16:03:19 -0700

dprintf: add the ability to log to stdio

Add the ability to redirect dprintf to stdio when there is no other
choice.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

Resolved Conflicts:

	com32/lib/dprintf.c
	com32/lib/vdprintf.c

---
 com32/include/dprintf.h |   20 +++++++++++++++++---
 com32/lib/dprintf.c     |    5 +----
 com32/lib/vdprintf.c    |    6 +++---
 3 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/com32/include/dprintf.h b/com32/include/dprintf.h
index 30a21ad..4bdf7a7 100644
--- a/com32/include/dprintf.h
+++ b/com32/include/dprintf.h
@@ -7,15 +7,29 @@
 
 #ifdef DEBUG
 
-#include <stdio.h>
+# include <stdio.h>
 
+# ifdef DEBUG_STDIO
+#  define dprintf  printf
+#  define vdprintf vprintf
+# else
 void dprintf(const char *, ...);
 void vdprintf(const char *, va_list);
+# endif
+
+# if DEBUG >= 2
+/* Really verbose debugging... */
+#  define dprintf2  dprintf
+#  define vdprintf2 vdprintf
+# else
+#  define dprintf2(fmt, ...)	((void)(0))
+#  define vdprintf2(fmt, ap)	((void)(0))
+# endif
 
 #else
 
-#define dprintf(fmt, ...)	((void)(0))
-#define vdprintf(fmt, ap)	((void)(0))
+# define dprintf(fmt, ...)	((void)(0))
+# define vdprintf(fmt, ap)	((void)(0))
 
 #endif /* DEBUG */
 
diff --git a/com32/lib/dprintf.c b/com32/lib/dprintf.c
index 869f07f..4d80204 100644
--- a/com32/lib/dprintf.c
+++ b/com32/lib/dprintf.c
@@ -4,11 +4,9 @@
 
 #include <stdio.h>
 #include <stdarg.h>
-
-#ifdef DEBUG
-
 #include <dprintf.h>
 
+#ifndef dprintf
 void dprintf(const char *format, ...)
 {
     va_list ap;
@@ -17,5 +15,4 @@ void dprintf(const char *format, ...)
     vdprintf(format, ap);
     va_end(ap);
 }
-
 #endif
diff --git a/com32/lib/vdprintf.c b/com32/lib/vdprintf.c
index d4dc974..a48f2eb 100644
--- a/com32/lib/vdprintf.c
+++ b/com32/lib/vdprintf.c
@@ -2,8 +2,6 @@
  * vdprintf.c
  */
 
-#ifdef DEBUG
-
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
@@ -14,6 +12,8 @@
 
 #include <dprintf.h>
 
+#ifndef vdprintf
+
 #define BUFFER_SIZE	4096
 
 enum serial_port_regs {
@@ -115,4 +115,4 @@ void vdprintf(const char *format, va_list ap)
 	debug_putc(*p++);
 }
 
-#endif /* DEBUG */
+#endif /* vdprintf */


More information about the Syslinux-commits mailing list