Subject: misc/4985: sys/vmmeter.h breakage
To: None <>
From: None <>
List: netbsd-bugs
Date: 02/12/1998 12:48:06
>Number:         4985
>Category:       misc
>Synopsis:       vmmeter.h no longer protects ``cnt'' declaration
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 12 10:50:03 1998
>Originator:     Brian Grayson
	Parallel and Distributed Systems
	Electrical and Computer Engineering
	The University of Texas at Austin
>Release:        Feb. 11, 1998
NetBSD marvin 1.3C NetBSD 1.3C (MARVIN) #28: Thu Feb 12 09:47:10 CST 1998     root@c3p0:/a/c3p0/home/c3p0/src/sys/arch/i386/compile/MARVIN i386

	The new /usr/include/sys/vmmeter.h no longer has an
	#ifdef _KERNEL wrapper around the declaration of struct
	vmmeter cnt, so if you compile a program with multiple C
	files, each of which includes vmmeter.h (i.e.,
	xosview), you end up with multiply-defined cnt symbols
	at link time.

	I'm not sure, but it seems to me that when the ifdef
	around the struct vmmeter declaration was added for UVM,
	that the wrong checks were done.  Previously, the struct
	vmmeter was declared regardless of whether it was _KERNEL
	or not, and the declaration of cnt was done only if
	_KERNEL.  Now, the struct _and_ the cnt decl are protected
	by the same ifdef of !_KERNEL || !UVM, which, when
	compiling either a non-UVM kernel or a user-level
	program, do the same thing.
	I _think_ it should be the following, unless
	I'm missing something:

	#if !defined(UVM)
	struct vmmeter {
	# ifdef _KERNEL
	struct vmmeter cnt;
	# endif
	Try to build xosview on a current system.
--- vmmeter.h.dist      Thu Feb 12 12:05:23 1998
+++ vmmeter.h   Thu Feb 12 12:32:33 1998
@@ -46,7 +46,7 @@
  * System wide statistics counters.  Look in <uvm/uvm_extern.h> for the
  * UVM equivalent.
-#if !defined(_KERNEL) || !defined(UVM)
+#if !defined(UVM)
 struct vmmeter {
         * General system activity.
@@ -99,7 +99,9 @@
        u_int v_forks_ppwait;   /* number of forks that block parent */
        u_int v_forks_sharevm;  /* number of forks that share address space */
+#if defined(_KERNEL)
 struct vmmeter cnt;
 /* systemwide totals computed every five seconds */