Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc/include Macros expanding to defined() express...



details:   https://anonhg.NetBSD.org/src/rev/1f893b0e310b
branches:  trunk
changeset: 348196:1f893b0e310b
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Oct 08 20:30:54 2016 +0000

description:
Macros expanding to defined() expression is not actually correct ISO C
behavior. Since it is not clear whether someone might decide to define
the macros to random non-1 values, introduce a level of indirection and
count the same of the helper macros.

diffstat:

 sys/arch/sparc/include/cpuconf.h |  26 +++++++++++++++++++++++---
 1 files changed, 23 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r e6c512f98ec1 -r 1f893b0e310b sys/arch/sparc/include/cpuconf.h
--- a/sys/arch/sparc/include/cpuconf.h  Sat Oct 08 20:19:37 2016 +0000
+++ b/sys/arch/sparc/include/cpuconf.h  Sat Oct 08 20:30:54 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: cpuconf.h,v 1.4 2005/12/11 12:19:05 christos Exp $     */
+/*     $NetBSD: cpuconf.h,v 1.5 2016/10/08 20:30:54 joerg Exp $        */
 
 /*
  * Copyright (c) 1992, 1993
@@ -76,8 +76,28 @@
  * Step 1: Count the number of CPU types configured into the kernel.
  */
 #if defined(_KERNEL_OPT)
-#define        CPU_NTYPES      (defined(SUN4) + defined(SUN4C) + \
-                        defined(SUN4M) + defined(SUN4D))
+#ifdef SUN4
+#define        _CPU_NTYPES_SUN4 1
+#else
+#define        _CPU_NTYPES_SUN4 0
+#endif
+#ifdef SUN4C
+#define        _CPU_NTYPES_SUN4C 1
+#else
+#define        _CPU_NTYPES_SUN4C 0
+#endif
+#ifdef SUN4M
+#define        _CPU_NTYPES_SUN4M 1
+#else
+#define        _CPU_NTYPES_SUN4M 0
+#endif
+#ifdef SUN4D
+#define        _CPU_NTYPES_SUN4D 1
+#else
+#define        _CPU_NTYPES_SUN4D 0
+#endif
+#define        CPU_NTYPES      (_CPU_NTYPES_SUN4 + _CPU_NTYPES_SUN4C + \
+                        _CPU_NTYPES_SUN4M + _CPU_NTYPES_SUN4D)
 #else
 #define        CPU_NTYPES      0
 #endif



Home | Main Index | Thread Index | Old Index