提交 c6c05ae8 编写于 作者: X xlu

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
上级 685101a3
......@@ -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;
......@@ -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)
......
......@@ -1160,7 +1160,10 @@ void os::Linux::capture_initial_stack(size_t max_size) {
/* 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 @@ void os::Linux::capture_initial_stack(size_t max_size) {
&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 @@ void os::jvm_path(char *buf, jint len) {
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 @@ void os::jvm_path(char *buf, jint len) {
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 @@ void os::jvm_path(char *buf, jint len) {
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 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) {
// 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 {
......
......@@ -866,7 +866,7 @@ char* java_lang_Throwable::print_stack_element_to_buffer(methodOop method, int b
}
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);
}
}
......
......@@ -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
......
......@@ -962,7 +962,7 @@ static void print_cpool_bytes(jint cnt, u1 *bytes) {
}
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;
......
......@@ -126,8 +126,11 @@ public:
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)
......
......@@ -557,7 +557,7 @@ void IdealGraphPrinter::visit_node(Node *n, void *param) {
// 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");
......
......@@ -2475,7 +2475,8 @@ void jio_print(const char* s) {
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));
}
}
......
......@@ -1361,7 +1361,7 @@ void Arguments::set_aggressive_opts_flags() {
// 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)) {
......
......@@ -104,21 +104,22 @@ void MemProfiler::do_trace() {
}
// 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, "%6ld,", 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, "%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, UINTX_FORMAT_W(6) ",", CodeCache::capacity() / 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);
}
......
......@@ -730,7 +730,7 @@ void SafepointSynchronize::print_safepoint_timeout(SafepointTimeoutReason reason
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);
......
......@@ -424,7 +424,7 @@ void ObjectSynchronizer::Initialize () {
// 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);
......
......@@ -1087,15 +1087,24 @@ inline int build_int_from_shorts( jushort low, jushort high ) {
// 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
......
......@@ -300,7 +300,10 @@ fileStream::fileStream(const char* file_name) {
}
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 @@ fdStream::~fdStream() {
}
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);
}
......
......@@ -50,7 +50,7 @@ class VMError : public StackObj {
// additional info for VM internal errors
const char * _filename;
int _lineno;
size_t _lineno;
// used by fatal error handler
int _current_step;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册