Fix Hertz calculation for FreeBSD
authorCraig Small <csmall@enc.com.au>
Thu, 6 Oct 2011 23:22:24 +0000 (10:22 +1100)
committerCraig Small <csmall@enc.com.au>
Thu, 6 Oct 2011 23:22:24 +0000 (10:22 +1100)
FreeBSD has no good way of finding the Hertz value. ELF notes don't
work, you can't find it in a function and even asm/params.h does
not have it.  Lucky for us, it is always 100.

Based upon Debian patch patch sysinfo_kfreebsd_hertz by Petr Salinger
Bug-Debian: http://bugs.debian.org/460331
Caution, 460331 has lots of overlapping bugs all around the Hertz
problem across many arches.

proc/sysinfo.c

index 1c7c2798d7996475841ece502708510ddd1ade93..85b28b7c6b9dfbaa5a05c9e9017d8899218c795e 100644 (file)
@@ -260,6 +260,14 @@ static void init_libproc(void){
     fputs("2.4+ kernel w/o ELF notes? -- report this\n", stderr);
   }
 #endif /* __linux __ */
+#if defined(__FreeBSD_kernel__) || defined(__FreeBSD__)
+  /* On FreeBSD the Hertz hack is unrelaible, there is no ELF note and
+   * Hertz isn't defined in asm/params.h
+   * See Debian Bug #460331
+   */
+  Hertz = 100;
+  return;
+#endif /* __FreeBSD__ */
   old_Hertz_hack();
 }