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

MiNT 1.11: faster TRACE() & friends



Here's a MiNT patch, I hope you like it.  It makes the binary a few KB

larger, but I think the speed increase is worth it.

debug.c, mint.h, debug.h (new):
        optimize TRACE, TRACELOW & DEBUG by not actually calling
        Trace, Tracelow and Debug if the debug_level isn't high
        enough; this saves us preparing the stack with parameters that
        will probably never be used.  The new tests in the macros are
        somewhat redundant with the code in the real functions, but
        only if the debug_level is high enough (which means that we
        have enough cycles to waste, anyway).                     --hohmuth

diff -u mint/debug.c:1.4 mint/debug.c:1.5
--- mint/debug.c:1.4	Fri Sep  2 14:59:07 1994
+++ mint/debug.c	Fri Sep  2 14:59:07 1994
@@ -227,11 +227,13 @@
  * Psemaphore, Pmsg, Syield.
  */

+#if 0 /* now in debug.h */
 #define FORCE_LEVEL 0
 #define ALERT_LEVEL 1
 #define DEBUG_LEVEL 2
 #define TRACE_LEVEL 3
 #define LOW_LEVEL 4
+#endif

 /*
  * The inner loop does this: at each newline, the keyboard is polled. If
diff -u /dev/null mint/debug.h:1.1
--- /dev/null	Fri Sep  2 14:59:07 1994
+++ mint/debug.h	Fri Sep  2 14:59:08 1994
@@ -0,0 +1,30 @@
+extern int debug_level;				/* in debug.c */
+extern int debug_logging;			/* in debug.c */
+
+#define FORCE_LEVEL 0
+#define ALERT_LEVEL 1
+#define DEBUG_LEVEL 2
+#define TRACE_LEVEL 3
+#define LOW_LEVEL 4
+
+#ifndef DEBUG_INFO
+
+# define TRACELOW(x)
+# define TRACE(x)
+# define DEBUG(x)
+
+#else                         
+
+# define TRACELOW(s) \
+  do { if (debug_logging || (debug_level >= LOW_LEVEL)) \
+         Tracelow s ; } while(0)
+
+# define TRACE(s) \
+  do { if (debug_logging || (debug_level >= TRACE_LEVEL)) \
+         Trace s ; } while(0)
+
+# define DEBUG(s) \
+  do { if (debug_logging || (debug_level >= DEBUG_LEVEL)) \
+         Debug s ; } while(0)
+
+#endif /* DEBUG_INFO */
diff -u mint/mint.h:1.10 mint/mint.h:1.11
--- mint/mint.h:1.10	Fri Sep  2 14:59:08 1994
+++ mint/mint.h	Fri Sep  2 14:59:08 1994
@@ -247,15 +247,7 @@
 #define DEBUG_INFO
 #endif

-#ifndef DEBUG_INFO
-#define TRACELOW(x)
-#define TRACE(x)
-#define DEBUG(x)
-#else
-#define TRACELOW(x) Tracelow x
-#define TRACE(x) Trace x
-#define DEBUG(x) Debug x
-#endif
+#include "debug.h"

 #define check_addr(x) 0
 #define yield() sleep(READY_Q, 0L)

Regards,
Michael
-- 
Email: hohmuth@inf.tu-dresden.de
WWW:   http://www.inf.tu-dresden.de/~mh1/