Mercurial > hg > graal-jvmci-8
comparison src/os/linux/vm/os_linux.cpp @ 17937:78bbf4d43a14
8037816: Fix for 8036122 breaks build with Xcode5/clang
8043029: Change 8037816 breaks HS build with older GCC versions which don't support diagnostic pragmas
8043164: Format warning in traceStream.hpp
Summary: Backport of main fix + two corrections, enables clang compilation, turns on format attributes, corrects/mutes warnings
Reviewed-by: kvn, coleenp, iveresov, twisti
author | drchase |
---|---|
date | Thu, 22 May 2014 15:52:41 -0400 |
parents | 6048424d3865 |
children | f73af4455d7d ce8f6bb717c9 |
comparison
equal
deleted
inserted
replaced
17935:7384f6a12fc1 | 17937:78bbf4d43a14 |
---|---|
98 # include <sys/shm.h> | 98 # include <sys/shm.h> |
99 # include <link.h> | 99 # include <link.h> |
100 # include <stdint.h> | 100 # include <stdint.h> |
101 # include <inttypes.h> | 101 # include <inttypes.h> |
102 # include <sys/ioctl.h> | 102 # include <sys/ioctl.h> |
103 | |
104 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC | |
103 | 105 |
104 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling | 106 // if RUSAGE_THREAD for getrusage() has not been defined, do it here. The code calling |
105 // getrusage() is prepared to handle the associated failure. | 107 // getrusage() is prepared to handle the associated failure. |
106 #ifndef RUSAGE_THREAD | 108 #ifndef RUSAGE_THREAD |
107 #define RUSAGE_THREAD (1) /* only the calling thread */ | 109 #define RUSAGE_THREAD (1) /* only the calling thread */ |
2135 os::Posix::print_uname_info(st); | 2137 os::Posix::print_uname_info(st); |
2136 | 2138 |
2137 // Print warning if unsafe chroot environment detected | 2139 // Print warning if unsafe chroot environment detected |
2138 if (unsafe_chroot_detected) { | 2140 if (unsafe_chroot_detected) { |
2139 st->print("WARNING!! "); | 2141 st->print("WARNING!! "); |
2140 st->print_cr(unstable_chroot_error); | 2142 st->print_cr("%s", unstable_chroot_error); |
2141 } | 2143 } |
2142 | 2144 |
2143 os::Linux::print_libversion_info(st); | 2145 os::Linux::print_libversion_info(st); |
2144 | 2146 |
2145 os::Posix::print_rlimit_info(st); | 2147 os::Posix::print_rlimit_info(st); |
2196 } | 2198 } |
2197 | 2199 |
2198 void os::Linux::print_libversion_info(outputStream* st) { | 2200 void os::Linux::print_libversion_info(outputStream* st) { |
2199 // libc, pthread | 2201 // libc, pthread |
2200 st->print("libc:"); | 2202 st->print("libc:"); |
2201 st->print(os::Linux::glibc_version()); st->print(" "); | 2203 st->print("%s ", os::Linux::glibc_version()); |
2202 st->print(os::Linux::libpthread_version()); st->print(" "); | 2204 st->print("%s ", os::Linux::libpthread_version()); |
2203 if (os::Linux::is_LinuxThreads()) { | 2205 if (os::Linux::is_LinuxThreads()) { |
2204 st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed"); | 2206 st->print("(%s stack)", os::Linux::is_floating_stack() ? "floating" : "fixed"); |
2205 } | 2207 } |
2206 st->cr(); | 2208 st->cr(); |
2207 } | 2209 } |
3413 // they are so fragmented after a long run that they can't | 3415 // they are so fragmented after a long run that they can't |
3414 // coalesce into large pages. Try to reserve large pages when | 3416 // coalesce into large pages. Try to reserve large pages when |
3415 // the system is still "fresh". | 3417 // the system is still "fresh". |
3416 if (warn_on_failure) { | 3418 if (warn_on_failure) { |
3417 jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno); | 3419 jio_snprintf(msg, sizeof(msg), "Failed to reserve shared memory (errno = %d).", errno); |
3418 warning(msg); | 3420 warning("%s", msg); |
3419 } | 3421 } |
3420 return NULL; | 3422 return NULL; |
3421 } | 3423 } |
3422 | 3424 |
3423 // attach to the region | 3425 // attach to the region |
3431 shmctl(shmid, IPC_RMID, NULL); | 3433 shmctl(shmid, IPC_RMID, NULL); |
3432 | 3434 |
3433 if ((intptr_t)addr == -1) { | 3435 if ((intptr_t)addr == -1) { |
3434 if (warn_on_failure) { | 3436 if (warn_on_failure) { |
3435 jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err); | 3437 jio_snprintf(msg, sizeof(msg), "Failed to attach shared memory (errno = %d).", err); |
3436 warning(msg); | 3438 warning("%s", msg); |
3437 } | 3439 } |
3438 return NULL; | 3440 return NULL; |
3439 } | 3441 } |
3440 | 3442 |
3441 return addr; | 3443 return addr; |
3451 | 3453 |
3452 if (warn_on_failure) { | 3454 if (warn_on_failure) { |
3453 char msg[128]; | 3455 char msg[128]; |
3454 jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: " | 3456 jio_snprintf(msg, sizeof(msg), "Failed to reserve large pages memory req_addr: " |
3455 PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error); | 3457 PTR_FORMAT " bytes: " SIZE_FORMAT " (errno = %d).", req_addr, bytes, error); |
3456 warning(msg); | 3458 warning("%s", msg); |
3457 } | 3459 } |
3458 } | 3460 } |
3459 | 3461 |
3460 char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec) { | 3462 char* os::Linux::reserve_memory_special_huge_tlbfs_only(size_t bytes, char* req_addr, bool exec) { |
3461 assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages"); | 3463 assert(UseLargePages && UseHugeTLBFS, "only for Huge TLBFS large pages"); |
5390 | 5392 |
5391 // | 5393 // |
5392 // -1 on error. | 5394 // -1 on error. |
5393 // | 5395 // |
5394 | 5396 |
5397 PRAGMA_DIAG_PUSH | |
5398 PRAGMA_FORMAT_NONLITERAL_IGNORED | |
5395 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { | 5399 static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time) { |
5396 static bool proc_task_unchecked = true; | 5400 static bool proc_task_unchecked = true; |
5397 static const char *proc_stat_path = "/proc/%d/stat"; | 5401 static const char *proc_stat_path = "/proc/%d/stat"; |
5398 pid_t tid = thread->osthread()->thread_id(); | 5402 pid_t tid = thread->osthread()->thread_id(); |
5399 char *s; | 5403 char *s; |
5451 return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec); | 5455 return ((jlong)sys_time + (jlong)user_time) * (1000000000 / clock_tics_per_sec); |
5452 } else { | 5456 } else { |
5453 return (jlong)user_time * (1000000000 / clock_tics_per_sec); | 5457 return (jlong)user_time * (1000000000 / clock_tics_per_sec); |
5454 } | 5458 } |
5455 } | 5459 } |
5460 PRAGMA_DIAG_POP | |
5456 | 5461 |
5457 void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { | 5462 void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { |
5458 info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits | 5463 info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits |
5459 info_ptr->may_skip_backward = false; // elapsed time not wall time | 5464 info_ptr->may_skip_backward = false; // elapsed time not wall time |
5460 info_ptr->may_skip_forward = false; // elapsed time not wall time | 5465 info_ptr->may_skip_forward = false; // elapsed time not wall time |