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;