summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--share/man/man9/kern.916
-rw-r--r--sys/lib/libkern/libkern.h5
2 files changed, 18 insertions, 3 deletions
diff --git a/share/man/man9/kern.9 b/share/man/man9/kern.9
index c1c4faa7171..b12f83435d0 100644
--- a/share/man/man9/kern.9
+++ b/share/man/man9/kern.9
@@ -1,4 +1,4 @@
-.\" $OpenBSD: kern.9,v 1.16 2013/06/04 19:27:08 schwarze Exp $
+.\" $OpenBSD: kern.9,v 1.17 2013/06/08 19:06:51 sf Exp $
.\"
.\" Copyright (c) 2002, 2003 CubeSoft Communications, Inc.
.\" <http://www.csoft.org>
@@ -24,7 +24,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd $Mdocdate: June 4 2013 $
+.Dd $Mdocdate: June 8 2013 $
.Dt KERN 9
.Os
.Sh NAME
@@ -108,6 +108,18 @@ enabled.
tests are only included if the kernel has
.Dv DEBUG
enabled.
+.Pp
+.nr nS 1
+.Fn CTASSERT "CONDITION"
+.nr nS 0
+.Pp
+This macro causes a compile time error if the given condition evaluates to
+false.
+Its main purpose is to verify assertions about type and struct sizes that
+would otherwise make the code fail at run time.
+.Fn CTASSERT
+can be used in global scope or at the start of blocks, where variable
+declarations are allowed.
.Sh BYTE STRINGS
.nr nS 1
.Ft int
diff --git a/sys/lib/libkern/libkern.h b/sys/lib/libkern/libkern.h
index a2e6efccd3f..cb9817bce7f 100644
--- a/sys/lib/libkern/libkern.h
+++ b/sys/lib/libkern/libkern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libkern.h,v 1.29 2012/04/26 01:22:31 matthew Exp $ */
+/* $OpenBSD: libkern.h,v 1.30 2013/06/08 19:06:50 sf Exp $ */
/* $NetBSD: libkern.h,v 1.7 1996/03/14 18:52:08 christos Exp $ */
/*-
@@ -138,6 +138,9 @@ abs(int j)
#endif
#endif
+#define CTASSERT(x) extern char _ctassert[(x) ? 1 : -1 ] \
+ __attribute__((__unused__))
+
/* Prototypes for non-quad routines. */
void __assert(const char *, const char *, int, const char *)
__attribute__ ((__noreturn__));