From e0bc9674b599e78257795c88a5479ac5b67cb06d Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 2 Dec 2005 02:30:53 +0000 Subject: [PATCH] fix freebsd compile --- src/os/darwin/darwin_sigar.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 88447dc2..e0056476 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -1345,18 +1345,27 @@ int sigar_cpu_info_list_get(sigar_t *sigar, sigar_cpu_info_list_t *cpu_infos) { int i; - unsigned int mhz, cache_size; + unsigned int mhz; + int cache_size=SIGAR_FIELD_NOTIMPL; size_t size; char model[128], vendor[128], *ptr; size = sizeof(mhz); - if (sysctlbyname(CTL_HW_FREQ, &mhz, &size, NULL, 0) < 0) { + +#ifdef DARWIN + { int mib[] = { CTL_HW, HW_CPU_FREQ }; size = sizeof(mhz); if (sysctl(mib, NMIB(mib), &mhz, &size, NULL, 0) < 0) { mhz = SIGAR_FIELD_NOTIMPL; } } +#else + if (sysctlbyname(CTL_HW_FREQ, &mhz, &size, NULL, 0) < 0) { + mhz = SIGAR_FIELD_NOTIMPL; + } +#endif + if (mhz != SIGAR_FIELD_NOTIMPL) { mhz /= 1000000; } @@ -1388,6 +1397,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, SIGAR_SSTRCPY(model, ptr+1); } +#ifdef DARWIN { int mib[] = { CTL_HW, HW_L2CACHESIZE }; / * in bytes */ size = sizeof(cache_size); @@ -1395,6 +1405,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, cache_size = SIGAR_FIELD_NOTIMPL; } } +#endif sigar_cpu_info_list_create(cpu_infos);