< prev index next >

src/os/posix/vm/os_posix.cpp

Print this page
rev 11647 : 8161258: Simplify including platform files.
Summary: Include patform files with macros cpu_header() etc. Do various cleanups of macro usages. Remove _64/_32 from adlc generated files and platform .hpp files. Merge stubRoutines_x86*.hpp. Remove empty mutex_<os>* files.
Reviewed-by: dholmes, coleenp, kbarrett


  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "utilities/globalDefinitions.hpp"
  26 #include "prims/jvm.h"
  27 #include "semaphore_posix.hpp"
  28 #include "runtime/frame.inline.hpp"
  29 #include "runtime/interfaceSupport.hpp"
  30 #include "runtime/os.hpp"

  31 #include "utilities/vmError.hpp"
  32 
  33 #include <signal.h>
  34 #include <unistd.h>
  35 #include <sys/resource.h>
  36 #include <sys/utsname.h>
  37 #include <pthread.h>
  38 #include <semaphore.h>
  39 #include <signal.h>
  40 
  41 // Todo: provide a os::get_max_process_id() or similar. Number of processes
  42 // may have been configured, can be read more accurately from proc fs etc.
  43 #ifndef MAX_PID
  44 #define MAX_PID INT_MAX
  45 #endif
  46 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
  47 
  48 // Check core dump limit and report possible place where core can be found
  49 void os::check_dump_limit(char* buffer, size_t bufferSize) {
  50   if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {


 197   os::loadavg(loadavg, 3);
 198   st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
 199   st->cr();
 200 }
 201 
 202 void os::Posix::print_rlimit_info(outputStream* st) {
 203   st->print("rlimit:");
 204   struct rlimit rlim;
 205 
 206   st->print(" STACK ");
 207   getrlimit(RLIMIT_STACK, &rlim);
 208   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 209   else st->print("%luk", rlim.rlim_cur >> 10);
 210 
 211   st->print(", CORE ");
 212   getrlimit(RLIMIT_CORE, &rlim);
 213   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 214   else st->print("%luk", rlim.rlim_cur >> 10);
 215 
 216   // Isn't there on solaris
 217 #if !defined(TARGET_OS_FAMILY_solaris) && !defined(TARGET_OS_FAMILY_aix)
 218   st->print(", NPROC ");
 219   getrlimit(RLIMIT_NPROC, &rlim);
 220   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 221   else st->print("%lu", rlim.rlim_cur);
 222 #endif
 223 
 224   st->print(", NOFILE ");
 225   getrlimit(RLIMIT_NOFILE, &rlim);
 226   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 227   else st->print("%lu", rlim.rlim_cur);
 228 
 229   st->print(", AS ");
 230   getrlimit(RLIMIT_AS, &rlim);
 231   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 232   else st->print("%luk", rlim.rlim_cur >> 10);
 233   st->cr();
 234 }
 235 
 236 void os::Posix::print_uname_info(outputStream* st) {
 237   // kernel


1045     os->print(", si_uid: %ld", (long) si->si_uid);
1046     if (sig == SIGCHLD) {
1047       os->print(", si_status: %d", si->si_status);
1048     }
1049   } else if (sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
1050              sig == SIGTRAP || sig == SIGFPE) {
1051     os->print(", si_addr: " PTR_FORMAT, p2i(si->si_addr));
1052 #ifdef SIGPOLL
1053   } else if (sig == SIGPOLL) {
1054     os->print(", si_band: %ld", si->si_band);
1055 #endif
1056   }
1057 
1058 }
1059 
1060 int os::Posix::unblock_thread_signal_mask(const sigset_t *set) {
1061   return pthread_sigmask(SIG_UNBLOCK, set, NULL);
1062 }
1063 
1064 address os::Posix::ucontext_get_pc(const ucontext_t* ctx) {
1065 #ifdef TARGET_OS_FAMILY_linux
1066    return Linux::ucontext_get_pc(ctx);
1067 #elif defined(TARGET_OS_FAMILY_solaris)
1068    return Solaris::ucontext_get_pc(ctx);
1069 #elif defined(TARGET_OS_FAMILY_aix)
1070    return Aix::ucontext_get_pc(ctx);
1071 #elif defined(TARGET_OS_FAMILY_bsd)
1072    return Bsd::ucontext_get_pc(ctx);




1073 #else
1074    VMError::report_and_die("unimplemented ucontext_get_pc");
1075 #endif
1076 }
1077 
1078 void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) {
1079 #ifdef TARGET_OS_FAMILY_linux
1080    Linux::ucontext_set_pc(ctx, pc);
1081 #elif defined(TARGET_OS_FAMILY_solaris)
1082    Solaris::ucontext_set_pc(ctx, pc);
1083 #elif defined(TARGET_OS_FAMILY_aix)
1084    Aix::ucontext_set_pc(ctx, pc);
1085 #elif defined(TARGET_OS_FAMILY_bsd)
1086    Bsd::ucontext_set_pc(ctx, pc);




1087 #else
1088    VMError::report_and_die("unimplemented ucontext_get_pc");
1089 #endif
1090 }
1091 
1092 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1093   size_t stack_size = 0;
1094   size_t guard_size = 0;
1095   int detachstate = 0;
1096   pthread_attr_getstacksize(attr, &stack_size);
1097   pthread_attr_getguardsize(attr, &guard_size);
1098   pthread_attr_getdetachstate(attr, &detachstate);
1099   jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1100     stack_size / 1024, guard_size / 1024,
1101     (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1102   return buf;
1103 }
1104 
1105 
1106 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {




  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "utilities/globalDefinitions.hpp"
  26 #include "prims/jvm.h"
  27 #include "semaphore_posix.hpp"
  28 #include "runtime/frame.inline.hpp"
  29 #include "runtime/interfaceSupport.hpp"
  30 #include "runtime/os.hpp"
  31 #include "utilities/macros.hpp"
  32 #include "utilities/vmError.hpp"
  33 
  34 #include <signal.h>
  35 #include <unistd.h>
  36 #include <sys/resource.h>
  37 #include <sys/utsname.h>
  38 #include <pthread.h>
  39 #include <semaphore.h>
  40 #include <signal.h>
  41 
  42 // Todo: provide a os::get_max_process_id() or similar. Number of processes
  43 // may have been configured, can be read more accurately from proc fs etc.
  44 #ifndef MAX_PID
  45 #define MAX_PID INT_MAX
  46 #endif
  47 #define IS_VALID_PID(p) (p > 0 && p < MAX_PID)
  48 
  49 // Check core dump limit and report possible place where core can be found
  50 void os::check_dump_limit(char* buffer, size_t bufferSize) {
  51   if (!FLAG_IS_DEFAULT(CreateCoredumpOnCrash) && !CreateCoredumpOnCrash) {


 198   os::loadavg(loadavg, 3);
 199   st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]);
 200   st->cr();
 201 }
 202 
 203 void os::Posix::print_rlimit_info(outputStream* st) {
 204   st->print("rlimit:");
 205   struct rlimit rlim;
 206 
 207   st->print(" STACK ");
 208   getrlimit(RLIMIT_STACK, &rlim);
 209   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 210   else st->print("%luk", rlim.rlim_cur >> 10);
 211 
 212   st->print(", CORE ");
 213   getrlimit(RLIMIT_CORE, &rlim);
 214   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 215   else st->print("%luk", rlim.rlim_cur >> 10);
 216 
 217   // Isn't there on solaris
 218 #if !defined(SOLARIS) && !defined(AIX)
 219   st->print(", NPROC ");
 220   getrlimit(RLIMIT_NPROC, &rlim);
 221   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 222   else st->print("%lu", rlim.rlim_cur);
 223 #endif
 224 
 225   st->print(", NOFILE ");
 226   getrlimit(RLIMIT_NOFILE, &rlim);
 227   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 228   else st->print("%lu", rlim.rlim_cur);
 229 
 230   st->print(", AS ");
 231   getrlimit(RLIMIT_AS, &rlim);
 232   if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity");
 233   else st->print("%luk", rlim.rlim_cur >> 10);
 234   st->cr();
 235 }
 236 
 237 void os::Posix::print_uname_info(outputStream* st) {
 238   // kernel


1046     os->print(", si_uid: %ld", (long) si->si_uid);
1047     if (sig == SIGCHLD) {
1048       os->print(", si_status: %d", si->si_status);
1049     }
1050   } else if (sig == SIGSEGV || sig == SIGBUS || sig == SIGILL ||
1051              sig == SIGTRAP || sig == SIGFPE) {
1052     os->print(", si_addr: " PTR_FORMAT, p2i(si->si_addr));
1053 #ifdef SIGPOLL
1054   } else if (sig == SIGPOLL) {
1055     os->print(", si_band: %ld", si->si_band);
1056 #endif
1057   }
1058 
1059 }
1060 
1061 int os::Posix::unblock_thread_signal_mask(const sigset_t *set) {
1062   return pthread_sigmask(SIG_UNBLOCK, set, NULL);
1063 }
1064 
1065 address os::Posix::ucontext_get_pc(const ucontext_t* ctx) {
1066 #if defined(AIX)




1067    return Aix::ucontext_get_pc(ctx);
1068 #elif defined(BSD)
1069    return Bsd::ucontext_get_pc(ctx);
1070 #elif defined(LINUX)
1071    return Linux::ucontext_get_pc(ctx);
1072 #elif defined(SOLARIS)
1073    return Solaris::ucontext_get_pc(ctx);
1074 #else
1075    VMError::report_and_die("unimplemented ucontext_get_pc");
1076 #endif
1077 }
1078 
1079 void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) {
1080 #if defined(AIX)




1081    Aix::ucontext_set_pc(ctx, pc);
1082 #elif defined(BSD)
1083    Bsd::ucontext_set_pc(ctx, pc);
1084 #elif defined(LINUX)
1085    Linux::ucontext_set_pc(ctx, pc);
1086 #elif defined(SOLARIS)
1087    Solaris::ucontext_set_pc(ctx, pc);
1088 #else
1089    VMError::report_and_die("unimplemented ucontext_get_pc");
1090 #endif
1091 }
1092 
1093 char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) {
1094   size_t stack_size = 0;
1095   size_t guard_size = 0;
1096   int detachstate = 0;
1097   pthread_attr_getstacksize(attr, &stack_size);
1098   pthread_attr_getguardsize(attr, &guard_size);
1099   pthread_attr_getdetachstate(attr, &detachstate);
1100   jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s",
1101     stack_size / 1024, guard_size / 1024,
1102     (detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable"));
1103   return buf;
1104 }
1105 
1106 
1107 os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() {


< prev index next >