summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZheng Da <zhengda1936@gmail.com>2009-12-03 16:46:34 +0100
committerZheng Da <zhengda1936@gmail.com>2009-12-03 16:46:34 +0100
commitb6bc230f90c7ca641f4555647649bdf681a268c1 (patch)
treee99fe924889362233e0c17e42b5bfe8948a800b7
parent09b6164c0b107cae65a48c2e070c83a4da676bec (diff)
Implement panic.
-rw-r--r--libddekit/Makefile2
-rw-r--r--libddekit/include/ddekit/panic.h19
-rw-r--r--libddekit/panic.c29
3 files changed, 18 insertions, 32 deletions
diff --git a/libddekit/Makefile b/libddekit/Makefile
index 59e5c5a9..1203ca38 100644
--- a/libddekit/Makefile
+++ b/libddekit/Makefile
@@ -20,7 +20,7 @@ makemode := library
libname = libddekit
SRCS= condvar.c init.c initcall.c interrupt.c lock.c malloc.c memory.c \
- panic.c pci.c pgtab-old.c pgtab.c printf.c resources.c list.c \
+ pci.c pgtab-old.c pgtab.c printf.c resources.c list.c \
thread.c timer.c kmem.c
LCLHDRS = include/ddekit/condvar.h include/ddekit/lock.h \
include/ddekit/initcall.h include/ddekit/debug.h \
diff --git a/libddekit/include/ddekit/panic.h b/libddekit/include/ddekit/panic.h
index 1468675f..11c46ebb 100644
--- a/libddekit/include/ddekit/panic.h
+++ b/libddekit/include/ddekit/panic.h
@@ -3,14 +3,29 @@
/** \defgroup DDEKit_util */
+#include <stdio.h>
+
/** Panic - print error message and enter the kernel debugger.
* \ingroup DDEKit_util
*/
-void ddekit_panic(char *fmt, ...) __attribute__((noreturn));
+#define ddekit_panic(format, ...) do \
+{ \
+ char buf[1024]; \
+ snprintf (buf, 1024, "%s", format); \
+ fprintf (stderr , buf, ## __VA_ARGS__); \
+ fflush (stderr); \
+ abort (); \
+} while (0)
/** Print a debug message.
* \ingroup DDEKit_util
*/
-void ddekit_debug(char *fmt, ...);
+#define ddekit_debug(format, ...) do \
+{ \
+ char buf[1024]; \
+ snprintf (buf, 1024, "%s: %s\n", __func__, format); \
+ fprintf (stderr , buf, ## __VA_ARGS__); \
+ fflush (stderr); \
+} while (0)
#endif
diff --git a/libddekit/panic.c b/libddekit/panic.c
deleted file mode 100644
index 24ace989..00000000
--- a/libddekit/panic.c
+++ /dev/null
@@ -1,29 +0,0 @@
-#include <l4/dde/ddekit/panic.h>
-#include <l4/dde/ddekit/printf.h>
-
-#include <l4/sys/kdebug.h>
-#include <stdarg.h>
-
-void ddekit_panic(char *fmt, ...) {
- va_list va;
-
- va_start(va, fmt);
- ddekit_vprintf(fmt, va);
- va_end(va);
- ddekit_printf("\n");
-
- while (1)
- enter_kdebug("ddekit_panic()");
-}
-
-void ddekit_debug(char *fmt, ...) {
- va_list va;
-
- va_start(va, fmt);
- ddekit_vprintf(fmt, va);
- va_end(va);
- ddekit_printf("\n");
-
- enter_kdebug("ddekit_debug()");
-}
-