From abf6d0735fda1b7d1acc9073e9faecc408043d20 Mon Sep 17 00:00:00 2001 From: Doug MacEachern Date: Fri, 2 Dec 2005 01:22:16 +0000 Subject: [PATCH] add cpu_info.cache_size --- src/os/darwin/darwin_sigar.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index 5664afb8..88447dc2 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -1345,7 +1345,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, sigar_cpu_info_list_t *cpu_infos) { int i; - unsigned int mhz; + unsigned int mhz, cache_size; size_t size; char model[128], vendor[128], *ptr; @@ -1388,6 +1388,14 @@ int sigar_cpu_info_list_get(sigar_t *sigar, SIGAR_SSTRCPY(model, ptr+1); } + { + int mib[] = { CTL_HW, HW_L2CACHESIZE }; / * in bytes */ + size = sizeof(cache_size); + if (sysctl(mib, NMIB(mib), &cache_size, &size, NULL, 0) < 0) { + cache_size = SIGAR_FIELD_NOTIMPL; + } + } + sigar_cpu_info_list_create(cpu_infos); for (i=0; incpu; i++) { @@ -1405,7 +1413,7 @@ int sigar_cpu_info_list_get(sigar_t *sigar, sigar_cpu_model_adjust(sigar, info); info->mhz = mhz; - info->cache_size = SIGAR_FIELD_NOTIMPL; + info->cache_size = cache_size; } return SIGAR_OK;