Sun Jan 22 02:57:37 2012 UTC ()
Add CTASSERT_SIGNED() and CTASSERT_UNSIGNED().


(rmind)
diff -r1.104 -r1.105 src/sys/lib/libkern/libkern.h

cvs diff -r1.104 -r1.105 src/sys/lib/libkern/libkern.h (expand / switch to unified diff)

--- src/sys/lib/libkern/libkern.h 2011/11/28 08:05:06 1.104
+++ src/sys/lib/libkern/libkern.h 2012/01/22 02:57:36 1.105
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: libkern.h,v 1.104 2011/11/28 08:05:06 tls Exp $ */ 1/* $NetBSD: libkern.h,v 1.105 2012/01/22 02:57:36 rmind Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -180,26 +180,28 @@ tolower(int ch) @@ -180,26 +180,28 @@ tolower(int ch)
180#define assert(e) ((void)0) 180#define assert(e) ((void)0)
181#else 181#else
182#define assert(e) (__predict_true((e)) ? (void)0 : \ 182#define assert(e) (__predict_true((e)) ? (void)0 : \
183 kern_assert(__KASSERTSTR, "", #e, __FILE__, __LINE__)) 183 kern_assert(__KASSERTSTR, "", #e, __FILE__, __LINE__))
184#endif 184#endif
185 185
186#ifdef __COVERITY__ 186#ifdef __COVERITY__
187#ifndef DIAGNOSTIC 187#ifndef DIAGNOSTIC
188#define DIAGNOSTIC 188#define DIAGNOSTIC
189#endif 189#endif
190#endif 190#endif
191 191
192#define CTASSERT(x) __CTASSERT(x) 192#define CTASSERT(x) __CTASSERT(x)
 193#define CTASSERT_SIGNED(x) __CTASSERT(((typeof(x))-1) < 0)
 194#define CTASSERT_UNSIGNED(x) __CTASSERT(((typeof(x))-1) >= 0)
193 195
194#ifndef DIAGNOSTIC 196#ifndef DIAGNOSTIC
195#define _DIAGASSERT(a) (void)0 197#define _DIAGASSERT(a) (void)0
196#ifdef lint 198#ifdef lint
197#define KASSERTMSG(e, msg, ...) /* NOTHING */ 199#define KASSERTMSG(e, msg, ...) /* NOTHING */
198#define KASSERT(e) /* NOTHING */ 200#define KASSERT(e) /* NOTHING */
199#else /* !lint */ 201#else /* !lint */
200#define KASSERTMSG(e, msg, ...) ((void)0) 202#define KASSERTMSG(e, msg, ...) ((void)0)
201#define KASSERT(e) ((void)0) 203#define KASSERT(e) ((void)0)
202#endif /* !lint */ 204#endif /* !lint */
203#else /* DIAGNOSTIC */ 205#else /* DIAGNOSTIC */
204#define _DIAGASSERT(a) assert(a) 206#define _DIAGASSERT(a) assert(a)
205#define KASSERTMSG(e, msg, ...) \ 207#define KASSERTMSG(e, msg, ...) \