Source-Changes-HG archive

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

[src/trunk]: src/sys/sys For compilers without __COUNTER__, make the ctassert...



details:   https://anonhg.NetBSD.org/src/rev/8ebfac51f936
branches:  trunk
changeset: 327671:8ebfac51f936
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Mar 13 20:36:01 2014 +0000

description:
For compilers without __COUNTER__, make the ctassert name contain
__INCLUDE_LEVEL__ ## _ ## __LINE__.  It's not perfect, but at least it's
better than just __LINE__ since it avoids collisions between .c's and .h's.

Incidentally, why does half of the kernel call CTASSERT() and the
other half __CTASSERT()?

diffstat:

 sys/sys/cdefs.h |  9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diffs (24 lines):

diff -r d00cc942aa9d -r 8ebfac51f936 sys/sys/cdefs.h
--- a/sys/sys/cdefs.h   Thu Mar 13 19:33:23 2014 +0000
+++ b/sys/sys/cdefs.h   Thu Mar 13 20:36:01 2014 +0000
@@ -1,7 +1,6 @@
-/*     $NetBSD: cdefs.h,v 1.118 2014/02/05 01:59:58 matt Exp $ */
+/*     $NetBSD: cdefs.h,v 1.119 2014/03/13 20:36:01 pooka Exp $        */
 
-/*
- * Copyright (c) 1991, 1993
+/* * Copyright (c) 1991, 1993
  *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
@@ -146,7 +145,9 @@
 #ifdef __COUNTER__
 #define        __CTASSERT(x)           __CTASSERT0(x, __ctassert, __COUNTER__)
 #else
-#define        __CTASSERT(x)           __CTASSERT0(x, __ctassert, __LINE__)
+#define        __CTASSERT(x)           __CTASSERT99(x, __INCLUDE_LEVEL__, __LINE__)
+#define        __CTASSERT99(x, a, b)   __CTASSERT0(x, __CONCAT(__ctassert,a), \
+                                              __CONCAT(_,b))
 #endif
 #define        __CTASSERT0(x, y, z)    __CTASSERT1(x, y, z) 
 #define        __CTASSERT1(x, y, z)    typedef char y ## z[/*CONSTCOND*/(x) ? 1 : -1] __unused



Home | Main Index | Thread Index | Old Index