diff --git a/bindings/dotnet/examples/CpuInfo.cs b/bindings/dotnet/examples/CpuInfo.cs index b7c7d2e8..95cea7cc 100644 --- a/bindings/dotnet/examples/CpuInfo.cs +++ b/bindings/dotnet/examples/CpuInfo.cs @@ -7,7 +7,7 @@ public class CpuInfo { Sigar sigar = new Sigar(); Hyperic.Sigar.CpuInfo[] infos = - sigar.CpuInfos(); + sigar.CpuInfoList(); System.Console.WriteLine(infos.Length + " total CPUs.."); diff --git a/bindings/dotnet/src/Sigar.cs b/bindings/dotnet/src/Sigar.cs index b09f417c..4ee05993 100644 --- a/bindings/dotnet/src/Sigar.cs +++ b/bindings/dotnet/src/Sigar.cs @@ -32,8 +32,8 @@ namespace Hyperic.Sigar { return Hyperic.Sigar.Swap.NativeGet(this); } - public CpuInfo[] CpuInfos() { - return Hyperic.Sigar.CpuInfos.NativeGet(this); + public CpuInfo[] CpuInfoList() { + return Hyperic.Sigar.CpuInfoList.NativeGet(this); } public FileSystem[] FileSystemList() { @@ -126,31 +126,32 @@ namespace Hyperic.Sigar { } [StructLayout(LayoutKind.Sequential)] - internal struct CpuInfos { + internal struct CpuInfoList { private readonly uint Number; //sizeof(unsigned long) == 4 private readonly uint size; private readonly IntPtr data; [DllImport(Sigar.LIBSIGAR)] - private static extern int sigar_cpu_infos_get(IntPtr sigar, - IntPtr cpu_infos); - - [DllImport(Sigar.LIBSIGAR)] - private static extern int sigar_cpu_infos_destroy(IntPtr sigar, + private static extern int sigar_cpu_info_list_get(IntPtr sigar, IntPtr cpu_infos); + [DllImport(Sigar.LIBSIGAR)] + private static extern int sigar_cpu_info_list_destroy(IntPtr sigar, + IntPtr cpu_infos); + internal static CpuInfo[] NativeGet(Sigar sigar) { - Type type = typeof(CpuInfos); + Type type = typeof(CpuInfoList); IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(type)); - int status = sigar_cpu_infos_get(sigar.sigar.Handle, ptr); + int status = sigar_cpu_info_list_get(sigar.sigar.Handle, ptr); if (status != Sigar.OK) { Marshal.FreeHGlobal(ptr); - throw new ApplicationException("cpu_infos_get"); + throw new ApplicationException("cpu_info_list_get"); } - CpuInfos infosPtr = (CpuInfos)Marshal.PtrToStructure(ptr, type); + CpuInfoList infosPtr = + (CpuInfoList)Marshal.PtrToStructure(ptr, type); CpuInfo[] infos = new CpuInfo[infosPtr.Number]; @@ -164,7 +165,7 @@ namespace Hyperic.Sigar { eptr = Sigar.incrementIntPtr(eptr, size); } - sigar_cpu_infos_destroy(sigar.sigar.Handle, ptr); + sigar_cpu_info_list_destroy(sigar.sigar.Handle, ptr); Marshal.FreeHGlobal(ptr); diff --git a/bindings/java/src/jni/javasigar.c b/bindings/java/src/jni/javasigar.c index 949d4c49..85c3844a 100644 --- a/bindings/java/src/jni/javasigar.c +++ b/bindings/java/src/jni/javasigar.c @@ -305,12 +305,12 @@ JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getCpuInfoList) { int status; unsigned int i; - sigar_cpu_infos_t cpu_infos; + sigar_cpu_info_list_t cpu_infos; jobjectArray cpuarray; jclass cls = SIGAR_FIND_CLASS("CpuInfo"); dSIGAR(NULL); - if ((status = sigar_cpu_infos_get(sigar, &cpu_infos)) != SIGAR_OK) { + if ((status = sigar_cpu_info_list_get(sigar, &cpu_infos)) != SIGAR_OK) { sigar_throw_error(env, sigar, status); return NULL; } @@ -326,7 +326,7 @@ JNIEXPORT jobjectArray SIGAR_JNI(Sigar_getCpuInfoList) JENV->SetObjectArrayElement(env, cpuarray, i, info_obj); } - sigar_cpu_infos_destroy(sigar, &cpu_infos); + sigar_cpu_info_list_destroy(sigar, &cpu_infos); return cpuarray; } diff --git a/bindings/java/src/net/hyperic/sigar/Sigar.java b/bindings/java/src/net/hyperic/sigar/Sigar.java index 3f46d6c9..42c03712 100644 --- a/bindings/java/src/net/hyperic/sigar/Sigar.java +++ b/bindings/java/src/net/hyperic/sigar/Sigar.java @@ -136,13 +136,13 @@ public class Sigar implements SigarProxy { return (this.lastCpu = Cpu.fetch(this)); } - private static void pause(int millis) { + static void pause(int millis) { try { Thread.sleep(millis); } catch(InterruptedException e) { } } - private static void pause() { + static void pause() { pause(500); } diff --git a/bindings/perl/Sigar.xs b/bindings/perl/Sigar.xs index cd864ed0..83a22f86 100644 --- a/bindings/perl/Sigar.xs +++ b/bindings/perl/Sigar.xs @@ -201,15 +201,15 @@ file_system_list(sigar) RETVAL SV * -cpu_infos(sigar) +cpu_info_list(sigar) Sigar sigar PREINIT: - sigar_cpu_infos_t cpu_infos; + sigar_cpu_info_list_t cpu_infos; int status; CODE: - status = sigar_cpu_infos_get(sigar, &cpu_infos); + status = sigar_cpu_info_list_get(sigar, &cpu_infos); if (status != SIGAR_OK) { SIGAR_CROAK(sigar, "cpu_infos"); @@ -220,7 +220,7 @@ cpu_infos(sigar) sizeof(*cpu_infos.data), "Sigar::CpuInfo"); - sigar_cpu_infos_destroy(sigar, &cpu_infos); + sigar_cpu_info_list_destroy(sigar, &cpu_infos); OUTPUT: RETVAL diff --git a/bindings/perl/examples/cpu_info.pl b/bindings/perl/examples/cpu_info.pl index b99afdde..46f2afa3 100755 --- a/bindings/perl/examples/cpu_info.pl +++ b/bindings/perl/examples/cpu_info.pl @@ -5,7 +5,7 @@ use Sigar; my $sigar = new Sigar; -my $infos = $sigar->cpu_infos; +my $infos = $sigar->cpu_info_list; my $num = scalar @$infos; diff --git a/include/sigar.h b/include/sigar.h index d81b1ffc..74d943b3 100644 --- a/include/sigar.h +++ b/include/sigar.h @@ -123,13 +123,15 @@ typedef struct { unsigned long number; unsigned long size; sigar_cpu_info_t *data; -} sigar_cpu_infos_t; +} sigar_cpu_info_list_t; -SIGAR_DECLARE(int) sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos); +SIGAR_DECLARE(int) +sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos); -SIGAR_DECLARE(int) sigar_cpu_infos_destroy(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos); +SIGAR_DECLARE(int) +sigar_cpu_info_list_destroy(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos); typedef struct { double uptime; diff --git a/include/sigar_private.h b/include/sigar_private.h index f56c724e..c750b3b3 100644 --- a/include/sigar_private.h +++ b/include/sigar_private.h @@ -120,13 +120,13 @@ int sigar_os_fs_type_get(sigar_file_system_t *fsp); void sigar_fs_type_get(sigar_file_system_t *fsp); -int sigar_cpu_infos_create(sigar_cpu_infos_t *cpu_infos); +int sigar_cpu_info_list_create(sigar_cpu_info_list_t *cpu_infos); -int sigar_cpu_infos_grow(sigar_cpu_infos_t *cpu_infos); +int sigar_cpu_info_list_grow(sigar_cpu_info_list_t *cpu_infos); -#define SIGAR_CPU_INFOS_GROW(cpu_infos) \ +#define SIGAR_CPU_INFO_LIST_GROW(cpu_infos) \ if (cpu_infos->number >= cpu_infos->size) { \ - sigar_cpu_infos_grow(cpu_infos); \ + sigar_cpu_info_list_grow(cpu_infos); \ } int sigar_cpu_list_create(sigar_cpu_list_t *cpulist); diff --git a/src/os/aix/aix_sigar.c b/src/os/aix/aix_sigar.c index 7277d1a0..8c0e8475 100644 --- a/src/os/aix/aix_sigar.c +++ b/src/os/aix/aix_sigar.c @@ -1183,20 +1183,20 @@ static int sigar_get_cpu_mhz(sigar_t *sigar) return sigar->cpu_mhz; } -int sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { int i; int ncpu = _system_configuration.ncpus; /* this can change */ /*XXX should only do this once*/ - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); for (i=0; idata[cpu_infos->number++]; diff --git a/src/os/darwin/darwin_sigar.c b/src/os/darwin/darwin_sigar.c index f7debbc5..03a6f916 100644 --- a/src/os/darwin/darwin_sigar.c +++ b/src/os/darwin/darwin_sigar.c @@ -593,17 +593,17 @@ int sigar_file_system_usage_get(sigar_t *sigar, return SIGAR_OK; } -int sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { int i; - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); for (i=0; incpu; i++) { sigar_cpu_info_t *info; - SIGAR_CPU_INFOS_GROW(cpu_infos); + SIGAR_CPU_INFO_LIST_GROW(cpu_infos); info = &cpu_infos->data[cpu_infos->number++]; diff --git a/src/os/hpux/hpux_sigar.c b/src/os/hpux/hpux_sigar.c index bd84a726..02bed416 100644 --- a/src/os/hpux/hpux_sigar.c +++ b/src/os/hpux/hpux_sigar.c @@ -538,8 +538,8 @@ int sigar_file_system_usage_get(sigar_t *sigar, return SIGAR_OK; } -int sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { int i; struct pst_dynamic stats; @@ -547,7 +547,7 @@ int sigar_cpu_infos_get(sigar_t *sigar, pstat_getdynamic(&stats, sizeof(stats), 1, 0); sigar->ncpu = stats.psd_proc_cnt; - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); for (i=0; incpu; i++) { sigar_cpu_info_t *info; @@ -558,7 +558,7 @@ int sigar_cpu_infos_get(sigar_t *sigar, continue; } - SIGAR_CPU_INFOS_GROW(cpu_infos); + SIGAR_CPU_INFO_LIST_GROW(cpu_infos); info = &cpu_infos->data[cpu_infos->number++]; diff --git a/src/os/linux/linux_sigar.c b/src/os/linux/linux_sigar.c index 9a4da614..b2c4b4b4 100644 --- a/src/os/linux/linux_sigar.c +++ b/src/os/linux/linux_sigar.c @@ -141,13 +141,13 @@ static int is_ht_enabled(sigar_t *sigar) { if (sigar->ht_enabled == -1) { /* only check once */ - sigar_cpu_infos_t cpuinfos; + sigar_cpu_info_list_t cpuinfos; - if (sigar_cpu_infos_get(sigar, &cpuinfos) != SIGAR_OK) { + if (sigar_cpu_info_list_get(sigar, &cpuinfos) != SIGAR_OK) { sigar->ht_enabled = 0; /* chances we reach here: slim..none */ } - sigar_cpu_infos_destroy(sigar, &cpuinfos); + sigar_cpu_info_list_destroy(sigar, &cpuinfos); } return sigar->ht_enabled; @@ -1075,8 +1075,8 @@ static int get_cpu_info(sigar_t *sigar, sigar_cpu_info_t *info, return found; } -int sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { FILE *fp; int id; @@ -1090,7 +1090,7 @@ int sigar_cpu_infos_get(sigar_t *sigar, sigar->ht_enabled = 0; /* figure out below */ - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); memset(&cpu_id[0], -1, sizeof(cpu_id)); while (get_cpu_info(sigar, &cpu_infos->data[cpu_infos->number], fp, &id)) { @@ -1118,7 +1118,7 @@ int sigar_cpu_infos_get(sigar_t *sigar, } ++cpu_infos->number; - SIGAR_CPU_INFOS_GROW(cpu_infos); + SIGAR_CPU_INFO_LIST_GROW(cpu_infos); } fclose(fp); diff --git a/src/os/solaris/solaris_sigar.c b/src/os/solaris/solaris_sigar.c index 0fe96655..61d4faa7 100644 --- a/src/os/solaris/solaris_sigar.c +++ b/src/os/solaris/solaris_sigar.c @@ -952,8 +952,8 @@ int sigar_file_system_usage_get(sigar_t *sigar, return SIGAR_OK; } -int sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { processor_info_t stats; unsigned int i; @@ -982,12 +982,12 @@ int sigar_cpu_infos_get(sigar_t *sigar, return ENOENT; } - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); for (i=0; incpu; i++) { sigar_cpu_info_t *info; - SIGAR_CPU_INFOS_GROW(cpu_infos); + SIGAR_CPU_INFO_LIST_GROW(cpu_infos); info = &cpu_infos->data[cpu_infos->number++]; @@ -1360,4 +1360,4 @@ int sigar_net_interface_stat_get(sigar_t *sigar, const char *name, int sigar_net_connection_list_get(sigar_t *sigar, sigar_net_connection_list_t *connlist, - int flags \ No newline at end of file + int flags diff --git a/src/os/stub/stub_sigar.c b/src/os/stub/stub_sigar.c index f7187492..e634f641 100644 --- a/src/os/stub/stub_sigar.c +++ b/src/os/stub/stub_sigar.c @@ -198,12 +198,12 @@ int sigar_file_system_usage_get(sigar_t *sigar, return SIGAR_OK; } -int sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { sigar_cpu_info_t *info; - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); info = &cpu_infos->data[cpu_infos->number++]; diff --git a/src/os/win32/win32_sigar.c b/src/os/win32/win32_sigar.c index 1b09139d..a299c4f8 100644 --- a/src/os/win32/win32_sigar.c +++ b/src/os/win32/win32_sigar.c @@ -1360,15 +1360,15 @@ sigar_file_system_usage_get(sigar_t *sigar, return SIGAR_OK; } -SIGAR_DECLARE(int) sigar_cpu_infos_get(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +SIGAR_DECLARE(int) sigar_cpu_info_list_get(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { int i, status; sigar_cpu_info_t *info; sigar_cpu_count(sigar); - sigar_cpu_infos_create(cpu_infos); + sigar_cpu_info_list_create(cpu_infos); info = &cpu_infos->data[cpu_infos->number++]; @@ -1380,7 +1380,7 @@ SIGAR_DECLARE(int) sigar_cpu_infos_get(sigar_t *sigar, if (sigar->ncpu > 1) { for (i=1; incpu; i++) { - SIGAR_CPU_INFOS_GROW(cpu_infos); + SIGAR_CPU_INFO_LIST_GROW(cpu_infos); memcpy(&cpu_infos->data[cpu_infos->number++], info, sizeof(*info)); diff --git a/src/sigar.c b/src/sigar.c index 503c1fc8..711583b0 100644 --- a/src/sigar.c +++ b/src/sigar.c @@ -486,7 +486,7 @@ sigar_file_system_list_destroy(sigar_t *sigar, return SIGAR_OK; } -int sigar_cpu_infos_create(sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_create(sigar_cpu_info_list_t *cpu_infos) { cpu_infos->number = 0; cpu_infos->size = SIGAR_CPU_INFO_MAX; @@ -495,7 +495,7 @@ int sigar_cpu_infos_create(sigar_cpu_infos_t *cpu_infos) return SIGAR_OK; } -int sigar_cpu_infos_grow(sigar_cpu_infos_t *cpu_infos) +int sigar_cpu_info_list_grow(sigar_cpu_info_list_t *cpu_infos) { cpu_infos->data = realloc(cpu_infos->data, sizeof(*(cpu_infos->data)) * @@ -505,8 +505,9 @@ int sigar_cpu_infos_grow(sigar_cpu_infos_t *cpu_infos) return SIGAR_OK; } -SIGAR_DECLARE(int) sigar_cpu_infos_destroy(sigar_t *sigar, - sigar_cpu_infos_t *cpu_infos) +SIGAR_DECLARE(int) +sigar_cpu_info_list_destroy(sigar_t *sigar, + sigar_cpu_info_list_t *cpu_infos) { if (cpu_infos->size) { free(cpu_infos->data);