Module Name: src
Committed By: christos
Date: Thu Sep 29 20:50:09 UTC 2011
Modified Files:
src/sys/lib/libkern: kern_assert.c libkern.h
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/lib/libkern/kern_assert.c
cvs rdiff -u -r1.101 -r1.102 src/sys/lib/libkern/libkern.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/lib/libkern/kern_assert.c
diff -u src/sys/lib/libkern/kern_assert.c:1.1 src/sys/lib/libkern/kern_assert.c:1.2
--- src/sys/lib/libkern/kern_assert.c:1.1 Tue Jan 19 17:28:30 2010
+++ src/sys/lib/libkern/kern_assert.c Thu Sep 29 16:50:09 2011
@@ -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);
}
Index: src/sys/lib/libkern/libkern.h
diff -u src/sys/lib/libkern/libkern.h:1.101 src/sys/lib/libkern/libkern.h:1.102
--- src/sys/lib/libkern/libkern.h:1.101 Mon Sep 26 21:02:39 2011
+++ src/sys/lib/libkern/libkern.h Thu Sep 29 16:50:09 2011
@@ -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 @@ tolower(int ch)
#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 @@ tolower(int ch)
#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 @@ tolower(int ch)
#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 @@ int ffs(int);
#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