1 #ifdef USE_PRAGMA_IDENT_HDR
   2 #pragma ident "@(#)os_linux.inline.hpp  1.31 07/06/29 04:01:54 JVM"
   3 #endif
   4 /*
   5  * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
   6  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   7  *
   8  * This code is free software; you can redistribute it and/or modify it
   9  * under the terms of the GNU General Public License version 2 only, as
  10  * published by the Free Software Foundation.
  11  *
  12  * This code is distributed in the hope that it will be useful, but WITHOUT
  13  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  14  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  15  * version 2 for more details (a copy is included in the LICENSE file that
  16  * accompanied this code).
  17  *
  18  * You should have received a copy of the GNU General Public License version
  19  * 2 along with this work; if not, write to the Free Software Foundation,
  20  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  21  *
  22  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  23  * CA 95054 USA or visit www.sun.com if you need additional information or
  24  * have any questions.
  25  *  
  26  */
  27 
  28 inline void* os::thread_local_storage_at(int index) {
  29   return pthread_getspecific((pthread_key_t)index);
  30 }
  31 
  32 inline const char* os::file_separator() {
  33   return "/";
  34 }
  35 
  36 inline const char* os::line_separator() {
  37   return "\n";
  38 }
  39 
  40 inline const char* os::path_separator() {
  41   return ":";
  42 }
  43 
  44 inline const char* os::jlong_format_specifier() {
  45   return "%lld";
  46 }
  47 
  48 inline const char* os::julong_format_specifier() {
  49   return "%llu";
  50 }
  51 
  52 // File names are case-sensitive on windows only
  53 inline int os::file_name_strcmp(const char* s1, const char* s2) {
  54   return strcmp(s1, s2);
  55 }
  56 
  57 inline bool os::obsolete_option(const JavaVMOption *option) {
  58   return false;
  59 }
  60 
  61 inline bool os::uses_stack_guard_pages() {
  62   return true;
  63 }
  64 
  65 inline bool os::allocate_stack_guard_pages() {
  66   assert(uses_stack_guard_pages(), "sanity check");
  67   return true;
  68 }
  69 
  70 
  71 // On Linux, reservations are made on a page by page basis, nothing to do.
  72 inline void os::split_reserved_memory(char *base, size_t size,
  73                                       size_t split, bool realloc) {
  74 }
  75 
  76 
  77 // Bang the shadow pages if they need to be touched to be mapped.
  78 inline void os::bang_stack_shadow_pages() {
  79 }
  80 
  81 inline DIR* os::opendir(const char* dirname)
  82 {
  83   assert(dirname != NULL, "just checking");
  84   return ::opendir(dirname);
  85 }
  86 
  87 inline int os::readdir_buf_size(const char *path)
  88 {
  89   return NAME_MAX + sizeof(dirent) + 1;
  90 }
  91 
  92 inline struct dirent* os::readdir(DIR* dirp, dirent *dbuf)
  93 {
  94   dirent* p;
  95   int status;
  96   assert(dirp != NULL, "just checking");
  97 
  98   // NOTE: Linux readdir_r (on RH 6.2 and 7.2 at least) is NOT like the POSIX
  99   // version. Here is the doc for this function:
 100   // http://www.gnu.org/manual/glibc-2.2.3/html_node/libc_262.html
 101 
 102   if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
 103     errno = status;
 104     return NULL;
 105   } else
 106     return p;
 107 }
 108 
 109 inline int os::closedir(DIR *dirp)
 110 {
 111   assert(dirp != NULL, "just checking");
 112   return ::closedir(dirp);
 113 }
 114 
 115 // macros for restartable system calls
 116 
 117 #define RESTARTABLE(_cmd, _result) do { \
 118     _result = _cmd; \
 119   } while(((int)_result == OS_ERR) && (errno == EINTR))
 120 
 121 #define RESTARTABLE_RETURN_INT(_cmd) do { \
 122   int _result; \
 123   RESTARTABLE(_cmd, _result); \
 124   return _result; \
 125 } while(false)
 126 
 127 inline bool os::numa_has_static_binding()   { return true; }
 128 inline bool os::numa_has_group_homing()     { return false;  }