summaryrefslogtreecommitdiff
path: root/graphics/osg-devel/files/patch-ag
blob: f98f5c72fd26911a4b8d4d35ee64478be3dde4c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
--- work/OpenSceneGraph-0.8/src/osg/Timer.cpp	Thu Dec  7 15:50:51 2000
+++ src/osg/Timer.cpp	Mon Apr 23 19:04:58 2001
@@ -59,15 +59,33 @@
 
 #endif // ]
 
-#ifdef __linux // [
-#include <unistd.h>
-#include <sys/mman.h>
+#if defined(__linux) || defined(__FreeBSD__) // [
+
+#  include <unistd.h>
+#  if defined(__linux)
+#    include <sys/mman.h>
+#  elif defined(__FreeBSD__)
+#    include <sys/types.h>
+#    include <sys/sysctl.h>
+#  endif
 
 int Timer::inited = 0;
 double Timer::cpu_mhz = 0.0;
 
 void Timer::init( void )
 {
+#  if defined(__FreeBSD__)
+    int cpuspeed;
+    size_t len;
+  
+    len = sizeof(cpuspeed);
+    if (sysctlbyname("machdep.tsc_freq", &cpuspeed, &len, NULL, NULL) == -1) {
+	perror("sysctlbyname(machdep.tsc_freq)");
+        return;
+    }
+    cpu_mhz = cpuspeed / 1e6;
+
+#  elif defined(__linux)
     char buff[128];
     FILE *fp = fopen( "/proc/cpuinfo", "r" );
 
@@ -87,6 +105,7 @@
 	}
     }
     fclose( fp );
+#  endif
     inited = 1;
 }