hotspot/src/os/linux/vm/os_linux.cpp
changeset 29181 89beae49867c
parent 29180 50369728b00e
parent 27926 0e2e188ab887
child 29185 41cf0610fedf
equal deleted inserted replaced
29180:50369728b00e 29181:89beae49867c
    66 #include "utilities/decoder.hpp"
    66 #include "utilities/decoder.hpp"
    67 #include "utilities/defaultStream.hpp"
    67 #include "utilities/defaultStream.hpp"
    68 #include "utilities/events.hpp"
    68 #include "utilities/events.hpp"
    69 #include "utilities/elfFile.hpp"
    69 #include "utilities/elfFile.hpp"
    70 #include "utilities/growableArray.hpp"
    70 #include "utilities/growableArray.hpp"
       
    71 #include "utilities/macros.hpp"
    71 #include "utilities/vmError.hpp"
    72 #include "utilities/vmError.hpp"
    72 
    73 
    73 // put OS-includes here
    74 // put OS-includes here
    74 # include <sys/types.h>
    75 # include <sys/types.h>
    75 # include <sys/mman.h>
    76 # include <sys/mman.h>
   337 #endif
   338 #endif
   338 
   339 
   339 // Base path of extensions installed on the system.
   340 // Base path of extensions installed on the system.
   340 #define SYS_EXT_DIR     "/usr/java/packages"
   341 #define SYS_EXT_DIR     "/usr/java/packages"
   341 #define EXTENSIONS_DIR  "/lib/ext"
   342 #define EXTENSIONS_DIR  "/lib/ext"
   342 #define ENDORSED_DIR    "/lib/endorsed"
       
   343 
   343 
   344   // Buffer that fits several sprintfs.
   344   // Buffer that fits several sprintfs.
   345   // Note that the space for the colon and the trailing null are provided
   345   // Note that the space for the colon and the trailing null are provided
   346   // by the nulls included by the sizeof operator.
   346   // by the nulls included by the sizeof operator.
   347   const size_t bufsize =
   347   const size_t bufsize =
   348     MAX3((size_t)MAXPATHLEN,  // For dll_dir & friends.
   348     MAX2((size_t)MAXPATHLEN,  // For dll_dir & friends.
   349          (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR), // extensions dir
   349          (size_t)MAXPATHLEN + sizeof(EXTENSIONS_DIR) + sizeof(SYS_EXT_DIR) + sizeof(EXTENSIONS_DIR)); // extensions dir
   350          (size_t)MAXPATHLEN + sizeof(ENDORSED_DIR)); // endorsed dir
       
   351   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
   350   char *buf = (char *)NEW_C_HEAP_ARRAY(char, bufsize, mtInternal);
   352 
   351 
   353   // sysclasspath, java_home, dll_dir
   352   // sysclasspath, java_home, dll_dir
   354   {
   353   {
   355     char *pslash;
   354     char *pslash;
   403                                                      strlen(v) + 1 +
   402                                                      strlen(v) + 1 +
   404                                                      sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1,
   403                                                      sizeof(SYS_EXT_DIR) + sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1,
   405                                                      mtInternal);
   404                                                      mtInternal);
   406     sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
   405     sprintf(ld_library_path, "%s%s" SYS_EXT_DIR "/lib/%s:" DEFAULT_LIBPATH, v, v_colon, cpu_arch);
   407     Arguments::set_library_path(ld_library_path);
   406     Arguments::set_library_path(ld_library_path);
   408     FREE_C_HEAP_ARRAY(char, ld_library_path, mtInternal);
   407     FREE_C_HEAP_ARRAY(char, ld_library_path);
   409   }
   408   }
   410 
   409 
   411   // Extensions directories.
   410   // Extensions directories.
   412   sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
   411   sprintf(buf, "%s" EXTENSIONS_DIR ":" SYS_EXT_DIR EXTENSIONS_DIR, Arguments::get_java_home());
   413   Arguments::set_ext_dirs(buf);
   412   Arguments::set_ext_dirs(buf);
   414 
   413 
   415   // Endorsed standards default directory.
   414   FREE_C_HEAP_ARRAY(char, buf);
   416   sprintf(buf, "%s" ENDORSED_DIR, Arguments::get_java_home());
       
   417   Arguments::set_endorsed_dirs(buf);
       
   418 
       
   419   FREE_C_HEAP_ARRAY(char, buf, mtInternal);
       
   420 
   415 
   421 #undef DEFAULT_LIBPATH
   416 #undef DEFAULT_LIBPATH
   422 #undef SYS_EXT_DIR
   417 #undef SYS_EXT_DIR
   423 #undef EXTENSIONS_DIR
   418 #undef EXTENSIONS_DIR
   424 #undef ENDORSED_DIR
       
   425 }
   419 }
   426 
   420 
   427 ////////////////////////////////////////////////////////////////////////////////
   421 ////////////////////////////////////////////////////////////////////////////////
   428 // breakpoint support
   422 // breakpoint support
   429 
   423 
  1620       }
  1614       }
  1621     }
  1615     }
  1622     // release the storage
  1616     // release the storage
  1623     for (int i = 0; i < n; i++) {
  1617     for (int i = 0; i < n; i++) {
  1624       if (pelements[i] != NULL) {
  1618       if (pelements[i] != NULL) {
  1625         FREE_C_HEAP_ARRAY(char, pelements[i], mtInternal);
  1619         FREE_C_HEAP_ARRAY(char, pelements[i]);
  1626       }
  1620       }
  1627     }
  1621     }
  1628     if (pelements != NULL) {
  1622     if (pelements != NULL) {
  1629       FREE_C_HEAP_ARRAY(char*, pelements, mtInternal);
  1623       FREE_C_HEAP_ARRAY(char*, pelements);
  1630     }
  1624     }
  1631   } else {
  1625   } else {
  1632     snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
  1626     snprintf(buffer, buflen, "%s/lib%s.so", pname, fname);
  1633     retval = true;
  1627     retval = true;
  1634   }
  1628   }
  2941           }
  2935           }
  2942         }
  2936         }
  2943       }
  2937       }
  2944     }
  2938     }
  2945   }
  2939   }
  2946   FREE_C_HEAP_ARRAY(unsigned long, cpu_map, mtInternal);
  2940   FREE_C_HEAP_ARRAY(unsigned long, cpu_map);
  2947 }
  2941 }
  2948 
  2942 
  2949 int os::Linux::get_node_by_cpu(int cpu_id) {
  2943 int os::Linux::get_node_by_cpu(int cpu_id) {
  2950   if (cpu_to_node() != NULL && cpu_id >= 0 && cpu_id < cpu_to_node()->length()) {
  2944   if (cpu_to_node() != NULL && cpu_id >= 0 && cpu_id < cpu_to_node()->length()) {
  2951     return cpu_to_node()->at(cpu_id);
  2945     return cpu_to_node()->at(cpu_id);
  3787   }
  3781   }
  3788 }
  3782 }
  3789 
  3783 
  3790 size_t os::read(int fd, void *buf, unsigned int nBytes) {
  3784 size_t os::read(int fd, void *buf, unsigned int nBytes) {
  3791   return ::read(fd, buf, nBytes);
  3785   return ::read(fd, buf, nBytes);
       
  3786 }
       
  3787 
       
  3788 size_t os::read_at(int fd, void *buf, unsigned int nBytes, jlong offset) {
       
  3789   return ::pread(fd, buf, nBytes, offset);
  3792 }
  3790 }
  3793 
  3791 
  3794 // Short sleep, direct OS call.
  3792 // Short sleep, direct OS call.
  3795 //
  3793 //
  3796 // Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee
  3794 // Note: certain versions of Linux CFS scheduler (since 2.6.23) do not guarantee