[PATCH] fix zero builds for "unknown" architectures

Matthias Klose doko at ubuntu.com
Wed Sep 9 16:19:04 UTC 2015


seen with jdk9 / tag jdk9-b80.  zero builds which don't match one of the hotspot
architectures fail to build in src/os/linux/vm/os_linux.cpp, because there is no
default / or else clause:

const char* search_string = IA32_ONLY("model name") AMD64_ONLY("model name")
                            IA64_ONLY("") SPARC_ONLY("cpu")
                            ARM32_ONLY("Processor") PPC_ONLY("Processor")
AARCH64_ONLY("Processor");

and:

  strncpy(cpuinfo, IA32_ONLY("x86_32") AMD64_ONLY("x86_32")
                   IA64_ONLY("IA64") SPARC_ONLY("sparcv9")
                   ARM32_ONLY("ARM") PPC_ONLY("PPC64") AARCH64_ONLY("AArch64"),
length);

attached are two alternate patches how to fix this, either by not using the
*_ONLY macros, or by defining an UNKOWN_ARCH_ONLY macro.

Two other issues:
 - The zero builds only define ARM, not ARM32, so the clause
   should be ARM_ONLY (or at least an ARM_ONLY added).
 - The cpuinfo string seems to be wrong for AMD64_ONLY.

Verified that zero builds without errors with on of these patches.

Attaching both patches.

  Matthias

-------------- next part --------------
--- src/hotspot/src/os/linux/vm/os_linux.cpp
+++ src/hotspot/src/os/linux/vm/os_linux.cpp
@@ -2211,9 +2211,13 @@
   }
 }
 
-const char* search_string = IA32_ONLY("model name") AMD64_ONLY("model name")
-                            IA64_ONLY("") SPARC_ONLY("cpu")
-                            ARM32_ONLY("Processor") PPC_ONLY("Processor") AARCH64_ONLY("Processor");
+#if defined(AMD64) || defined(IA32) || defined(X32)
+const char* search_string = "model name";
+#elif defined(SPARC)
+const char* search_string = "cpu";
+#else
+const char* search_string = "Processor";
+#endif
 
 // Parses the cpuinfo file for string representing the model name.
 void os::get_summary_cpu_info(char* cpuinfo, size_t length) {
@@ -2248,9 +2252,26 @@
   }
   // cpuinfo not found or parsing failed, just print generic string.  The entire
   // /proc/cpuinfo file will be printed later in the file (or enough of it for x86)
-  strncpy(cpuinfo, IA32_ONLY("x86_32") AMD64_ONLY("x86_32")
-                   IA64_ONLY("IA64") SPARC_ONLY("sparcv9")
-                   ARM32_ONLY("ARM") PPC_ONLY("PPC64") AARCH64_ONLY("AArch64"), length);
+  
+#if defined(AMD64)
+  strncpy(cpuinfo, "x86_64", length);
+#elif defined(IA32)
+  strncpy(cpuinfo, "x86_32", length);
+#elif defined(IA64)
+  strncpy(cpuinfo, "IA64", length);
+#elif defined(SPARC)
+  strncpy(cpuinfo, "sparcv9", length);
+#elif defined(ARM)
+  strncpy(cpuinfo, "ARM", length);
+#elif defined(AARCH64)
+  strncpy(cpuinfo, "AArch64", length);
+#elif defined(PPC)
+  strncpy(cpuinfo, "PPC64", length);
+#elif defined(ZERO_LIBARCH)
+  strncpy(cpuinfo, ZERO_LIBARCH, length);
+#else
+  strncpy(cpuinfo, "unknown", length);
+#endif
 }
 
 void os::print_siginfo(outputStream* st, void* siginfo) {
-------------- next part --------------
--- a/hotspot/src/share/vm/utilities/macros.hpp
+++ b/hotspot/src/share/vm/utilities/macros.hpp
@@ -425,6 +425,12 @@
 #define NOT_AARCH64(code) code
 #endif
 
+#if !defined(X86) && !defined(IA64) && !defined(SPARC) && !defined(PPC) && !defined(ARM) && !defined(AARCH64)
+#define UNKNOWN_ARCH_ONLY(code) code
+#else
+#define UNKNOWN_ARCH_ONLY(code)
+#endif
+
 #ifdef JAVASE_EMBEDDED
 #define EMBEDDED_ONLY(code) code
 #define NOT_EMBEDDED(code)
--- a/hotspot/src/os/linux/vm/os_linux.cpp
+++ b/hotspot/src/os/linux/vm/os_linux.cpp
@@ -2213,7 +2213,8 @@
 
 const char* search_string = IA32_ONLY("model name") AMD64_ONLY("model name")
                             IA64_ONLY("") SPARC_ONLY("cpu")
-                            ARM32_ONLY("Processor") PPC_ONLY("Processor") AARCH64_ONLY("Processor");
+                            ARM_ONLY("Processor") PPC_ONLY("Processor") AARCH64_ONLY("Processor")
+                            UNKNOWN_ARCH_ONLY("Processor");
 
 // Parses the cpuinfo file for string representing the model name.
 void os::get_summary_cpu_info(char* cpuinfo, size_t length) {
@@ -2248,9 +2249,15 @@
   }
   // cpuinfo not found or parsing failed, just print generic string.  The entire
   // /proc/cpuinfo file will be printed later in the file (or enough of it for x86)
-  strncpy(cpuinfo, IA32_ONLY("x86_32") AMD64_ONLY("x86_32")
+  strncpy(cpuinfo, IA32_ONLY("x86_32") AMD64_ONLY("x86_64")
                    IA64_ONLY("IA64") SPARC_ONLY("sparcv9")
-                   ARM32_ONLY("ARM") PPC_ONLY("PPC64") AARCH64_ONLY("AArch64"), length);
+                   ARM_ONLY("ARM") PPC_ONLY("PPC64") AARCH64_ONLY("AArch64")
+#ifdef ZERO_LIBARCH
+                   ZERO_LIBARCH
+#else
+                   UNKNOWN_ARCH_ONLY("unknown")
+#endif
+	  , length);
 }
 
 void os::print_siginfo(outputStream* st, void* siginfo) {


More information about the hotspot-dev mailing list