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

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 2322
828eafbd85cc
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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 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  */
    25 #ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
    26 #define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
    28 #include "runtime/atomic.hpp"
    29 #include "runtime/os.hpp"
    30 #ifdef TARGET_OS_ARCH_solaris_x86
    31 # include "atomic_solaris_x86.inline.hpp"
    32 # include "orderAccess_solaris_x86.inline.hpp"
    33 #endif
    34 #ifdef TARGET_OS_ARCH_solaris_sparc
    35 # include "atomic_solaris_sparc.inline.hpp"
    36 # include "orderAccess_solaris_sparc.inline.hpp"
    37 #endif
    39 inline const char* os::file_separator() { return "/"; }
    40 inline const char* os::line_separator() { return "\n"; }
    41 inline const char* os::path_separator() { return ":"; }
    43 inline const char* os::jlong_format_specifier()   { return "%lld"; }
    44 inline const char* os::julong_format_specifier()  { return "%llu"; }
    46 // File names are case-sensitive on windows only
    47 inline int os::file_name_strcmp(const char* s1, const char* s2) {
    48   return strcmp(s1, s2);
    49 }
    51 inline bool os::uses_stack_guard_pages() {
    52   return true;
    53 }
    55 inline bool os::allocate_stack_guard_pages() {
    56   assert(uses_stack_guard_pages(), "sanity check");
    57   int r = thr_main() ;
    58   guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
    59   return r;
    60 }
    63 // On Solaris, reservations are made on a page by page basis, nothing to do.
    64 inline void os::split_reserved_memory(char *base, size_t size,
    65                                       size_t split, bool realloc) {
    66 }
    69 // Bang the shadow pages if they need to be touched to be mapped.
    70 inline void os::bang_stack_shadow_pages() {
    71 }
    73 inline DIR* os::opendir(const char* dirname)
    74 {
    75   assert(dirname != NULL, "just checking");
    76   return ::opendir(dirname);
    77 }
    79 inline int os::readdir_buf_size(const char *path)
    80 {
    81   int size = pathconf(path, _PC_NAME_MAX);
    82   return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1;
    83 }
    85 inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf)
    86 {
    87   assert(dirp != NULL, "just checking");
    88 #if defined(_LP64) || defined(_GNU_SOURCE)
    89   dirent* p;
    90   int status;
    92   if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
    93     errno = status;
    94     return NULL;
    95   } else
    96     return p;
    97 #else  // defined(_LP64) || defined(_GNU_SOURCE)
    98   return ::readdir_r(dirp, dbuf);
    99 #endif // defined(_LP64) || defined(_GNU_SOURCE)
   100 }
   102 inline int os::closedir(DIR *dirp)
   103 {
   104   assert(dirp != NULL, "just checking");
   105   return ::closedir(dirp);
   106 }
   108 //////////////////////////////////////////////////////////////////////////////
   109 ////////////////////////////////////////////////////////////////////////////////
   111 // macros for interruptible io and system calls and system call restarting
   113 #define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \
   114 do { \
   115   _setup; \
   116   _before; \
   117   OSThread* _osthread = _thread->osthread(); \
   118   if (_int_enable && _thread->has_last_Java_frame()) { \
   119     /* this is java interruptible io stuff */ \
   120     if (os::is_interrupted(_thread, _clear))  { \
   121       os::Solaris::bump_interrupted_before_count(); \
   122       _result = OS_INTRPT; \
   123     } else { \
   124       /* _cmd always expands to an assignment to _result */ \
   125       if ((_cmd) < 0 && errno == EINTR  \
   126        && os::is_interrupted(_thread, _clear)) { \
   127         os::Solaris::bump_interrupted_during_count(); \
   128         _result = OS_INTRPT; \
   129       } \
   130     } \
   131   } else { \
   132     /* this is normal blocking io stuff */ \
   133     _cmd; \
   134   } \
   135   _after; \
   136 } while(false)
   138 // Interruptible io support + restarting of interrupted system calls
   140 #ifndef ASSERT
   142 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
   143   _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \
   144 } while((_result == OS_ERR) && (errno == EINTR))
   146 #else
   148 // This adds an assertion that it is only called from thread_in_native
   149 // The call overhead is skipped for performance in product mode
   150 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
   151   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \
   152 } while((_result == OS_ERR) && (errno == EINTR))
   154 #endif
   156 // Used for calls from _thread_in_vm, not from _thread_in_native
   157 #define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \
   158   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \
   159 } while((_result == OS_ERR) && (errno == EINTR))
   161 /* Use NORESTART when the system call cannot return EINTR, when something other
   162    than a system call is being invoked, or when the caller must do EINTR
   163    handling. */
   165 #ifndef ASSERT
   167 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
   168   _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO)
   170 #else
   172 // This adds an assertion that it is only called from thread_in_native
   173 // The call overhead is skipped for performance in product mode
   174 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
   175   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO )
   177 #endif
   179 // Don't attend to UseVMInterruptibleIO. Always allow interruption.
   180 // Also assumes that it is called from the _thread_blocked state.
   181 // Used by os_sleep().
   183 #define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \
   184   _INTERRUPTIBLE(os::Solaris::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true )
   186 #define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \
   187   int _result; \
   188   do { \
   189     INTERRUPTIBLE(_cmd, _result, _clear); \
   190   } while((_result == OS_ERR) && (errno == EINTR)); \
   191   return _result; \
   192 } while(false)
   194 #define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \
   195   int _result; \
   196   do { \
   197     INTERRUPTIBLE_VM(_cmd, _result, _clear); \
   198   } while((_result == OS_ERR) && (errno == EINTR)); \
   199   return _result; \
   200 } while(false)
   202 #define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \
   203   int _result; \
   204   INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \
   205   return _result; \
   206 } while(false)
   208 /* Use the RESTARTABLE macros when interruptible io is not needed */
   210 #define RESTARTABLE(_cmd, _result) do { \
   211   do { \
   212     _result = _cmd; \
   213   } while((_result == OS_ERR) && (errno == EINTR)); \
   214 } while(false)
   216 #define RESTARTABLE_RETURN_INT(_cmd) do { \
   217   int _result; \
   218   RESTARTABLE(_cmd, _result); \
   219   return _result; \
   220 } while(false)
   222 inline bool os::numa_has_static_binding()   { return false; }
   223 inline bool os::numa_has_group_homing()     { return true;  }
   225 #endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP

mercurial