pkgsrc-Users archive

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

Re: sysutils/xosview build failure (was: CVS commit: src/sys)



On Fri, Mar 16, 2007 at 01:45:22PM +0900, YAMAMOTO Takashi wrote:
> > Hmm, schedstate_percpu is now inside an ifdef _KERNEL and 
> > pkgsrc/sysutils/xosview
> > fails to build now:
> > 
> > kernel.cc: In function 'void BSDGetCPUTimes(u_int64_t*)':
> > kernel.cc:418: error: aggregate 'schedstate_percpu ssp' has incomplete type 
> > and cannot be defined
> > 
> > Bernd
> 
> i think it should use "uint64_t cp_time[CPUSTATES]" rather than
> schedstate_percpu.

Ok, I think the following patch should fix that problem, where I'm not sure
about the MP case with more then one CPU.

Bernd

--- bsd/kernel.cc       2007-04-09 16:57:18.000000000 +0200
+++ bsd/kernel.cc       2007-04-09 16:57:29.000000000 +0200
@@ -401,6 +408,8 @@
   static int mib[] = { CTL_KERN, KERN_CPUSTATS };
 #endif
 #if defined(XOSVIEW_NETBSD) && (__NetBSD_Version__ >= 104260000)
+  uint64_t cp_time[CPUSTATES];
+  size_t size = sizeof(cp_time[0]) * CPUSTATES;
   static int mib[] = { CTL_KERN, KERN_CP_TIME };
 #endif
 
@@ -408,14 +417,11 @@
   if (CPUSTATES != 5)
     errx (-1, "Error:  xosview for *BSD expects 5 cpu states!\n");
 #if defined(__NetBSD_Version__) && __NetBSD_Version__ > 104260000 /* > 1.4Z */
-  struct schedstate_percpu ssp;
-  size_t size = sizeof(ssp.spc_cp_time);
-  if (sysctl(mib, 2, ssp.spc_cp_time, &size, NULL, 0) < 0) {
-    fprintf(stderr, "can't get schedstate_percpu: %s\n", strerror(errno));
-    memset(&ssp, 0, sizeof(ssp));
+  if (sysctl(mib, 2, cp_time, &size, NULL, 0) < 0) {
+    fprintf(stderr, "xosview: sysctl kern.cp_time failed: %s\n", 
strerror(errno));
+    bzero(&cp_time, size);
   }
-  for (size = 0; size < CPUSTATES; size++)
-    timeArray[size] = (long) ssp.spc_cp_time[size];
+  bcopy (cp_time, timeArray, size);
 #else
 #ifdef XOSVIEW_BSDI
   if (sysctl(mib, 2, &cpu, &size, NULL, 0) < 0) {


Home | Main Index | Thread Index | Old Index