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

Mon, 17 Jun 2019 16:41:38 +0100

author
andrew
date
Mon, 17 Jun 2019 16:41:38 +0100
changeset 9711
0f2fe7d37d8c
parent 6911
ce8f6bb717c9
child 9756
2be326848943
permissions
-rw-r--r--

8202353: os::readdir should use readdir instead of readdir_r
Summary: Summary: os::readdir uses POSIX readdir, drop buffer arg, fix JFR uses.
Reviewed-by: coleenp, tschatzl, bsrbnd, shade, phh

     1 /*
     2  * Copyright (c) 1997, 2013, 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.inline.hpp"
    29 #include "runtime/orderAccess.inline.hpp"
    30 #include "runtime/os.hpp"
    32 // System includes
    33 #include <sys/param.h>
    34 #include <dlfcn.h>
    35 #include <sys/socket.h>
    36 #include <sys/poll.h>
    37 #include <sys/filio.h>
    38 #include <unistd.h>
    39 #include <netdb.h>
    40 #include <setjmp.h>
    42 inline const char* os::file_separator() { return "/"; }
    43 inline const char* os::line_separator() { return "\n"; }
    44 inline const char* os::path_separator() { return ":"; }
    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::pd_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 }
    72 inline void os::dll_unload(void *lib) { ::dlclose(lib); }
    74 //////////////////////////////////////////////////////////////////////////////
    75 ////////////////////////////////////////////////////////////////////////////////
    77 // macros for interruptible io and system calls and system call restarting
    79 #define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \
    80 do { \
    81   _setup; \
    82   _before; \
    83   OSThread* _osthread = _thread->osthread(); \
    84   if (_int_enable && _thread->has_last_Java_frame()) { \
    85     /* this is java interruptible io stuff */ \
    86     if (os::is_interrupted(_thread, _clear))  { \
    87       os::Solaris::bump_interrupted_before_count(); \
    88       _result = OS_INTRPT; \
    89     } else { \
    90       /* _cmd always expands to an assignment to _result */ \
    91       if ((_cmd) < 0 && errno == EINTR  \
    92        && os::is_interrupted(_thread, _clear)) { \
    93         os::Solaris::bump_interrupted_during_count(); \
    94         _result = OS_INTRPT; \
    95       } \
    96     } \
    97   } else { \
    98     /* this is normal blocking io stuff */ \
    99     _cmd; \
   100   } \
   101   _after; \
   102 } while(false)
   104 // Interruptible io support + restarting of interrupted system calls
   106 #ifndef ASSERT
   108 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
   109   _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \
   110 } while((_result == OS_ERR) && (errno == EINTR))
   112 #else
   114 // This adds an assertion that it is only called from thread_in_native
   115 // The call overhead is skipped for performance in product mode
   116 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
   117   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \
   118 } while((_result == OS_ERR) && (errno == EINTR))
   120 #endif
   122 // Used for calls from _thread_in_vm, not from _thread_in_native
   123 #define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \
   124   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \
   125 } while((_result == OS_ERR) && (errno == EINTR))
   127 /* Use NORESTART when the system call cannot return EINTR, when something other
   128    than a system call is being invoked, or when the caller must do EINTR
   129    handling. */
   131 #ifndef ASSERT
   133 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
   134   _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO)
   136 #else
   138 // This adds an assertion that it is only called from thread_in_native
   139 // The call overhead is skipped for performance in product mode
   140 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
   141   _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO )
   143 #endif
   145 // Don't attend to UseVMInterruptibleIO. Always allow interruption.
   146 // Also assumes that it is called from the _thread_blocked state.
   147 // Used by os_sleep().
   149 #define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \
   150   _INTERRUPTIBLE(os::Solaris::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true )
   152 #define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \
   153   int _result; \
   154   do { \
   155     INTERRUPTIBLE(_cmd, _result, _clear); \
   156   } while((_result == OS_ERR) && (errno == EINTR)); \
   157   return _result; \
   158 } while(false)
   160 #define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \
   161   int _result; \
   162   do { \
   163     INTERRUPTIBLE_VM(_cmd, _result, _clear); \
   164   } while((_result == OS_ERR) && (errno == EINTR)); \
   165   return _result; \
   166 } while(false)
   168 #define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \
   169   int _result; \
   170   INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \
   171   return _result; \
   172 } while(false)
   174 /* Use the RESTARTABLE macros when interruptible io is not needed */
   176 #define RESTARTABLE(_cmd, _result) do { \
   177   do { \
   178     _result = _cmd; \
   179   } while((_result == OS_ERR) && (errno == EINTR)); \
   180 } while(false)
   182 #define RESTARTABLE_RETURN_INT(_cmd) do { \
   183   int _result; \
   184   RESTARTABLE(_cmd, _result); \
   185   return _result; \
   186 } while(false)
   188 inline bool os::numa_has_static_binding()   { return false; }
   189 inline bool os::numa_has_group_homing()     { return true;  }
   191 inline int    os::socket(int domain, int type, int protocol) {
   192   return ::socket(domain, type, protocol);
   193 }
   195 inline int    os::listen(int fd, int count) {
   196   if (fd < 0) return OS_ERR;
   198   return ::listen(fd, count);
   199 }
   201 inline int os::socket_shutdown(int fd, int howto){
   202   return ::shutdown(fd, howto);
   203 }
   205 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len){
   206   return ::getsockname(fd, him, len);
   207 }
   209 inline int os::get_host_name(char* name, int namelen){
   210   return ::gethostname(name, namelen);
   211 }
   213 inline struct hostent* os::get_host_by_name(char* name) {
   214   return ::gethostbyname(name);
   215 }
   217 inline int os::get_sock_opt(int fd, int level, int optname,
   218                             char* optval, socklen_t* optlen) {
   219   return ::getsockopt(fd, level, optname, optval, optlen);
   220 }
   222 inline int os::set_sock_opt(int fd, int level, int optname,
   223                             const char *optval, socklen_t optlen) {
   224   return ::setsockopt(fd, level, optname, optval, optlen);
   225 }
   226 #endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP

mercurial