6781583: Hotspot build fails on linux 64 bit platform with gcc 4.3.2
Summary: Fixed the wrong cast between types since more restrictions are imposed by gcc 4.3.2
Reviewed-by: jcoomes, acorn, phh, never
--- a/hotspot/src/cpu/sparc/vm/jni_sparc.h Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/cpu/sparc/vm/jni_sparc.h Wed Dec 24 19:13:53 2008 -0800
@@ -28,5 +28,11 @@
#define JNICALL
typedef int jint;
-typedef long long jlong;
+
+#ifdef _LP64
+ typedef long jlong;
+#else
+ typedef long long jlong;
+#endif
+
typedef signed char jbyte;
--- a/hotspot/src/cpu/x86/vm/jni_x86.h Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/cpu/x86/vm/jni_x86.h Wed Dec 24 19:13:53 2008 -0800
@@ -32,7 +32,13 @@
#define JNICALL
typedef int jint;
+
+#ifdef _LP64
+ typedef long jlong;
+#else
typedef long long jlong;
+#endif
+
#else
#define JNIEXPORT __declspec(dllexport)
#define JNIIMPORT __declspec(dllimport)
--- a/hotspot/src/os/linux/vm/os_linux.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/os/linux/vm/os_linux.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -1160,7 +1160,10 @@
/* 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 */
/* 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 */
- i = sscanf(s, "%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld %lu %lu %ld %lu %lu %lu %lu",
+ i = sscanf(s, "%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu %ld %ld %ld %ld %ld %ld "
+ UINTX_FORMAT UINTX_FORMAT UINTX_FORMAT
+ " %lu "
+ UINTX_FORMAT UINTX_FORMAT UINTX_FORMAT,
&state, /* 3 %c */
&ppid, /* 4 %d */
&pgrp, /* 5 %d */
@@ -1180,13 +1183,13 @@
&nice, /* 19 %ld */
&junk, /* 20 %ld */
&it_real, /* 21 %ld */
- &start, /* 22 %lu */
- &vsize, /* 23 %lu */
- &rss, /* 24 %ld */
+ &start, /* 22 UINTX_FORMAT */
+ &vsize, /* 23 UINTX_FORMAT */
+ &rss, /* 24 UINTX_FORMAT */
&rsslim, /* 25 %lu */
- &scodes, /* 26 %lu */
- &ecode, /* 27 %lu */
- &stack_start); /* 28 %lu */
+ &scodes, /* 26 UINTX_FORMAT */
+ &ecode, /* 27 UINTX_FORMAT */
+ &stack_start); /* 28 UINTX_FORMAT */
}
if (i != 28 - 2) {
@@ -2024,7 +2027,8 @@
CAST_FROM_FN_PTR(address, os::jvm_path),
dli_fname, sizeof(dli_fname), NULL);
assert(ret != 0, "cannot locate libjvm");
- realpath(dli_fname, buf);
+ if (realpath(dli_fname, buf) == NULL)
+ return;
if (strcmp(Arguments::sun_java_launcher(), "gamma") == 0) {
// Support for the gamma launcher. Typical value for buf is
@@ -2048,7 +2052,8 @@
assert(strstr(p, "/libjvm") == p, "invalid library name");
p = strstr(p, "_g") ? "_g" : "";
- realpath(java_home_var, buf);
+ if (realpath(java_home_var, buf) == NULL)
+ return;
sprintf(buf + strlen(buf), "/jre/lib/%s", cpu_arch);
if (0 == access(buf, F_OK)) {
// Use current module name "libjvm[_g].so" instead of
@@ -2059,7 +2064,8 @@
sprintf(buf + strlen(buf), "/hotspot/libjvm%s.so", p);
} else {
// Go back to path of .so
- realpath(dli_fname, buf);
+ if (realpath(dli_fname, buf) == NULL)
+ return;
}
}
}
@@ -4184,11 +4190,11 @@
// Skip blank chars
do s++; while (isspace(*s));
- count = sscanf(s,"%c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu",
- &idummy, &idummy, &idummy, &idummy, &idummy, &idummy,
+ count = sscanf(s,"%*c %d %d %d %d %d %lu %lu %lu %lu %lu %lu %lu",
+ &idummy, &idummy, &idummy, &idummy, &idummy,
&ldummy, &ldummy, &ldummy, &ldummy, &ldummy,
&user_time, &sys_time);
- if ( count != 13 ) return -1;
+ if ( count != 12 ) return -1;
if (user_sys_cpu_time) {
return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec);
} else {
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -866,7 +866,7 @@
}
nmethod* nm = method->code();
if (WizardMode && nm != NULL) {
- sprintf(buf + (int)strlen(buf), "(nmethod %#x)", nm);
+ sprintf(buf + (int)strlen(buf), "(nmethod " PTR_FORMAT ")", (intptr_t)nm);
}
}
--- a/hotspot/src/share/vm/libadt/port.hpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/libadt/port.hpp Wed Dec 24 19:13:53 2008 -0800
@@ -34,17 +34,6 @@
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
-#undef bzero
-inline void bzero(void *b, int len) { memset(b,0,len); }
-#undef bcopy
-inline void bcopy(const void *s, void *d, size_t len) { memmove(d,s,len); }
-#undef bcmp
-inline int bcmp(const void *s,const void *t,int len) { return memcmp(s,t,len);}
-extern "C" unsigned long strtoul(const char *s, char **end, int base);
-
-// Definition for sys_errlist varies from Sun 4.1 & Solaris.
-// We use the new Solaris definition.
-#include <string.h>
// Access to the C++ class virtual function pointer
// Put the class in the macro
--- a/hotspot/src/share/vm/oops/constantPoolOop.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/oops/constantPoolOop.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -962,7 +962,7 @@
}
case JVM_CONSTANT_Long: {
u8 val = Bytes::get_Java_u8(bytes);
- printf("long %lldl", *(jlong *) &val);
+ printf("long "INT64_FORMAT, *(jlong *) &val);
ent_size = 8;
idx++; // Long takes two cpool slots
break;
--- a/hotspot/src/share/vm/oops/oopsHierarchy.hpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/oops/oopsHierarchy.hpp Wed Dec 24 19:13:53 2008 -0800
@@ -126,8 +126,11 @@
operator jobject () const { return (jobject)obj(); }
// from javaClasses.cpp
operator JavaThread* () const { return (JavaThread*)obj(); }
+
+#ifndef _LP64
// from jvm.cpp
operator jlong* () const { return (jlong*)obj(); }
+#endif
// from parNewGeneration and other things that want to get to the end of
// an oop for stuff (like constMethodKlass.cpp, objArrayKlass.cpp)
--- a/hotspot/src/share/vm/opto/idealGraphPrinter.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/opto/idealGraphPrinter.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -557,7 +557,7 @@
// max. 2 chars allowed
if (value >= -9 && value <= 99) {
- sprintf(buffer, "%d", value);
+ sprintf(buffer, INT64_FORMAT, value);
print_prop(short_name, buffer);
} else {
print_prop(short_name, "L");
--- a/hotspot/src/share/vm/prims/jvm.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/prims/jvm.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -2475,7 +2475,8 @@
if (Arguments::vfprintf_hook() != NULL) {
jio_fprintf(defaultStream::output_stream(), "%s", s);
} else {
- ::write(defaultStream::output_fd(), s, (int)strlen(s));
+ // Make an unused local variable to avoid warning from gcc 4.x compiler.
+ size_t count = ::write(defaultStream::output_fd(), s, (int)strlen(s));
}
}
--- a/hotspot/src/share/vm/runtime/arguments.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/runtime/arguments.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -1361,7 +1361,7 @@
// Feed the cache size setting into the JDK
char buffer[1024];
- sprintf(buffer, "java.lang.Integer.IntegerCache.high=%d", AutoBoxCacheMax);
+ sprintf(buffer, "java.lang.Integer.IntegerCache.high=" INTX_FORMAT, AutoBoxCacheMax);
add_property(buffer);
}
if (AggressiveOpts && FLAG_IS_DEFAULT(DoEscapeAnalysis)) {
--- a/hotspot/src/share/vm/runtime/memprofiler.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/runtime/memprofiler.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -104,21 +104,22 @@
}
// Print trace line in log
- fprintf(_log_fp, "%6.1f,%5d,%5d,%6ld,%6ld,%6ld,%6ld,",
- os::elapsedTime(),
- Threads::number_of_threads(),
- SystemDictionary::number_of_classes(),
- Universe::heap()->used() / K,
- Universe::heap()->capacity() / K,
- Universe::heap()->permanent_used() / HWperKB,
- Universe::heap()->permanent_capacity() / HWperKB);
+ fprintf(_log_fp, "%6.1f,%5d,%5d," UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ","
+ UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ",",
+ os::elapsedTime(),
+ Threads::number_of_threads(),
+ SystemDictionary::number_of_classes(),
+ Universe::heap()->used() / K,
+ Universe::heap()->capacity() / K,
+ Universe::heap()->permanent_used() / HWperKB,
+ Universe::heap()->permanent_capacity() / HWperKB);
- fprintf(_log_fp, "%6ld,", CodeCache::capacity() / K);
+ fprintf(_log_fp, UINTX_FORMAT_W(6) ",", CodeCache::capacity() / K);
- fprintf(_log_fp, "%6ld,%6ld,%6ld\n",
- handles_memory_usage / K,
- resource_memory_usage / K,
- OopMapCache::memory_usage() / K);
+ fprintf(_log_fp, UINTX_FORMAT_W(6) "," UINTX_FORMAT_W(6) ",%6ld\n",
+ handles_memory_usage / K,
+ resource_memory_usage / K,
+ OopMapCache::memory_usage() / K);
fflush(_log_fp);
}
--- a/hotspot/src/share/vm/runtime/safepoint.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/runtime/safepoint.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -730,7 +730,7 @@
if (DieOnSafepointTimeout) {
char msg[1024];
VM_Operation *op = VMThread::vm_operation();
- sprintf(msg, "Safepoint sync time longer than %d ms detected when executing %s.",
+ sprintf(msg, "Safepoint sync time longer than " INTX_FORMAT "ms detected when executing %s.",
SafepointTimeoutDelay,
op != NULL ? op->name() : "no vm operation");
fatal(msg);
--- a/hotspot/src/share/vm/runtime/synchronizer.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/runtime/synchronizer.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -424,7 +424,7 @@
// asserts is that error message -- often something about negative array
// indices -- is opaque.
-#define CTASSERT(x) { int tag[1-(2*!(x))]; printf ("Tag @%X\n", tag); }
+#define CTASSERT(x) { int tag[1-(2*!(x))]; printf ("Tag @" INTPTR_FORMAT "\n", (intptr_t)tag); }
void ObjectMonitor::ctAsserts() {
CTASSERT(offset_of (ObjectMonitor, _header) == 0);
--- a/hotspot/src/share/vm/utilities/globalDefinitions.hpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/utilities/globalDefinitions.hpp Wed Dec 24 19:13:53 2008 -0800
@@ -1087,15 +1087,24 @@
// Format macros that allow the field width to be specified. The width must be
// a string literal (e.g., "8") or a macro that evaluates to one.
#ifdef _LP64
+#define UINTX_FORMAT_W(width) UINT64_FORMAT_W(width)
#define SSIZE_FORMAT_W(width) INT64_FORMAT_W(width)
#define SIZE_FORMAT_W(width) UINT64_FORMAT_W(width)
#else
+#define UINTX_FORMAT_W(width) UINT32_FORMAT_W(width)
#define SSIZE_FORMAT_W(width) INT32_FORMAT_W(width)
#define SIZE_FORMAT_W(width) UINT32_FORMAT_W(width)
#endif // _LP64
// Format pointers and size_t (or size_t-like integer types) which change size
-// between 32- and 64-bit.
+// between 32- and 64-bit. The pointer format theoretically should be "%p",
+// however, it has different output on different platforms. On Windows, the data
+// will be padded with zeros automatically. On Solaris, we can use "%016p" &
+// "%08p" on 64 bit & 32 bit platforms to make the data padded with extra zeros.
+// On Linux, "%016p" or "%08p" is not be allowed, at least on the latest GCC
+// 4.3.2. So we have to use "%016x" or "%08x" to simulate the printing format.
+// GCC 4.3.2, however requires the data to be converted to "intptr_t" when
+// using "%x".
#ifdef _LP64
#define PTR_FORMAT PTR64_FORMAT
#define UINTX_FORMAT UINT64_FORMAT
--- a/hotspot/src/share/vm/utilities/ostream.cpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/utilities/ostream.cpp Wed Dec 24 19:13:53 2008 -0800
@@ -300,7 +300,10 @@
}
void fileStream::write(const char* s, size_t len) {
- if (_file != NULL) fwrite(s, 1, len, _file);
+ if (_file != NULL) {
+ // Make an unused local variable to avoid warning from gcc 4.x compiler.
+ size_t count = fwrite(s, 1, len, _file);
+ }
update_position(s, len);
}
@@ -328,7 +331,10 @@
}
void fdStream::write(const char* s, size_t len) {
- if (_fd != -1) ::write(_fd, s, (int)len);
+ if (_fd != -1) {
+ // Make an unused local variable to avoid warning from gcc 4.x compiler.
+ size_t count = ::write(_fd, s, (int)len);
+ }
update_position(s, len);
}
--- a/hotspot/src/share/vm/utilities/vmError.hpp Wed Dec 24 13:06:09 2008 -0800
+++ b/hotspot/src/share/vm/utilities/vmError.hpp Wed Dec 24 19:13:53 2008 -0800
@@ -50,7 +50,7 @@
// additional info for VM internal errors
const char * _filename;
- int _lineno;
+ size_t _lineno;
// used by fatal error handler
int _current_step;