NetBSD Problem Report #9056

Received: (qmail 2785 invoked from network); 26 Dec 1999 11:38:46 -0000
Message-Id: <199912261138.FAA04844@yerfable.metonymy.com>
Date: Sun, 26 Dec 1999 05:38:44 -0600 (CST)
From: Dave Huang <khym@bga.com>
Reply-To: khym@bga.com
To: gnats-bugs@gnats.netbsd.org
Subject: C++ files can't #include <sys/param.h>
X-Send-Pr-Version: 3.95

>Number:         9056
>Category:       port-alpha
>Synopsis:       C++ files can't #include <sys/param.h>
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    thorpej
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Dec 26 03:39:00 +0000 1999
>Closed-Date:    Sun Mar 05 18:46:25 +0000 2000
>Last-Modified:  Sun Mar 05 18:46:45 +0000 2000
>Originator:     Dave Huang
>Release:        NetBSD-current as of December 25, 1999
>Organization:
Name: Dave Huang     |   Mammal, mammal / their names are called /
INet: khym@bga.com   |   they raise a paw / the bat, the cat /
FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
Dahan: Hani G Y+C 24 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++
>Environment:

System: NetBSD yerfable.metonymy.com 1.4P NetBSD 1.4P (YERFABLE) #57: Sun Dec 19 23:06:35 CST 1999 khym@yerfable.metonymy.com:/usr/src.local/sys/arch/alpha/compile/YERFABLE alpha


>Description:
On the alpha, /usr/include/sys/param.h includes a couple of headers
that have inlined functions (machine/alpha_cpu.h and
machine/atomic.h). They're K&R style function declarations though,
which C++ doesn't support, so any C++ file that includes that header
won't compile.

>How-To-Repeat:
% echo "#include <sys/param.h>" > gorp.c
% c++ -c gorp.c
In file included from /usr/include/machine/cpu.h:93,
                 from /usr/include/machine/param.h:54,
                 from /usr/include/sys/param.h:147,
                 from gorp.c:1:
/usr/include/machine/alpha_cpu.h:433: `ctx' was not declared in this scope
/usr/include/machine/alpha_cpu.h:434: syntax error before `unsigned'

>Fix:
Well, ANSIfying it would do the trick, but we seem to like to have a
semblance of K&R compatibility... So I guess doing the "#if __STDC__"
thing (like in sys/isofs/cd9660/iso.h) would work.

The files in sys/arch/alpha/include that have inline functions are:
alpha_cpu.h atomic.h bwx.h intr.h lock.h pmap.h. Of those, intr.h and
pmap.h's inline functions are inside an #ifdef _KERNEL, so I didn't
bother messing with them (I seem to remember seeing someone on one of
the lists mention that C++ code could be in the kernel... well if that
ever happens, someone can fix those header files :).  lock.h never
gets installed into /usr/include/machine, so I didn't do anything with
it either (but maybe it should be installed? /usr/include/sys/lock.h
will #include <machine/lock.h> if MULTIPROCESSOR is #defined).

So, here are patches for alpha_cpu.h, atomic.h, and bwx.h:

diff -ur /usr/src/sys/arch/alpha/include/alpha_cpu.h ./alpha_cpu.h
--- /usr/src/sys/arch/alpha/include/alpha_cpu.h	Fri Dec  3 06:09:42 1999
+++ ./alpha_cpu.h	Sun Dec 26 05:13:51 1999
@@ -430,8 +430,12 @@
 }

 static __inline unsigned long
+#if __STDC__
+alpha_pal_swpctx(unsigned long ctx)
+#else
 alpha_pal_swpctx(ctx)
 	unsigned long ctx;
+#endif
 {
 	register unsigned long a0 __asm("$16") = ctx;
 	register unsigned long v0 __asm("$0");
@@ -446,8 +450,12 @@
 }

 static __inline unsigned long
+#if __STDC__
+alpha_pal_swpipl(unsigned long ipl)
+#else
 alpha_pal_swpipl(ipl)
 	unsigned long ipl;
+#endif
 {
 	register unsigned long a0 __asm("$16") = ipl;
 	register unsigned long v0 __asm("$0");
@@ -462,9 +470,13 @@
 }

 static __inline void
+#if __STDC__
+alpha_pal_tbi(unsigned long op, vaddr_t va)
+#else
 alpha_pal_tbi(op, va)
 	unsigned long op;
 	vaddr_t va;
+#endif
 {
 	register unsigned long a0 __asm("$16") = op;
 	register unsigned long a1 __asm("$17") = va;
@@ -491,8 +503,12 @@
 }

 static __inline void
+#if __STDC__
+alpha_pal_wrfen(unsigned long onoff)
+#else
 alpha_pal_wrfen(onoff)
 	unsigned long onoff;
+#endif
 {
 	register unsigned long a0 __asm("$16") = onoff;

@@ -504,8 +520,12 @@
 }

 static __inline void
+#if __STDC__
+alpha_pal_wripir(unsigned long cpu_id)
+#else
 alpha_pal_wripir(cpu_id)
 	unsigned long cpu_id;
+#endif
 {
 	register unsigned long a0 __asm("$16") = cpu_id;

@@ -517,8 +537,12 @@
 }

 static __inline void
+#if __STDC__
+alpha_pal_wrusp(unsigned long usp)
+#else
 alpha_pal_wrusp(usp)
 	unsigned long usp;
+#endif
 {
 	register unsigned long a0 __asm("$16") = usp;

@@ -530,8 +554,12 @@
 }

 static __inline void
+#if __STDC__
+alpha_pal_wrmces(unsigned long mces)
+#else
 alpha_pal_wrmces(mces)
 	unsigned long mces;
+#endif
 {
 	register unsigned long a0 __asm("$16") = mces;

@@ -543,8 +571,12 @@
 }

 static __inline void
+#if __STDC__
+alpha_pal_wrval(unsigned long val)
+#else
 alpha_pal_wrval(val)
 	unsigned long val;
+#endif
 {
 	register unsigned long a0 __asm("$16") = val;

diff -ur /usr/src/sys/arch/alpha/include/atomic.h ./atomic.h
--- /usr/src/sys/arch/alpha/include/atomic.h	Fri Dec  3 06:09:42 1999
+++ ./atomic.h	Sun Dec 26 05:16:02 1999
@@ -64,9 +64,13 @@
  *	Atomically set bits in a quadword.
  */
 static __inline void
+#if __STDC__
+alpha_atomic_setbits_q(__volatile unsigned long *ulp, unsigned long v)
+#else
 alpha_atomic_setbits_q(ulp, v)
 	__volatile unsigned long *ulp;
 	unsigned long v;
+#endif
 {
 	unsigned long t0;

@@ -91,9 +95,13 @@
  *	Atomically clear bits in a quadword.
  */
 static __inline void
+#if __STDC__
+alpha_atomic_clearbits_q(__volatile unsigned long *ulp, unsigned long v)
+#else
 alpha_atomic_clearbits_q(ulp, v)
 	__volatile unsigned long *ulp;
 	unsigned long v;
+#endif
 {
 	unsigned long t0;

@@ -118,9 +126,13 @@
  *	Atomically add a value to a quadword.
  */
 static __inline void
+#if __STDC__
+alpha_atomic_add_q(__volatile unsigned long *ulp, unsigned long v)
+#else
 alpha_atomic_add_q(ulp, v)
 	__volatile unsigned long *ulp;
 	unsigned long v;
+#endif
 {
 	unsigned long t0;

@@ -145,9 +157,13 @@
  *	Atomically subtract a value from a quadword.
  */
 static __inline void
+#if __STDC__
+alpha_atomic_sub_q(__volatile unsigned long *ulp, unsigned long v)
+#else
 alpha_atomic_sub_q(ulp, v)
 	__volatile unsigned long *ulp;
 	unsigned long v;
+#endif
 {
 	unsigned long t0;

@@ -172,9 +188,13 @@
  *	Atomically load and latch a quadword value.
  */
 static __inline unsigned long
+#if __STDC__
+alpha_atomic_loadlatch_q(__volatile unsigned long *ulp, unsigned long v)
+#else
 alpha_atomic_loadlatch_q(ulp, v)
 	__volatile unsigned long *ulp;
 	unsigned long v;
+#endif
 {
 	unsigned long t0, v0;

diff -ur /usr/src/sys/arch/alpha/include/bwx.h ./bwx.h
--- /usr/src/sys/arch/alpha/include/bwx.h	Thu Dec  2 13:41:40 1999
+++ ./bwx.h	Sun Dec 26 05:24:04 1999
@@ -62,8 +62,12 @@
 	__attribute__((__unused__));

 static __inline u_int8_t
+#if __STDC__
+alpha_ldbu(__volatile u_int8_t *a0)
+#else
 alpha_ldbu(a0)
 	__volatile u_int8_t *a0;
+#endif
 {
 	u_int8_t v0;

@@ -75,8 +79,12 @@
 }

 static __inline u_int16_t
+#if __STDC__
+alpha_ldwu(__volatile u_int16_t *a0)
+#else
 alpha_ldwu(a0)
 	__volatile u_int16_t *a0;
+#endif
 {
 	u_int16_t v0;

@@ -88,9 +96,13 @@
 }

 static __inline void
+#if __STDC__
+alpha_stb(__volatile u_int8_t *a0, u_int8_t a1)
+#else
 alpha_stb(a0, a1)
 	__volatile u_int8_t *a0;
 	u_int8_t a1;
+#endif
 {

 	__asm __volatile("stb %1, %0"
@@ -99,9 +111,13 @@
 }

 static __inline void
+#if __STDC__
+alpha_stw(__volatile u_int16_t *a0, u_int16_t a1)
+#else
 alpha_stw(a0, a1)
 	__volatile u_int16_t *a0;
 	u_int16_t a1;
+#endif
 {

 	__asm __volatile("stw %1, %0"
@@ -110,8 +126,12 @@
 }

 static __inline u_int8_t
+#if __STDC__
+alpha_sextb(u_int8_t a0)
+#else
 alpha_sextb(a0)
 	u_int8_t a0;
+#endif
 {
 	u_int8_t v0;

@@ -123,8 +143,12 @@
 }

 static __inline u_int16_t
+#if __STDC__
+alpha_sextw(u_int16_t a0)
+#else
 alpha_sextw(a0)
 	u_int16_t a0;
+#endif
 {
 	u_int16_t v0;


>Release-Note:
>Audit-Trail:

From: "Martin Husemann" <martin@rumolt.teuto.de>
To: <khym@bga.com>, <gnats-bugs@gnats.netbsd.org>
Cc:  Subject: RE: port-alpha/9056: C++ files can't #include <sys/param.h>
Date: Sun, 26 Dec 1999 13:55:38 +0100

 Wouldn't "#ifdef __cplusplus" be the right thing to do here? We could use
 real C++ "inline" attributes then.


 Martin


From: Dave Huang <khym@bga.com>
To: Martin Husemann <martin@rumolt.teuto.de>
Cc: gnats-bugs@gnats.netbsd.org
Subject: RE: port-alpha/9056: C++ files can't #include <sys/param.h>
Date: Sun, 26 Dec 1999 08:45:13 -0600 (CST)

 On Sun, 26 Dec 1999, Martin Husemann wrote:
 > Wouldn't "#ifdef __cplusplus" be the right thing to do here? We could use
 > real C++ "inline" attributes then.

 Well, <sys/cdefs.h> already #defines __inline to be inline #ifdef
 __cplusplus, and cdefs.h is included just about everywhere (since it
 defines the ubiquitous __P() macro).
 -- 
 Name: Dave Huang     |   Mammal, mammal / their names are called /
 INet: khym@bga.com   |   they raise a paw / the bat, the cat /
 FurryMUCK: Dahan     |   dolphin and dog / koala bear and hog -- TMBG
 Dahan: Hani G Y+C 24 Y++ L+++ W- C++ T++ A+ E+ S++ V++ F- Q+++ P+ B+ PA+ PL++

Responsible-Changed-From-To: port-alpha-maintainer->thorpej 
Responsible-Changed-By: thorpej 
Responsible-Changed-When: Tue Jan 25 15:01:30 PST 2000 
Responsible-Changed-Why:  
Bug is my fault, I'll fix it. 
State-Changed-From-To: open->closed 
State-Changed-By: thorpej 
State-Changed-When: Sun Mar 5 10:46:25 PST 2000 
State-Changed-Why:  
fixed, thanks 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.