Attached is an updated patch to deal with sparc machines (tested on my Sun U30).

HTH

T-Bone

--
Thibaut VARENE
http://www.parisc-linux.org/~varenet/
--- boinc-5.4.11.orig/client/hostinfo_unix.C	2006-03-02 08:17:17.000000000 +0100
+++ boinc-5.4.11/client/hostinfo_unix.C	2007-02-03 01:32:36.491942808 +0100
@@ -323,7 +323,168 @@
     fclose(f);
 }
 
-#else   // not mips or alpha
+#elif __ia64__
+
+void parse_cpuinfo(HOST_INFO& host) {
+    char buf[256];
+    int system_found=0,model_found=0;
+    int n;
+    host.m_cache = 0;
+
+    FILE* f = fopen("/proc/cpuinfo", "r");
+    if (!f) return;
+
+    while (fgets(buf, 256, f)) {
+        if ( (strstr(buf, "vendor     : ") == buf) &&
+             (system_found == 0) ) {
+            system_found = 1;
+            strncpy(host.p_vendor, strchr(buf, ':') + 2, sizeof(host.p_vendor) - 1);
+            char * p = strchr(host.p_vendor, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+        if ( (strstr(buf, "family     : ") == buf) &&
+             (model_found == 0) ) {
+            model_found = 1;
+            strncpy(host.p_model, strchr(buf, ':') + 2, sizeof(host.p_model) - 1);
+            char * p = strchr(host.p_model, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+    }
+
+    fclose(f);
+}
+
+#elif __hppa__
+
+void parse_cpuinfo(HOST_INFO& host) {
+    char buf[256];
+    int system_found=0,model_found=0,icache_found=0,dcache_found=0;
+    int n;
+    host.m_cache = 0;
+
+    FILE* f = fopen("/proc/cpuinfo", "r");
+    if (!f) return;
+
+    while (fgets(buf, 256, f)) {
+        if ( (strstr(buf, "cpu\t\t: ") == buf) &&
+             (system_found == 0) ) {
+            system_found = 1;
+            strncpy(host.p_vendor, strchr(buf, ':') + 2, sizeof(host.p_vendor) - 1);
+            char * p = strchr(host.p_vendor, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+        if ( (strstr(buf, "model name\t: ") == buf) &&
+             (model_found == 0) ) {
+            model_found = 1;
+            strncpy(host.p_model, strchr(buf, ':') + 2, sizeof(host.p_model) - 1);
+            char * p = strchr(host.p_model, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+        if ( (strstr(buf, "I-cache\t\t: ") == buf) &&
+             (icache_found == 0) ) {
+            icache_found = 1;
+            sscanf(buf, "I-cache\t\t: %d", &n);
+            host.m_cache += n*1024;
+        }
+        if ( (strstr(buf, "D-cache\t\t: ") == buf) &&
+             (dcache_found == 0) ) {
+            dcache_found = 1;
+            sscanf(buf, "D-cache\t\t: %d", &n);
+            host.m_cache += n*1024;
+        }
+    }
+
+    fclose(f);
+}
+
+#elif __powerpc__
+
+void parse_cpuinfo(HOST_INFO& host) {
+    char buf[256];
+    int system_found=0,model_found=0,cache_found=0;
+    int n;
+    char* coma=NULL;
+    host.m_cache=0;
+
+    FILE* f = fopen("/proc/cpuinfo", "r");
+    if (!f) return;
+
+    while (fgets(buf, 256, f)) {
+        if ( (strstr(buf, "machine\t\t: ") == buf) &&
+             (system_found == 0) ) {
+            system_found = 1;
+            strncpy(host.p_vendor, strchr(buf, ':') + 2, sizeof(host.p_vendor) - 1);
+            char * p = strchr(host.p_vendor, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+        if ( (strstr(buf, "cpu\t\t: ") == buf) &&
+             (model_found == 0) ) {
+            model_found = 1;
+	    if ((coma = strrchr(buf, ',')))
+	    	*coma = '\0';	/* we don't want the ", altivec supported" */
+            strncpy(host.p_model, strchr(buf, ':') + 2, sizeof(host.p_model) - 1);
+            char * p = strchr(host.p_model, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+        if ( (strstr(buf, "L2-cache\t: ") == buf) &&
+             (cache_found == 0) ) {
+            cache_found = 1;
+            sscanf(buf, "L2-cache\t: %d", &n);
+            host.m_cache = n*1024;
+        }
+    }
+
+    fclose(f);
+}
+
+#elif __sparc__
+
+void parse_cpuinfo(HOST_INFO& host) {
+    char buf[256];
+    int system_found=0,model_found=0;
+    int n;
+    host.m_cache=0;
+
+    FILE* f = fopen("/proc/cpuinfo", "r");
+    if (!f) return;
+
+    while (fgets(buf, 256, f)) {
+        if ( (strstr(buf, "type\t\t: ") == buf) &&
+             (system_found == 0) ) {
+            system_found = 1;
+            strncpy(host.p_vendor, strchr(buf, ':') + 2, sizeof(host.p_vendor) - 1);
+            char * p = strchr(host.p_vendor, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+        if ( (strstr(buf, "cpu\t\t: ") == buf) &&
+             (model_found == 0) ) {
+            model_found = 1;
+            strncpy(host.p_model, strchr(buf, ':') + 2, sizeof(host.p_model) - 1);
+            char * p = strchr(host.p_model, '\n');
+            if (p) {
+                *p = '\0';
+            }
+        }
+    }
+
+    fclose(f);
+}
+
+#else   // not mips or alpha or ia64 or hppa or powerpc or sparc
 
 // Unfortunately the format of /proc/cpuinfo is not standardized.
 // See http://people.nl.linux.org/~hch/cpuinfo/ for some examples.

Reply via email to