annotate src/os/solaris/vm/os_solaris.inline.hpp @ 470:ad8c8ca4ab0f jdk7-b42

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