[netperf-dev] netperf2 commit notice r256 - trunk/src
raj at netperf.org
raj at netperf.org
Tue Mar 11 18:19:46 PDT 2008
Author: raj
Date: 2008-03-11 18:19:45 -0700 (Tue, 11 Mar 2008)
New Revision: 256
Added:
trunk/src/netsys_solaris.c
Modified:
trunk/src/netlib.c
Log:
initial cpu model and frequency info using kstat on solaris and a netlib fix for the uname call
Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c 2008-03-10 20:10:48 UTC (rev 255)
+++ trunk/src/netlib.c 2008-03-12 01:19:45 UTC (rev 256)
@@ -1121,7 +1121,10 @@
{
#ifdef HAVE_UNAME
struct utsname buf;
- if (uname(&buf) == 0) {
+ /* the linux manpage for uname says 0 means success, everyone else
+ says non-negative. at least they all agree that -1 means
+ error */
+ if (uname(&buf) != -1) {
local_sysname = strdup(buf.sysname);
local_release = strdup(buf.release);
local_version = strdup(buf.version);
Added: trunk/src/netsys_solaris.c
===================================================================
--- trunk/src/netsys_solaris.c (rev 0)
+++ trunk/src/netsys_solaris.c 2008-03-12 01:19:45 UTC (rev 256)
@@ -0,0 +1,77 @@
+#include <stdio.h>
+#include <math.h>
+#include <stdlib.h>
+#include <string.h>
+#include <kstat.h>
+
+static kstat_ctl_t *kc = NULL;
+static kid_t kcid = 0;
+
+static void
+find_cpu_model_freq(char **cpu_model, int *frequency) {
+
+ kstat_t *ksp;
+ kid_t nkcid;
+ kstat_named_t *knp;
+ int i,found_brand,found_freq;
+
+
+ found_brand = 0;
+ found_freq = 0;
+
+ kc = kstat_open();
+
+ if (NULL == kc) {
+ *cpu_model = strdup("kstat_open");
+ *frequency = -1;
+ return;
+ }
+
+ ksp = kstat_lookup(kc, "cpu_info", 0, NULL);
+
+ if ((NULL == ksp) ||
+ ((ksp) && (KSTAT_TYPE_NAMED != ksp->ks_type))) {
+ *cpu_model = strdup("kstat_lookup");
+ *frequency = -1;
+ kstat_close(kc);
+ return;
+ }
+
+ nkcid = kstat_read(kc, ksp, NULL);
+
+ if (-1 == nkcid) {
+ *cpu_model = strdup("kstat_read");
+ *frequency = -1;
+ kstat_close(kc);
+ return;
+ }
+
+ for (i = ksp->ks_ndata, knp = ksp->ks_data;
+ i > 0;
+ knp++, i--) {
+ if (!strcmp("brand", knp->name)) {
+ *cpu_model = strdup(KSTAT_NAMED_STR_PTR(knp));
+ found_brand = 1;
+ }
+ else if (!strcmp("clock_MHz",knp->name)) {
+ *frequency = (int)knp->value.ui32;
+ found_freq = 1;
+ }
+ }
+ if (!found_brand)
+ *cpu_model = strdup("CPU Not Found");
+ if (!found_freq)
+ *frequency = -1;
+
+ kstat_close(kc);
+}
+
+
+void
+find_system_info(char **system_model, char **cpu_model, int *cpu_frequency) {
+ int ret;
+
+ *system_model = strdup("Teach Me DMI");
+ find_cpu_model_freq(cpu_model,cpu_frequency);
+
+}
More information about the netperf-dev
mailing list