Source-Changes-HG archive

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

[src/trunk]: src/sys/lib/libkern Don't include <sys/systm.h> because it bring...



details:   https://anonhg.NetBSD.org/src/rev/adebea3476aa
branches:  trunk
changeset: 769991:adebea3476aa
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Sep 29 20:50:09 2011 +0000

description:
Don't include <sys/systm.h> because it brings in too much stuff that
conflicts with standalone code. Instead modify kern_assert() to be like
panic() and call that.

diffstat:

 sys/lib/libkern/kern_assert.c |  12 ++++++------
 sys/lib/libkern/libkern.h     |  16 ++++++++--------
 2 files changed, 14 insertions(+), 14 deletions(-)

diffs (93 lines):

diff -r 539bbb2be1ce -r adebea3476aa sys/lib/libkern/kern_assert.c
--- a/sys/lib/libkern/kern_assert.c     Thu Sep 29 17:40:19 2011 +0000
+++ b/sys/lib/libkern/kern_assert.c     Thu Sep 29 20:50:09 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_assert.c,v 1.1 2010/01/19 22:28:30 pooka Exp $    */
+/*     $NetBSD: kern_assert.c,v 1.2 2011/09/29 20:50:09 christos Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou
@@ -39,14 +39,14 @@
 #endif
 
 void
-kern_assert(const char *t, const char *f, int l, const char *e)
+kern_assert(const char *fmt, ...)
 {
-
+       va_list ap;
 #ifdef _KERNEL
        if (panicstr != NULL)
                return;
 #endif
-
-       panic("kernel %sassertion \"%s\" failed: file \"%s\", line %d",
-           t, e, f, l);
+       va_start(ap, fmt);
+       vpanic(fmt, ap);
+       va_end(ap);
 }
diff -r 539bbb2be1ce -r adebea3476aa sys/lib/libkern/libkern.h
--- a/sys/lib/libkern/libkern.h Thu Sep 29 17:40:19 2011 +0000
+++ b/sys/lib/libkern/libkern.h Thu Sep 29 20:50:09 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: libkern.h,v 1.101 2011/09/27 01:02:39 jym Exp $        */
+/*     $NetBSD: libkern.h,v 1.102 2011/09/29 20:50:09 christos Exp $   */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -37,7 +37,6 @@
 #include <sys/types.h>
 #include <sys/inttypes.h>
 #include <sys/null.h>
-#include <sys/systm.h>
 
 #ifndef LIBKERN_INLINE
 #define LIBKERN_INLINE static __inline
@@ -181,7 +180,7 @@
 #define        assert(e)       ((void)0)
 #else
 #define        assert(e)       (__predict_true((e)) ? (void)0 :                    \
-                           panic(__KASSERTSTR, "", #e, __FILE__, __LINE__))
+                           kern_assert(__KASSERTSTR, "", #e, __FILE__, __LINE__))
 #endif
 
 #ifdef __COVERITY__
@@ -205,11 +204,11 @@
 #define _DIAGASSERT(a) assert(a)
 #define        KASSERTMSG(e, msg, ...)         \
                        (__predict_true((e)) ? (void)0 :                    \
-                           panic(__KASSERTSTR msg, "diagnostic ", #e,      \
+                           kern_assert(__KASSERTSTR msg, "diagnostic ", #e,        \
                                __FILE__, __LINE__, ## __VA_ARGS__))
 
 #define        KASSERT(e)      (__predict_true((e)) ? (void)0 :                    \
-                           panic(__KASSERTSTR, "diagnostic ", #e,          \
+                           kern_assert(__KASSERTSTR, "diagnostic ", #e,            \
                                __FILE__, __LINE__))
 #endif
 
@@ -224,11 +223,11 @@
 #else
 #define        KDASSERTMSG(e, msg, ...)        \
                        (__predict_true((e)) ? (void)0 :                    \
-                           panic(__KASSERTSTR msg, "debugging ", #e,       \
+                           kern_assert(__KASSERTSTR msg, "debugging ", #e,         \
                                __FILE__, __LINE__, ## __VA_ARGS__))
 
 #define        KDASSERT(e)     (__predict_true((e)) ? (void)0 :                    \
-                           panic(__KASSERTSTR, "debugging ", #e,           \
+                           kern_assert(__KASSERTSTR, "debugging ", #e,     \
                                __FILE__, __LINE__))
 #endif
 
@@ -300,7 +299,8 @@
 #define        ffs(x)          __builtin_ffs(x)
 #endif
 
-void    kern_assert(const char *, const char *, int, const char *);
+void    kern_assert(const char *, ...)
+    __attribute__((__format__(__printf__, 1, 2)));
 unsigned int
        bcdtobin(unsigned int);
 unsigned int



Home | Main Index | Thread Index | Old Index