diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-09-14 19:10:50 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1997-09-14 19:10:50 +0000 |
commit | 9691107fcf80cbc251201589babc198cdcb55d54 (patch) | |
tree | 9674f42c89f221db2e7abfd7bb3b5e718931f563 | |
parent | bd7544914aa4c8ec96723bbdd0a5885a7f88993f (diff) |
From NetBSD: assert stuff
-rw-r--r-- | sys/lib/libkern/libkern.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h index dbdea5cb6d4..4e5b89a5e13 100644 --- a/sys/lib/libkern/libkern.h +++ b/sys/lib/libkern/libkern.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libkern.h,v 1.11 1997/05/05 14:35:09 millert Exp $ */ +/* $OpenBSD: libkern.h,v 1.12 1997/09/14 19:10:49 niklas Exp $ */ /* $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $ */ /*- @@ -115,7 +115,45 @@ abs(j) } #endif +#ifdef NDEBUG /* tradition! */ +#define assert(e) ((void)0) +#else +#ifdef __STDC__ +#define assert(e) ((e) ? (void)0 : \ + __assert("", __FILE__, __LINE__, #e)) +#else +#define assert(e) ((e) ? (void)0 : \ + __assert("", __FILE__, __LINE__, "e")) +#endif +#endif + +#ifndef DIAGNOSTIC +#define KASSERT(e) ((void)0) +#else +#ifdef __STDC__ +#define KASSERT(e) ((e) ? (void)0 : \ + __assert("diagnostic ", __FILE__, __LINE__, #e)) +#else +#define KASSERT(e) ((e) ? (void)0 : \ + __assert("diagnostic ", __FILE__, __LINE__, "e")) +#endif +#endif + +#ifndef DEBUG +#define KDASSERT(e) ((void)0) +#else +#ifdef __STDC__ +#define KDASSERT(e) ((e) ? (void)0 : \ + __assert("debugging ", __FILE__, __LINE__, #e)) +#else +#define KDASSERT(e) ((e) ? (void)0 : \ + __assert("debugging ", __FILE__, __LINE__, "e")) +#endif +#endif + /* Prototypes for non-quad routines. */ +void __assert __P((const char *, const char *, int, const char *)) + __attribute__ ((__noreturn__)); int bcmp __P((const void *, const void *, size_t)); int ffs __P((int)); int locc __P((int, char *, u_int)); |