Subject: kern/19923: Post-nathanw_sa i386 kernel compilation error with PERFCTRS defined
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dave@dtsp.co.nz>
List: netbsd-bugs
Date: 01/19/2003 04:36:40
>Number: 19923
>Category: kern
>Synopsis: Post-nathanw_sa i386 kernel compilation error with PERFCTRS defined
>Confidential: no
>Severity: non-critical
>Priority: high
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Jan 18 20:37:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator: David Sainty
>Release: NetBSD 1.6M
>Organization:
Dynamic Technology Services and Products Ltd (NZ)
>Environment:
System: NetBSD tequila.dave.dtsp.co.nz 1.6K NetBSD 1.6K (TEQUILA-$Revision: 1.41 $) #1: Tue Dec 31 19:46:39 NZDT 2002 dave@tequila.dave.dtsp.co.nz:/vol/tequila/userD/NetBSD-current/src/sys/arch/i386/compile/TEQUILA i386
Architecture: i386
Machine: i386
>Description:
"options PERFCTRS" causes code to be compiled that defines variables
that are never used on some ports. This causes the compile to fail.
>How-To-Repeat:
Compile an i386 kernel (I'm sure i386 isn't the only affected port)
with "options PERFCTRS" enabled.
cc -ffreestanding -g -O2 -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wno-sign-compare -Wno-uninitialized -Di386 -I. -I../../../../arch -I../../../.. -nostdinc -DIPFORWSRCRT="0" -DFIFO -DMSGBUFSIZE="0x100000" -DDIAGNOSTIC -DUSB_DEBUG -DBTHCI_DEBUG -DTLP_MATCH_21140 -DMAXUSERS=16 -D_KERNEL -D_KERNEL_OPT -c /usr/src/NetBSD-current/src/sys/arch/i386/compile/MERLOT/../../../../kern/sys_pmc.c
cc1: warnings being treated as errors
/usr/src/NetBSD-current/src/sys/arch/i386/compile/MERLOT/../../../../kern/sys_pmc.c: In function `sys_pmc_control':
/usr/src/NetBSD-current/src/sys/arch/i386/compile/MERLOT/../../../../kern/sys_pmc.c:70: warning: unused variable `p'
/usr/src/NetBSD-current/src/sys/arch/i386/compile/MERLOT/../../../../kern/sys_pmc.c: In function `sys_pmc_get_info':
/usr/src/NetBSD-current/src/sys/arch/i386/compile/MERLOT/../../../../kern/sys_pmc.c:140: warning: unused variable `p'
*** Error code 1
Stop.
>Fix:
Here's one approach, the code looks a little repetitive, but it's
probably a reasonable solution.
--- src/sys/kern/sys_pmc.c.orig Sun Jan 19 16:22:29 2003
+++ src/sys/kern/sys_pmc.c Sun Jan 19 17:19:22 2003
@@ -56,6 +56,15 @@
* XXX We need a multiprocessor locking protocol!
*/
+/*
+ * The pmc_counter_*() interfaces are typically implemented as macros,
+ * and may not use the process reference. By repeatedly using
+ * l->l_proc as the parameter (instead of factoring it out into a
+ * separate variable), we avoid compiler warnings on systems that
+ * define macros which never use that parameter.
+ */
+
+/*ARGSUSED*/
int
sys_pmc_control(struct lwp *l, void *v, register_t *rv)
{
@@ -67,7 +76,6 @@
syscallarg(int) op;
syscallarg(void *) args;
} */ *uap = v;
- struct proc *p = l->l_proc;
struct pmc_counter_cfg cfg;
void *args;
int ctr, operation, error=0;
@@ -77,33 +85,33 @@
switch (operation) {
case PMC_OP_START:
- if (!pmc_counter_isconfigured(p, ctr)) {
+ if (!pmc_counter_isconfigured(l->l_proc, ctr)) {
return ENXIO;
}
- if (pmc_counter_isrunning(p, ctr)) {
+ if (pmc_counter_isrunning(l->l_proc, ctr)) {
return EINPROGRESS;
}
- pmc_enable_counter(p, ctr);
+ pmc_enable_counter(l->l_proc, ctr);
break;
case PMC_OP_STOP:
- if (!pmc_counter_isconfigured(p, ctr)) {
+ if (!pmc_counter_isconfigured(l->l_proc, ctr)) {
return ENXIO;
}
- if (!pmc_counter_isrunning(p, ctr)) {
+ if (!pmc_counter_isrunning(l->l_proc, ctr)) {
/* Nothing to do */
return 0;
}
- pmc_disable_counter(p, ctr);
+ pmc_disable_counter(l->l_proc, ctr);
break;
case PMC_OP_CONFIGURE:
args = SCARG(uap, args);
- if (pmc_counter_isrunning(p, ctr)) {
- pmc_disable_counter(p, ctr);
+ if (pmc_counter_isrunning(l->l_proc, ctr)) {
+ pmc_disable_counter(l->l_proc, ctr);
}
error = copyin(args, &cfg, sizeof(struct pmc_counter_cfg));
if (error == 0) {
- error = pmc_configure_counter(p, ctr, &cfg);
+ error = pmc_configure_counter(l->l_proc, ctr, &cfg);
}
break;
case PMC_OP_PROFSTART:
@@ -125,6 +133,7 @@
#endif
}
+/*ARGSUSED*/
int
sys_pmc_get_info(struct lwp *l, void *v, register_t *rv)
{
@@ -137,7 +146,6 @@
syscallarg(void *) args;
} */ *uap = v;
uint64_t val;
- struct proc *p = l->l_proc;
void *args;
int nctrs, ctr, ctrt, request, error=0, flags=0;
@@ -164,7 +172,7 @@
if (ctr < 0 || ctr >= nctrs) {
return EINVAL;
}
- error = pmc_get_counter_value(p, ctr, flags, &val);
+ error = pmc_get_counter_value(l->l_proc, ctr, flags, &val);
if (error == 0) {
error = copyout(&val, args, sizeof(uint64_t));
}
>Release-Note:
>Audit-Trail:
>Unformatted: