Hi,

Here's an updated semi-ugly quick patch for 5.8.16. It's built based on
the previous one, and adds some comments and #ifdefs which are necessary
to avoid unwanted output on foreign platforms. Tested using a quick-hack
testcase program on all 4 platforms (same machines as the first time).

Since I'm not quite sure what upstream wants in the various fields, I
tried to be sensible, but if they want to look more into this, I've put a
bunch of cpuinfo files here: http://www.pateam.org/archive/tmp/boinc/

These files are plain copy in order to preserve tabs/spaces.

I don't really know how to contact upstream (I'm not too fond of web
forums), so Frank, if you can I'd suggest you forward them this and see
how they react. I'd be willing to offer machine access if they need it.

Also note they're not getting cache information on alpha, dunno if that's
intended so I didn't touch it. 

Some more about cache: except for hppa where I explicitly initialize
m_cache to 0, I suspect that this version will still expose the minor bug
of reporting bogus cache value if no cache info is found in cpuinfo...
They might want to fix that as well, if it hasn't been already.

HTH

T-Bone

(PS: answer to #407461 is coming, testing of 5.8.16 amd64 in progress :)
--- boinc-5.8.16/client/hostinfo_unix.C.orig	2007-03-01 17:10:08.000000000 +0100
+++ boinc-5.8.16/client/hostinfo_unix.C	2007-03-04 00:25:46.000000000 +0100
@@ -268,33 +268,93 @@
     strcpy(features, "");
     while (fgets(buf, 256, f)) {
         strip_whitespace(buf);
-        if (strstr(buf, "vendor_id\t: ") || strstr(buf, "system type\t\t: ")) {
+         if (
+                /* there might be conflicts if we dont #ifdef */
+#ifdef __ia64__
+                strstr(buf, "vendor     : ")
+#elif __hppa__		
+		strstr(buf, "cpu\t\t: ")
+#elif __powerpc__
+                strstr(buf, "machine\t\t: ")
+#elif __sparc__
+		strstr(buf, "type\t\t: ")
+#else
+		strstr(buf, "vendor_id\t: ") || strstr(buf, "system type\t\t: ")
+#endif
+		) {
             if (!vendor_found) {
                 vendor_found = true;
                 strlcpy(host.p_vendor, strchr(buf, ':') + 2, sizeof(host.p_vendor));
             }
         }
-        if (strstr(buf, "model name\t: ") || strstr(buf, "cpu model\t\t: ")) {
+        if (
+#ifdef __ia64__
+		strstr(buf, "family     : ")
+#elif __powerpc__ || __sparc__
+		strstr(buf, "cpu\t\t: ")
+#else
+		strstr(buf, "model name\t: ") || strstr(buf, "cpu model\t\t: ")
+#endif
+                ) {
             if (!model_found) {
                 model_found = true;
+#ifdef __powerpc__
+	    char *coma = NULL;
+            if ((coma = strrchr(buf, ','))) {   /* we have ", altivec supported" */
+	    	*coma = '\0';	/* strip the unwanted line */
+                strcpy(features, "altivec");
+                features_found = true;
+            }
+#endif
                 strlcpy(host.p_model, strchr(buf, ':') + 2, sizeof(host.p_model));
             }
         }
+#ifndef __hppa__
+	/* XXX: hppa: "cpu family	: PA-RISC 2.0" */
         if (strstr(buf, "cpu family\t: ") && family<0) {
-            family = atoi(buf+strlen("cpu family\t: "));
+	    family = atoi(buf+strlen("cpu family\t: "));
         }
+        /* XXX: hppa: "model            : 9000/785/J6000" */
         if (strstr(buf, "model\t\t: ") && model<0) {
             model = atoi(buf+strlen("model\t\t: "));
         }
+        /* ia64 */
+        if (strstr(buf, "model      : ") && model<0) {
+            model = atoi(buf+strlen("model     : "));
+        }
+#endif
         if (strstr(buf, "stepping\t: ") && stepping<0) {
             stepping = atoi(buf+strlen("stepping\t: "));
         }
+#ifdef __hppa__
+        bool icache_found=false,dcache_found=false;
+        host.m_cache = 0;
+        if ( (strstr(buf, "I-cache\t\t: ") == buf) &&
+             (icache_found == 0) ) {
+            icache_found = true;
+            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 = true;
+            sscanf(buf, "D-cache\t\t: %d", &n);
+            host.m_cache += n*1024;
+        }
+#elif __powerpc__
+        if ( (strstr(buf, "L2 cache\t: ") == buf) &&
+             (cache_found == 0) ) {
+            cache_found = true;
+            sscanf(buf, "L2 cache\t: %d", &n);
+            host.m_cache = n*1024;
+        }
+#else
         if (!cache_found && (strstr(buf, "cache size\t: ") == buf)) {
             cache_found = true;
             sscanf(buf, "cache size\t: %d", &n);
             host.m_cache = n*1024;
         }
-
+#endif
         if (!features_found) {
             // Some versions of the linux kernel call them flags,
             // others call them features, so look for both.
@@ -303,7 +363,9 @@
                 strlcpy(features, strchr(buf, ':') + 2, sizeof(features));
             } else if ((strstr(buf, "features\t\t: ") == buf)) {
                 strlcpy(features, strchr(buf, ':') + 2, sizeof(features));
-            }
+            } else if ((strstr(buf, "features   : ") == buf)) {	/* ia64 */
+	    	strlcpy(features, strchr(buf, ':') + 2, sizeof(features));
+	    }
             if (strlen(features)) {
                 features_found = true;
             }

Reply via email to