src/os/aix/vm/os_aix.cpp

changeset 6556
6048424d3865
parent 6519
941427282eae
child 6807
514c03fe3a35
child 6911
ce8f6bb717c9
     1.1 --- a/src/os/aix/vm/os_aix.cpp	Thu Feb 27 09:37:16 2014 +0100
     1.2 +++ b/src/os/aix/vm/os_aix.cpp	Thu Apr 10 04:07:45 2014 -0700
     1.3 @@ -60,8 +60,8 @@
     1.4  #include "runtime/sharedRuntime.hpp"
     1.5  #include "runtime/statSampler.hpp"
     1.6  #include "runtime/stubRoutines.hpp"
     1.7 +#include "runtime/thread.inline.hpp"
     1.8  #include "runtime/threadCritical.hpp"
     1.9 -#include "runtime/thread.inline.hpp"
    1.10  #include "runtime/timer.hpp"
    1.11  #include "services/attachListener.hpp"
    1.12  #include "services/runtimeService.hpp"
    1.13 @@ -70,16 +70,6 @@
    1.14  #include "utilities/events.hpp"
    1.15  #include "utilities/growableArray.hpp"
    1.16  #include "utilities/vmError.hpp"
    1.17 -#ifdef TARGET_ARCH_ppc
    1.18 -# include "assembler_ppc.inline.hpp"
    1.19 -# include "nativeInst_ppc.hpp"
    1.20 -#endif
    1.21 -#ifdef COMPILER1
    1.22 -#include "c1/c1_Runtime1.hpp"
    1.23 -#endif
    1.24 -#ifdef COMPILER2
    1.25 -#include "opto/runtime.hpp"
    1.26 -#endif
    1.27  
    1.28  // put OS-includes here (sorted alphabetically)
    1.29  #include <errno.h>
    1.30 @@ -378,13 +368,14 @@
    1.31    assert(_page_size == SIZE_4K, "surprise!");
    1.32  
    1.33  
    1.34 -  // query default data page size (default page size for C-Heap, pthread stacks and .bss).
    1.35 +  // Query default data page size (default page size for C-Heap, pthread stacks and .bss).
    1.36    // Default data page size is influenced either by linker options (-bdatapsize)
    1.37    // or by environment variable LDR_CNTRL (suboption DATAPSIZE). If none is given,
    1.38    // default should be 4K.
    1.39    size_t data_page_size = SIZE_4K;
    1.40    {
    1.41      void* p = ::malloc(SIZE_16M);
    1.42 +    guarantee(p != NULL, "malloc failed");
    1.43      data_page_size = os::Aix::query_pagesize(p);
    1.44      ::free(p);
    1.45    }
    1.46 @@ -511,85 +502,76 @@
    1.47  
    1.48  } // end os::Aix::query_multipage_support()
    1.49  
    1.50 -
    1.51 -// The code for this method was initially derived from the version in os_linux.cpp
    1.52 +// The code for this method was initially derived from the version in os_linux.cpp.
    1.53  void os::init_system_properties_values() {
    1.54 -  // The next few definitions allow the code to be verbatim:
    1.55 -#define malloc(n) (char*)NEW_C_HEAP_ARRAY(char, (n), mtInternal)
    1.56 +
    1.57  #define DEFAULT_LIBPATH "/usr/lib:/lib"
    1.58  #define EXTENSIONS_DIR  "/lib/ext"
    1.59  #define ENDORSED_DIR    "/lib/endorsed"
    1.60  
    1.61 +  // Buffer that fits several sprintfs.
    1.62 +  // Note that the space for the trailing null is provided
    1.63 +  // by the nulls included by the sizeof operator.
    1.64 +  const size_t bufsize =
    1.65 +    MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
    1.66 +         (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR), // extensions dir
    1.67 +         (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
    1.68 +  char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
    1.69 +
    1.70    // sysclasspath, java_home, dll_dir
    1.71 -  char *home_path;
    1.72 -  char *dll_path;
    1.73 -  char *pslash;
    1.74 -  char buf[MAXPATHLEN];
    1.75 -  os::jvm_path(buf, sizeof(buf));
    1.76 -
    1.77 -  // Found the full path to libjvm.so.
    1.78 -  // Now cut the path to <java_home>/jre if we can.
    1.79 -  *(strrchr(buf, '/')) = '\0'; // get rid of /libjvm.so
    1.80 -  pslash = strrchr(buf, '/');
    1.81 -  if (pslash != NULL) {
    1.82 -    *pslash = '\0';            // get rid of /{client|server|hotspot}
    1.83 -  }
    1.84 -
    1.85 -  dll_path = malloc(strlen(buf) + 1);
    1.86 -  strcpy(dll_path, buf);
    1.87 -  Arguments::set_dll_dir(dll_path);
    1.88 -
    1.89 -  if (pslash != NULL) {
    1.90 +  {
    1.91 +    char *pslash;
    1.92 +    os::jvm_path(buf, bufsize);
    1.93 +
    1.94 +    // Found the full path to libjvm.so.
    1.95 +    // Now cut the path to <java_home>/jre if we can.
    1.96 +    *(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
    1.97      pslash = strrchr(buf, '/');
    1.98      if (pslash != NULL) {
    1.99 -      *pslash = '\0';          // get rid of /<arch>
   1.100 +      *pslash = '\0';            // Get rid of /{client|server|hotspot}.
   1.101 +    }
   1.102 +    Arguments::set_dll_dir(buf);
   1.103 +
   1.104 +    if (pslash != NULL) {
   1.105        pslash = strrchr(buf, '/');
   1.106        if (pslash != NULL) {
   1.107 -        *pslash = '\0';        // get rid of /lib
   1.108 +        *pslash = '\0';          // Get rid of /<arch>.
   1.109 +        pslash = strrchr(buf, '/');
   1.110 +        if (pslash != NULL) {
   1.111 +          *pslash = '\0';        // Get rid of /lib.
   1.112 +        }
   1.113        }
   1.114      }
   1.115 -  }
   1.116 -
   1.117 -  home_path = malloc(strlen(buf) + 1);
   1.118 -  strcpy(home_path, buf);
   1.119 -  Arguments::set_java_home(home_path);
   1.120 -
   1.121 -  if (!set_boot_path('/', ':')) return;
   1.122 -
   1.123 -  // Where to look for native libraries
   1.124 -
   1.125 -  // On Aix we get the user setting of LIBPATH
   1.126 +    Arguments::set_java_home(buf);
   1.127 +    set_boot_path('/', ':');
   1.128 +  }
   1.129 +
   1.130 +  // Where to look for native libraries.
   1.131 +
   1.132 +  // On Aix we get the user setting of LIBPATH.
   1.133    // Eventually, all the library path setting will be done here.
   1.134 -  char *ld_library_path;
   1.135 -
   1.136 -  // Construct the invariant part of ld_library_path.
   1.137 -  ld_library_path = (char *) malloc(sizeof(DEFAULT_LIBPATH));
   1.138 -  sprintf(ld_library_path, DEFAULT_LIBPATH);
   1.139 -
   1.140 -  // Get the user setting of LIBPATH, and prepended it.
   1.141 -  char *v = ::getenv("LIBPATH");
   1.142 -  if (v == NULL) {
   1.143 -    v = "";
   1.144 -  }
   1.145 -
   1.146 -  char *t = ld_library_path;
   1.147 -  // That's +1 for the colon and +1 for the trailing '\0'
   1.148 -  ld_library_path = (char *) malloc(strlen(v) + 1 + strlen(t) + 1);
   1.149 -  sprintf(ld_library_path, "%s:%s", v, t);
   1.150 -
   1.151 +  // Get the user setting of LIBPATH.
   1.152 +  const char *v = ::getenv("LIBPATH");
   1.153 +  const char *v_colon = ":";
   1.154 +  if (v == NULL) { v = ""; v_colon = ""; }
   1.155 +
   1.156 +  // Concatenate user and invariant part of ld_library_path.
   1.157 +  // That's +1 for the colon and +1 for the trailing '\0'.
   1.158 +  char *ld_library_path = (char *)NEW_C_HEAP_ARRAY(char, strlen(v) + 1 + sizeof(DEFAULT_LIBPATH) + 1, mtInternal);
   1.159 +  sprintf(ld_library_path, "%s%s" DEFAULT_LIBPATH, v, v_colon);
   1.160    Arguments::set_library_path(ld_library_path);
   1.161 -
   1.162 -  // Extensions directories
   1.163 -  char* cbuf = malloc(strlen(Arguments::get_java_home()) + sizeof(EXTENSIONS_DIR));
   1.164 -  sprintf(cbuf, "%s" EXTENSIONS_DIR, Arguments::get_java_home());
   1.165 -  Arguments::set_ext_dirs(cbuf);
   1.166 +  FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
   1.167 +
   1.168 +  // Extensions directories.
   1.169 +  sprintf(buf, "%s" EXTENSIONS_DIR, Arguments::get_java_home());
   1.170 +  Arguments::set_ext_dirs(buf);
   1.171  
   1.172    // Endorsed standards default directory.
   1.173 -  cbuf = malloc(strlen(Arguments::get_java_home()) + sizeof(ENDORSED_DIR));
   1.174 -  sprintf(cbuf, "%s" ENDORSED_DIR, Arguments::get_java_home());
   1.175 -  Arguments::set_endorsed_dirs(cbuf);
   1.176 -
   1.177 -#undef malloc
   1.178 +  sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
   1.179 +  Arguments::set_endorsed_dirs(buf);
   1.180 +
   1.181 +  FREE_C_HEAP_ARRAY(char, buf, mtInternal);
   1.182 +
   1.183  #undef DEFAULT_LIBPATH
   1.184  #undef EXTENSIONS_DIR
   1.185  #undef ENDORSED_DIR

mercurial