author | lana |
Wed, 12 Oct 2011 12:25:03 -0700 | |
changeset 10692 | 6ff3a5ad9412 |
parent 7405 | e6fc8d3926f8 |
child 11256 | 025cd1741566 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
670
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP |
26 |
#define OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP |
|
27 |
||
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 |
|
38 |
||
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
39 |
// System includes |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
40 |
#include <sys/param.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
41 |
#include <dlfcn.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
42 |
#include <sys/socket.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
43 |
#include <sys/poll.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
44 |
#include <sys/filio.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
45 |
#include <unistd.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
46 |
#include <netdb.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
47 |
#include <setjmp.h> |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
48 |
|
1 | 49 |
inline const char* os::file_separator() { return "/"; } |
50 |
inline const char* os::line_separator() { return "\n"; } |
|
51 |
inline const char* os::path_separator() { return ":"; } |
|
52 |
||
53 |
inline const char* os::jlong_format_specifier() { return "%lld"; } |
|
54 |
inline const char* os::julong_format_specifier() { return "%llu"; } |
|
55 |
||
56 |
// File names are case-sensitive on windows only |
|
57 |
inline int os::file_name_strcmp(const char* s1, const char* s2) { |
|
58 |
return strcmp(s1, s2); |
|
59 |
} |
|
60 |
||
61 |
inline bool os::uses_stack_guard_pages() { |
|
62 |
return true; |
|
63 |
} |
|
64 |
||
65 |
inline bool os::allocate_stack_guard_pages() { |
|
66 |
assert(uses_stack_guard_pages(), "sanity check"); |
|
67 |
int r = thr_main() ; |
|
68 |
guarantee (r == 0 || r == 1, "CR6501650 or CR6493689") ; |
|
69 |
return r; |
|
70 |
} |
|
71 |
||
72 |
||
73 |
// On Solaris, reservations are made on a page by page basis, nothing to do. |
|
74 |
inline void os::split_reserved_memory(char *base, size_t size, |
|
75 |
size_t split, bool realloc) { |
|
76 |
} |
|
77 |
||
78 |
||
79 |
// Bang the shadow pages if they need to be touched to be mapped. |
|
80 |
inline void os::bang_stack_shadow_pages() { |
|
81 |
} |
|
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
82 |
inline void os::dll_unload(void *lib) { ::dlclose(lib); } |
1 | 83 |
|
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
84 |
inline DIR* os::opendir(const char* dirname) { |
1 | 85 |
assert(dirname != NULL, "just checking"); |
86 |
return ::opendir(dirname); |
|
87 |
} |
|
88 |
||
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
89 |
inline int os::readdir_buf_size(const char *path) { |
1 | 90 |
int size = pathconf(path, _PC_NAME_MAX); |
91 |
return (size < 0 ? MAXPATHLEN : size) + sizeof(dirent) + 1; |
|
92 |
} |
|
93 |
||
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
94 |
inline struct dirent* os::readdir(DIR* dirp, dirent* dbuf) { |
1 | 95 |
assert(dirp != NULL, "just checking"); |
96 |
#if defined(_LP64) || defined(_GNU_SOURCE) |
|
97 |
dirent* p; |
|
98 |
int status; |
|
99 |
||
100 |
if((status = ::readdir_r(dirp, dbuf, &p)) != 0) { |
|
101 |
errno = status; |
|
102 |
return NULL; |
|
103 |
} else |
|
104 |
return p; |
|
105 |
#else // defined(_LP64) || defined(_GNU_SOURCE) |
|
106 |
return ::readdir_r(dirp, dbuf); |
|
107 |
#endif // defined(_LP64) || defined(_GNU_SOURCE) |
|
108 |
} |
|
109 |
||
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
110 |
inline int os::closedir(DIR *dirp) { |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
111 |
assert(dirp != NULL, "argument is NULL"); |
1 | 112 |
return ::closedir(dirp); |
113 |
} |
|
114 |
||
115 |
////////////////////////////////////////////////////////////////////////////// |
|
116 |
//////////////////////////////////////////////////////////////////////////////// |
|
117 |
||
118 |
// macros for interruptible io and system calls and system call restarting |
|
119 |
||
120 |
#define _INTERRUPTIBLE(_setup, _cmd, _result, _thread, _clear, _before, _after, _int_enable) \ |
|
121 |
do { \ |
|
122 |
_setup; \ |
|
123 |
_before; \ |
|
124 |
OSThread* _osthread = _thread->osthread(); \ |
|
125 |
if (_int_enable && _thread->has_last_Java_frame()) { \ |
|
126 |
/* this is java interruptible io stuff */ \ |
|
127 |
if (os::is_interrupted(_thread, _clear)) { \ |
|
128 |
os::Solaris::bump_interrupted_before_count(); \ |
|
129 |
_result = OS_INTRPT; \ |
|
130 |
} else { \ |
|
131 |
/* _cmd always expands to an assignment to _result */ \ |
|
132 |
if ((_cmd) < 0 && errno == EINTR \ |
|
133 |
&& os::is_interrupted(_thread, _clear)) { \ |
|
134 |
os::Solaris::bump_interrupted_during_count(); \ |
|
135 |
_result = OS_INTRPT; \ |
|
136 |
} \ |
|
137 |
} \ |
|
138 |
} else { \ |
|
139 |
/* this is normal blocking io stuff */ \ |
|
140 |
_cmd; \ |
|
141 |
} \ |
|
142 |
_after; \ |
|
143 |
} while(false) |
|
144 |
||
145 |
// Interruptible io support + restarting of interrupted system calls |
|
146 |
||
147 |
#ifndef ASSERT |
|
148 |
||
149 |
#define INTERRUPTIBLE(_cmd, _result, _clear) do { \ |
|
150 |
_INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO); \ |
|
151 |
} while((_result == OS_ERR) && (errno == EINTR)) |
|
152 |
||
153 |
#else |
|
154 |
||
155 |
// This adds an assertion that it is only called from thread_in_native |
|
156 |
// The call overhead is skipped for performance in product mode |
|
157 |
#define INTERRUPTIBLE(_cmd, _result, _clear) do { \ |
|
158 |
_INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ); \ |
|
159 |
} while((_result == OS_ERR) && (errno == EINTR)) |
|
160 |
||
161 |
#endif |
|
162 |
||
163 |
// Used for calls from _thread_in_vm, not from _thread_in_native |
|
164 |
#define INTERRUPTIBLE_VM(_cmd, _result, _clear) do { \ |
|
165 |
_INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible(_thread), UseVMInterruptibleIO ); \ |
|
166 |
} while((_result == OS_ERR) && (errno == EINTR)) |
|
167 |
||
168 |
/* Use NORESTART when the system call cannot return EINTR, when something other |
|
169 |
than a system call is being invoked, or when the caller must do EINTR |
|
170 |
handling. */ |
|
171 |
||
172 |
#ifndef ASSERT |
|
173 |
||
174 |
#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \ |
|
175 |
_INTERRUPTIBLE( JavaThread* _thread = (JavaThread*)ThreadLocalStorage::thread(),_result = _cmd, _result, _thread, _clear, , , UseVMInterruptibleIO) |
|
176 |
||
177 |
#else |
|
178 |
||
179 |
// This adds an assertion that it is only called from thread_in_native |
|
180 |
// The call overhead is skipped for performance in product mode |
|
181 |
#define INTERRUPTIBLE_NORESTART(_cmd, _result, _clear) \ |
|
182 |
_INTERRUPTIBLE(JavaThread* _thread = os::Solaris::setup_interruptible_native(), _result = _cmd, _result, _thread, _clear, , os::Solaris::cleanup_interruptible_native(_thread), UseVMInterruptibleIO ) |
|
183 |
||
184 |
#endif |
|
185 |
||
186 |
// Don't attend to UseVMInterruptibleIO. Always allow interruption. |
|
187 |
// Also assumes that it is called from the _thread_blocked state. |
|
188 |
// Used by os_sleep(). |
|
189 |
||
190 |
#define INTERRUPTIBLE_NORESTART_VM_ALWAYS(_cmd, _result, _thread, _clear) \ |
|
191 |
_INTERRUPTIBLE(os::Solaris::setup_interruptible_already_blocked(_thread), _result = _cmd, _result, _thread, _clear, , , true ) |
|
192 |
||
193 |
#define INTERRUPTIBLE_RETURN_INT(_cmd, _clear) do { \ |
|
194 |
int _result; \ |
|
195 |
do { \ |
|
196 |
INTERRUPTIBLE(_cmd, _result, _clear); \ |
|
197 |
} while((_result == OS_ERR) && (errno == EINTR)); \ |
|
198 |
return _result; \ |
|
199 |
} while(false) |
|
200 |
||
201 |
#define INTERRUPTIBLE_RETURN_INT_VM(_cmd, _clear) do { \ |
|
202 |
int _result; \ |
|
203 |
do { \ |
|
204 |
INTERRUPTIBLE_VM(_cmd, _result, _clear); \ |
|
205 |
} while((_result == OS_ERR) && (errno == EINTR)); \ |
|
206 |
return _result; \ |
|
207 |
} while(false) |
|
208 |
||
209 |
#define INTERRUPTIBLE_RETURN_INT_NORESTART(_cmd, _clear) do { \ |
|
210 |
int _result; \ |
|
211 |
INTERRUPTIBLE_NORESTART(_cmd, _result, _clear); \ |
|
212 |
return _result; \ |
|
213 |
} while(false) |
|
214 |
||
215 |
/* Use the RESTARTABLE macros when interruptible io is not needed */ |
|
216 |
||
217 |
#define RESTARTABLE(_cmd, _result) do { \ |
|
218 |
do { \ |
|
219 |
_result = _cmd; \ |
|
220 |
} while((_result == OS_ERR) && (errno == EINTR)); \ |
|
221 |
} while(false) |
|
222 |
||
223 |
#define RESTARTABLE_RETURN_INT(_cmd) do { \ |
|
224 |
int _result; \ |
|
225 |
RESTARTABLE(_cmd, _result); \ |
|
226 |
return _result; \ |
|
227 |
} while(false) |
|
388 | 228 |
|
229 |
inline bool os::numa_has_static_binding() { return false; } |
|
230 |
inline bool os::numa_has_group_homing() { return true; } |
|
7397 | 231 |
|
7405
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
232 |
inline int os::socket(int domain, int type, int protocol) { |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
233 |
return ::socket(domain, type, protocol); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
234 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
235 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
236 |
inline int os::listen(int fd, int count) { |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
237 |
if (fd < 0) return OS_ERR; |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
238 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
239 |
return ::listen(fd, count); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
240 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
241 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
242 |
inline int os::socket_shutdown(int fd, int howto){ |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
243 |
return ::shutdown(fd, howto); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
244 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
245 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
246 |
inline int os::get_sock_name(int fd, struct sockaddr *him, int *len){ |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
247 |
return ::getsockname(fd, him, (socklen_t*) len); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
248 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
249 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
250 |
inline int os::get_host_name(char* name, int namelen){ |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
251 |
return ::gethostname(name, namelen); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
252 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
253 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
254 |
inline struct hostent* os::get_host_by_name(char* name) { |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
255 |
return ::gethostbyname(name); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
256 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
257 |
inline int os::get_sock_opt(int fd, int level, int optname, |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
258 |
char *optval, int* optlen){ |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
259 |
return ::getsockopt(fd, level, optname, optval, (socklen_t*) optlen); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
260 |
} |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
261 |
|
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
262 |
inline int os::set_sock_opt(int fd, int level, int optname, |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
263 |
const char *optval, int optlen){ |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
264 |
return ::setsockopt(fd, level, optname, optval, optlen); |
e6fc8d3926f8
6348631: remove the use of the HPI library from Hotspot
ikrylov
parents:
7397
diff
changeset
|
265 |
} |
7397 | 266 |
#endif // OS_SOLARIS_VM_OS_SOLARIS_INLINE_HPP |