src/os/solaris/vm/os_solaris.inline.hpp

Thu, 19 Mar 2009 09:13:24 -0700

author
kvn
date
Thu, 19 Mar 2009 09:13:24 -0700
changeset 1082
bd441136a5ce
parent 631
d1605aabd0a1
child 1907
c18cbe5936b8
permissions
-rw-r--r--

Merge

     1 /*
     2  * Copyright 1997-2008 Sun Microsystems, Inc.  All Rights Reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
    20  * CA 95054 USA or visit www.sun.com if you need additional information or
    21  * have any questions.
    22  *
    23  */
    25 inline const char* os::file_separator() { return "/"; }
    26 inline const char* os::line_separator() { return "\n"; }
    27 inline const char* os::path_separator() { return ":"; }
    29 inline const char* os::jlong_format_specifier()   { return "%lld"; }
    30 inline const char* os::julong_format_specifier()  { return "%llu"; }
    32 // File names are case-sensitive on windows only
    33 inline int os::file_name_strcmp(const char* s1, const char* s2) {
    34   return strcmp(s1, s2);
    35 }
    37 inline bool os::uses_stack_guard_pages() {
    38   return true;
    39 }
    41 inline bool os::allocate_stack_guard_pages() {
    42   assert(uses_stack_guard_pages(), "sanity check");
    43   int r = thr_main() ;
    44   guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
    45   return r;
    46 }
    49 // On Solaris, reservations are made on a page by page basis, nothing to do.
    50 inline void os::split_reserved_memory(char *base, size_t size,
    51                                       size_t split, bool realloc) {
    52 }
    55 // Bang the shadow pages if they need to be touched to be mapped.
    56 inline void os::bang_stack_shadow_pages() {
    57 }
    59 inline DIR* os::opendir(const char* dirname)
    60 {
    61   assert(dirname != NULL, "just checking");
    62   return ::opendir(dirname);
    63 }
    65 inline int os::readdir_buf_size(const char *path)
    66 {
    67   int size = pathconf(path, _PC_NAME_MAX);
    68   return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1;
    69 }
    71 inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf)
    72 {
    73   assert(dirp != NULL, "just checking");
    74 #if defined(_LP64) || defined(_GNU_SOURCE)
    75   dirent* p;
    76   int status;
    78   if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
    79     errno = status;
    80     return NULL;
    81   } else
    82     return p;
    83 #else  // defined(_LP64) || defined(_GNU_SOURCE)
    84   return ::readdir_r(dirp, dbuf);
    85 #endif // defined(_LP64) || defined(_GNU_SOURCE)
    86 }
    88 inline int os::closedir(DIR *dirp)
    89 {
    90   assert(dirp != NULL, "just checking");
    91   return ::closedir(dirp);
    92 }
    94 //////////////////////////////////////////////////////////////////////////////
    95 ////////////////////////////////////////////////////////////////////////////////
    97 // macros for interruptible io and system calls and system call restarting
    99 #define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \
   100 do { \
   101   _setup; \
   102   _before; \
   103   OSThread* _osthread = _thread->osthread(); \
   104   if (_int_enable && _thread->has_last_Java_frame()) { \
   105     /* this is java interruptible io stuff */ \
   106     if (os::is_interrupted(_thread, _clear))  { \
   107       os::Solaris::bump_interrupted_before_count(); \
   108       _result = OS_INTRPT; \
   109     } else { \
   110       /* _cmd always expands to an assignment to _result */ \
   111       if ((_cmd) < 0 && errno == EINTR  \
   112        && os::is_interrupted(_thread, _clear)) { \
   113         os::Solaris::bump_interrupted_during_count(); \
   114         _result = OS_INTRPT; \
   115       } \
   116     } \
   117   } else { \
   118     /* this is normal blocking io stuff */ \
   119     _cmd; \
   120   } \
   121   _after; \
   122 } while(false)
   124 // Interruptible io support + restarting of interrupted system calls
   126 #ifndef ASSERT
   128 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
   129   _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \
   130 } while((_result == OS_ERR) && (errno == EINTR))
   132 #else
   134 // This adds an assertion that it is only called from thread_in_native
   135 // The call overhead is skipped for performance in product mode
   136 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
   137   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \
   138 } while((_result == OS_ERR) && (errno == EINTR))
   140 #endif
   142 // Used for calls from _thread_in_vm, not from _thread_in_native
   143 #define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \
   144   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \
   145 } while((_result == OS_ERR) && (errno == EINTR))
   147 /* Use NORESTART when the system call cannot return EINTR, when something other
   148    than a system call is being invoked, or when the caller must do EINTR
   149    handling. */
   151 #ifndef ASSERT
   153 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
   154   _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO)
   156 #else
   158 // This adds an assertion that it is only called from thread_in_native
   159 // The call overhead is skipped for performance in product mode
   160 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
   161   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO )
   163 #endif
   165 // Don't attend to UseVMInterruptibleIO. Always allow interruption.
   166 // Also assumes that it is called from the _thread_blocked state.
   167 // Used by os_sleep().
   169 #define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \
   170   _INTERRUPTIBLE(os::Solaris::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true )
   172 #define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \
   173   int _result; \
   174   do { \
   175     INTERRUPTIBLE(_cmd, _result, _clear); \
   176   } while((_result == OS_ERR) && (errno == EINTR)); \
   177   return _result; \
   178 } while(false)
   180 #define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \
   181   int _result; \
   182   do { \
   183     INTERRUPTIBLE_VM(_cmd, _result, _clear); \
   184   } while((_result == OS_ERR) && (errno == EINTR)); \
   185   return _result; \
   186 } while(false)
   188 #define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \
   189   int _result; \
   190   INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \
   191   return _result; \
   192 } while(false)
   194 /* Use the RESTARTABLE macros when interruptible io is not needed */
   196 #define RESTARTABLE(_cmd, _result) do { \
   197   do { \
   198     _result = _cmd; \
   199   } while((_result == OS_ERR) && (errno == EINTR)); \
   200 } while(false)
   202 #define RESTARTABLE_RETURN_INT(_cmd) do { \
   203   int _result; \
   204   RESTARTABLE(_cmd, _result); \
   205   return _result; \
   206 } while(false)
   208 inline bool os::numa_has_static_binding()   { return false; }
   209 inline bool os::numa_has_group_homing()     { return true;  }

mercurial