os_solaris.inline.hpp revision 1472:c18cbe5936b8
1/* 2 * Copyright (c) 1997, 2008, 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 */ 24 25inline const char* os::file_separator() { return "/"; } 26inline const char* os::line_separator() { return "\n"; } 27inline const char* os::path_separator() { return ":"; } 28 29inline const char* os::jlong_format_specifier() { return "%lld"; } 30inline const char* os::julong_format_specifier() { return "%llu"; } 31 32// File names are case-sensitive on windows only 33inline int os::file_name_strcmp(const char* s1, const char* s2) { 34 return strcmp(s1, s2); 35} 36 37inline bool os::uses_stack_guard_pages() { 38 return true; 39} 40 41inline 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} 47 48 49// On Solaris, reservations are made on a page by page basis, nothing to do. 50inline void os::split_reserved_memory(char *base, size_t size, 51 size_t split, bool realloc) { 52} 53 54 55// Bang the shadow pages if they need to be touched to be mapped. 56inline void os::bang_stack_shadow_pages() { 57} 58 59inline DIR* os::opendir(const char* dirname) 60{ 61 assert(dirname != NULL, "just checking"); 62 return ::opendir(dirname); 63} 64 65inline 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} 70 71inline 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; 77 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} 87 88inline int os::closedir(DIR *dirp) 89{ 90 assert(dirp != NULL, "just checking"); 91 return ::closedir(dirp); 92} 93 94////////////////////////////////////////////////////////////////////////////// 95//////////////////////////////////////////////////////////////////////////////// 96 97// macros for interruptible io and system calls and system call restarting 98 99#define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \ 100do { \ 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) 123 124// Interruptible io support + restarting of interrupted system calls 125 126#ifndef ASSERT 127 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)) 131 132#else 133 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)) 139 140#endif 141 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)) 146 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. */ 150 151#ifndef ASSERT 152 153#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \ 154 _INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO) 155 156#else 157 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 ) 162 163#endif 164 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(). 168 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 ) 171 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) 179 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) 187 188#define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \ 189 int _result; \ 190 INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \ 191 return _result; \ 192} while(false) 193 194/* Use the RESTARTABLE macros when interruptible io is not needed */ 195 196#define RESTARTABLE(_cmd, _result) do { \ 197 do { \ 198 _result = _cmd; \ 199 } while((_result == OS_ERR) && (errno == EINTR)); \ 200} while(false) 201 202#define RESTARTABLE_RETURN_INT(_cmd) do { \ 203 int _result; \ 204 RESTARTABLE(_cmd, _result); \ 205 return _result; \ 206} while(false) 207 208inline bool os::numa_has_static_binding() { return false; } 209inline bool os::numa_has_group_homing() { return true; } 210