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