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

Fri, 07 Dec 2012 01:09:03 -0800

author
roland
date
Fri, 07 Dec 2012 01:09:03 -0800
changeset 4325
d2f8c38e543d
parent 4318
cd3d6a6b95d9
child 4465
203f64878aab
permissions
-rw-r--r--

Merge

duke@435 1 /*
mikael@4153 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
stefank@2314 26 #define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP
stefank@2314 27
stefank@2314 28 #include "runtime/atomic.hpp"
twisti@4318 29 #include "runtime/atomic.inline.hpp"
stefank@2314 30 #include "runtime/os.hpp"
twisti@4318 31
stefank@2314 32 #ifdef TARGET_OS_ARCH_solaris_x86
stefank@2314 33 # include "orderAccess_solaris_x86.inline.hpp"
stefank@2314 34 #endif
stefank@2314 35 #ifdef TARGET_OS_ARCH_solaris_sparc
stefank@2314 36 # include "orderAccess_solaris_sparc.inline.hpp"
stefank@2314 37 #endif
stefank@2314 38
ikrylov@2322 39 // System includes
ikrylov@2322 40 #include <sys/param.h>
ikrylov@2322 41 #include <dlfcn.h>
ikrylov@2322 42 #include <sys/socket.h>
ikrylov@2322 43 #include <sys/poll.h>
ikrylov@2322 44 #include <sys/filio.h>
ikrylov@2322 45 #include <unistd.h>
ikrylov@2322 46 #include <netdb.h>
ikrylov@2322 47 #include <setjmp.h>
ikrylov@2322 48
duke@435 49 inline const char* os::file_separator() { return "/"; }
duke@435 50 inline const char* os::line_separator() { return "\n"; }
duke@435 51 inline const char* os::path_separator() { return ":"; }
duke@435 52
duke@435 53 inline const char* os::jlong_format_specifier() { return "%lld"; }
duke@435 54 inline const char* os::julong_format_specifier() { return "%llu"; }
duke@435 55
duke@435 56 // File names are case-sensitive on windows only
duke@435 57 inline int os::file_name_strcmp(const char* s1, const char* s2) {
duke@435 58 return strcmp(s1, s2);
duke@435 59 }
duke@435 60
duke@435 61 inline bool os::uses_stack_guard_pages() {
duke@435 62 return true;
duke@435 63 }
duke@435 64
duke@435 65 inline bool os::allocate_stack_guard_pages() {
duke@435 66 assert(uses_stack_guard_pages(), "sanity check");
duke@435 67 int r = thr_main() ;
duke@435 68 guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ;
duke@435 69 return r;
duke@435 70 }
duke@435 71
duke@435 72
duke@435 73 // On Solaris, reservations are made on a page by page basis, nothing to do.
zgu@3900 74 inline void os::pd_split_reserved_memory(char *base, size_t size,
duke@435 75 size_t split, bool realloc) {
duke@435 76 }
duke@435 77
duke@435 78
duke@435 79 // Bang the shadow pages if they need to be touched to be mapped.
duke@435 80 inline void os::bang_stack_shadow_pages() {
duke@435 81 }
ikrylov@2322 82 inline void os::dll_unload(void *lib) { ::dlclose(lib); }
duke@435 83
ikrylov@2322 84 inline DIR* os::opendir(const char* dirname) {
duke@435 85 assert(dirname != NULL, "just checking");
duke@435 86 return ::opendir(dirname);
duke@435 87 }
duke@435 88
ikrylov@2322 89 inline int os::readdir_buf_size(const char *path) {
duke@435 90 int size = pathconf(path, _PC_NAME_MAX);
duke@435 91 return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1;
duke@435 92 }
duke@435 93
ikrylov@2322 94 inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf) {
duke@435 95 assert(dirp != NULL, "just checking");
duke@435 96 #if defined(_LP64) || defined(_GNU_SOURCE)
duke@435 97 dirent* p;
duke@435 98 int status;
duke@435 99
duke@435 100 if((status = ::readdir_r(dirp, dbuf, &p)) != 0) {
duke@435 101 errno = status;
duke@435 102 return NULL;
duke@435 103 } else
duke@435 104 return p;
duke@435 105 #else // defined(_LP64) || defined(_GNU_SOURCE)
duke@435 106 return ::readdir_r(dirp, dbuf);
duke@435 107 #endif // defined(_LP64) || defined(_GNU_SOURCE)
duke@435 108 }
duke@435 109
ikrylov@2322 110 inline int os::closedir(DIR *dirp) {
ikrylov@2322 111 assert(dirp != NULL, "argument is NULL");
duke@435 112 return ::closedir(dirp);
duke@435 113 }
duke@435 114
duke@435 115 //////////////////////////////////////////////////////////////////////////////
duke@435 116 ////////////////////////////////////////////////////////////////////////////////
duke@435 117
duke@435 118 // macros for interruptible io and system calls and system call restarting
duke@435 119
duke@435 120 #define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \
duke@435 121 do { \
duke@435 122 _setup; \
duke@435 123 _before; \
duke@435 124 OSThread* _osthread = _thread->osthread(); \
duke@435 125 if (_int_enable && _thread->has_last_Java_frame()) { \
duke@435 126 /* this is java interruptible io stuff */ \
duke@435 127 if (os::is_interrupted(_thread, _clear)) { \
duke@435 128 os::Solaris::bump_interrupted_before_count(); \
duke@435 129 _result = OS_INTRPT; \
duke@435 130 } else { \
duke@435 131 /* _cmd always expands to an assignment to _result */ \
duke@435 132 if ((_cmd) < 0 && errno == EINTR \
duke@435 133 && os::is_interrupted(_thread, _clear)) { \
duke@435 134 os::Solaris::bump_interrupted_during_count(); \
duke@435 135 _result = OS_INTRPT; \
duke@435 136 } \
duke@435 137 } \
duke@435 138 } else { \
duke@435 139 /* this is normal blocking io stuff */ \
duke@435 140 _cmd; \
duke@435 141 } \
duke@435 142 _after; \
duke@435 143 } while(false)
duke@435 144
duke@435 145 // Interruptible io support + restarting of interrupted system calls
duke@435 146
duke@435 147 #ifndef ASSERT
duke@435 148
duke@435 149 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
duke@435 150 _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \
duke@435 151 } while((_result == OS_ERR) && (errno == EINTR))
duke@435 152
duke@435 153 #else
duke@435 154
duke@435 155 // This adds an assertion that it is only called from thread_in_native
duke@435 156 // The call overhead is skipped for performance in product mode
duke@435 157 #define INTERRUPTIBLE(_cmd, _result, _clear) do { \
duke@435 158 _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \
duke@435 159 } while((_result == OS_ERR) && (errno == EINTR))
duke@435 160
duke@435 161 #endif
duke@435 162
duke@435 163 // Used for calls from _thread_in_vm, not from _thread_in_native
duke@435 164 #define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \
duke@435 165 _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \
duke@435 166 } while((_result == OS_ERR) && (errno == EINTR))
duke@435 167
duke@435 168 /* Use NORESTART when the system call cannot return EINTR, when something other
duke@435 169 than a system call is being invoked, or when the caller must do EINTR
duke@435 170 handling. */
duke@435 171
duke@435 172 #ifndef ASSERT
duke@435 173
duke@435 174 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
duke@435 175 _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO)
duke@435 176
duke@435 177 #else
duke@435 178
duke@435 179 // This adds an assertion that it is only called from thread_in_native
duke@435 180 // The call overhead is skipped for performance in product mode
duke@435 181 #define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \
duke@435 182 _INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO )
duke@435 183
duke@435 184 #endif
duke@435 185
duke@435 186 // Don't attend to UseVMInterruptibleIO. Always allow interruption.
duke@435 187 // Also assumes that it is called from the _thread_blocked state.
duke@435 188 // Used by os_sleep().
duke@435 189
duke@435 190 #define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \
duke@435 191 _INTERRUPTIBLE(os::Solaris::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true )
duke@435 192
duke@435 193 #define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \
duke@435 194 int _result; \
duke@435 195 do { \
duke@435 196 INTERRUPTIBLE(_cmd, _result, _clear); \
duke@435 197 } while((_result == OS_ERR) && (errno == EINTR)); \
duke@435 198 return _result; \
duke@435 199 } while(false)
duke@435 200
duke@435 201 #define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \
duke@435 202 int _result; \
duke@435 203 do { \
duke@435 204 INTERRUPTIBLE_VM(_cmd, _result, _clear); \
duke@435 205 } while((_result == OS_ERR) && (errno == EINTR)); \
duke@435 206 return _result; \
duke@435 207 } while(false)
duke@435 208
duke@435 209 #define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \
duke@435 210 int _result; \
duke@435 211 INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \
duke@435 212 return _result; \
duke@435 213 } while(false)
duke@435 214
duke@435 215 /* Use the RESTARTABLE macros when interruptible io is not needed */
duke@435 216
duke@435 217 #define RESTARTABLE(_cmd, _result) do { \
duke@435 218 do { \
duke@435 219 _result = _cmd; \
duke@435 220 } while((_result == OS_ERR) && (errno == EINTR)); \
duke@435 221 } while(false)
duke@435 222
duke@435 223 #define RESTARTABLE_RETURN_INT(_cmd) do { \
duke@435 224 int _result; \
duke@435 225 RESTARTABLE(_cmd, _result); \
duke@435 226 return _result; \
duke@435 227 } while(false)
iveresov@576 228
iveresov@576 229 inline bool os::numa_has_static_binding() { return false; }
iveresov@576 230 inline bool os::numa_has_group_homing() { return true; }
stefank@2314 231
ikrylov@2322 232 inline int os::socket(int domain, int type, int protocol) {
ikrylov@2322 233 return ::socket(domain, type, protocol);
ikrylov@2322 234 }
ikrylov@2322 235
ikrylov@2322 236 inline int os::listen(int fd, int count) {
ikrylov@2322 237 if (fd < 0) return OS_ERR;
ikrylov@2322 238
ikrylov@2322 239 return ::listen(fd, count);
ikrylov@2322 240 }
ikrylov@2322 241
ikrylov@2322 242 inline int os::socket_shutdown(int fd, int howto){
ikrylov@2322 243 return ::shutdown(fd, howto);
ikrylov@2322 244 }
ikrylov@2322 245
phh@3344 246 inline int os::get_sock_name(int fd, struct sockaddr* him, socklen_t* len){
phh@3344 247 return ::getsockname(fd, him, len);
ikrylov@2322 248 }
ikrylov@2322 249
ikrylov@2322 250 inline int os::get_host_name(char* name, int namelen){
ikrylov@2322 251 return ::gethostname(name, namelen);
ikrylov@2322 252 }
ikrylov@2322 253
phh@3344 254 inline struct hostent* os::get_host_by_name(char* name) {
ikrylov@2322 255 return ::gethostbyname(name);
ikrylov@2322 256 }
phh@3344 257
ikrylov@2322 258 inline int os::get_sock_opt(int fd, int level, int optname,
phh@3344 259 char* optval, socklen_t* optlen) {
phh@3344 260 return ::getsockopt(fd, level, optname, optval, optlen);
ikrylov@2322 261 }
ikrylov@2322 262
ikrylov@2322 263 inline int os::set_sock_opt(int fd, int level, int optname,
phh@3344 264 const char *optval, socklen_t optlen) {
ikrylov@2322 265 return ::setsockopt(fd, level, optname, optval, optlen);
ikrylov@2322 266 }
stefank@2314 267 #endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP

mercurial