author | mlarsson |
Mon, 11 Apr 2016 12:22:09 +0200 | |
changeset 37465 | 1d5551f466ee |
parent 37113 | 5a33bf5089ac |
child 38065 | 025c784d9333 |
permissions | -rw-r--r-- |
8119 | 1 |
/* |
36174 | 2 |
* Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved. |
22826 | 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 |
*/ |
|
8119 | 24 |
|
22826 | 25 |
#include "utilities/globalDefinitions.hpp" |
8119 | 26 |
#include "prims/jvm.h" |
31610 | 27 |
#include "semaphore_posix.hpp" |
13195 | 28 |
#include "runtime/frame.inline.hpp" |
22891
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
29 |
#include "runtime/interfaceSupport.hpp" |
8119 | 30 |
#include "runtime/os.hpp" |
31 |
#include "utilities/vmError.hpp" |
|
32 |
||
22826 | 33 |
#include <signal.h> |
8119 | 34 |
#include <unistd.h> |
35 |
#include <sys/resource.h> |
|
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
36 |
#include <sys/utsname.h> |
19691
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
37 |
#include <pthread.h> |
31610 | 38 |
#include <semaphore.h> |
19691
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
39 |
#include <signal.h> |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
40 |
|
22826 | 41 |
// Todo: provide a os::get_max_process_id() or similar. Number of processes |
42 |
// may have been configured, can be read more accurately from proc fs etc. |
|
43 |
#ifndef MAX_PID |
|
44 |
#define MAX_PID INT_MAX |
|
45 |
#endif |
|
46 |
#define IS_VALID_PID(p) (p > 0 && p < MAX_PID) |
|
8119 | 47 |
|
48 |
// Check core dump limit and report possible place where core can be found |
|
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
28172
diff
changeset
|
49 |
void os::check_dump_limit(char* buffer, size_t bufferSize) { |
13198
271c557a7623
7129724: MAC: Core file location is wrong in crash report
mikael
parents:
13195
diff
changeset
|
50 |
int n; |
8119 | 51 |
struct rlimit rlim; |
52 |
bool success; |
|
53 |
||
28172
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
54 |
char core_path[PATH_MAX]; |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
55 |
n = get_core_path(core_path, PATH_MAX); |
8119 | 56 |
|
28172
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
57 |
if (n <= 0) { |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
58 |
jio_snprintf(buffer, bufferSize, "core.%d (may not exist)", current_process_id()); |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
59 |
success = true; |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
60 |
#ifdef LINUX |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
61 |
} else if (core_path[0] == '"') { // redirect to user process |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
62 |
jio_snprintf(buffer, bufferSize, "Core dumps may be processed with %s", core_path); |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
63 |
success = true; |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
64 |
#endif |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
65 |
} else if (getrlimit(RLIMIT_CORE, &rlim) != 0) { |
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
66 |
jio_snprintf(buffer, bufferSize, "%s (may not exist)", core_path); |
8119 | 67 |
success = true; |
68 |
} else { |
|
69 |
switch(rlim.rlim_cur) { |
|
70 |
case RLIM_INFINITY: |
|
28172
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
71 |
jio_snprintf(buffer, bufferSize, "%s", core_path); |
8119 | 72 |
success = true; |
73 |
break; |
|
74 |
case 0: |
|
75 |
jio_snprintf(buffer, bufferSize, "Core dumps have been disabled. To enable core dumping, try \"ulimit -c unlimited\" before starting Java again"); |
|
76 |
success = false; |
|
77 |
break; |
|
78 |
default: |
|
28172
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
79 |
jio_snprintf(buffer, bufferSize, "%s (max size %lu kB). To ensure a full core dump, try \"ulimit -c unlimited\" before starting Java again", core_path, (unsigned long)(rlim.rlim_cur >> 10)); |
8119 | 80 |
success = true; |
81 |
break; |
|
82 |
} |
|
83 |
} |
|
28172
19ae5c844e75
8059586: hs_err report should treat redirected core pattern
dholmes
parents:
28166
diff
changeset
|
84 |
|
30240
a7ba42fa1df6
8074354: Make CreateMinidumpOnCrash a new name and available on all platforms
minqi
parents:
28172
diff
changeset
|
85 |
VMError::record_coredump_status(buffer, success); |
8119 | 86 |
} |
87 |
||
25946 | 88 |
int os::get_native_stack(address* stack, int frames, int toSkip) { |
13195 | 89 |
#ifdef _NMT_NOINLINE_ |
25946 | 90 |
toSkip++; |
13195 | 91 |
#endif |
25946 | 92 |
|
93 |
int frame_idx = 0; |
|
94 |
int num_of_frames; // number of frames captured |
|
13195 | 95 |
frame fr = os::current_frame(); |
25946 | 96 |
while (fr.pc() && frame_idx < frames) { |
97 |
if (toSkip > 0) { |
|
98 |
toSkip --; |
|
99 |
} else { |
|
100 |
stack[frame_idx ++] = fr.pc(); |
|
101 |
} |
|
28166
e42212b64568
8066803: compiler/intrinsics/mathexact/SubExactINonConstantTest.java crashed in os::is_first_C_frame(frame*)
coleenp
parents:
27471
diff
changeset
|
102 |
if (fr.fp() == NULL || fr.cb() != NULL || |
e42212b64568
8066803: compiler/intrinsics/mathexact/SubExactINonConstantTest.java crashed in os::is_first_C_frame(frame*)
coleenp
parents:
27471
diff
changeset
|
103 |
fr.sender_pc() == NULL || os::is_first_C_frame(&fr)) break; |
25946 | 104 |
|
105 |
if (fr.sender_pc() && !os::is_first_C_frame(&fr)) { |
|
106 |
fr = os::get_sender_for_C_frame(&fr); |
|
107 |
} else { |
|
108 |
break; |
|
109 |
} |
|
13195 | 110 |
} |
25946 | 111 |
num_of_frames = frame_idx; |
112 |
for (; frame_idx < frames; frame_idx ++) { |
|
113 |
stack[frame_idx] = NULL; |
|
13195 | 114 |
} |
25946 | 115 |
|
116 |
return num_of_frames; |
|
117 |
} |
|
118 |
||
119 |
||
120 |
bool os::unsetenv(const char* name) { |
|
121 |
assert(name != NULL, "Null pointer"); |
|
122 |
return (::unsetenv(name) == 0); |
|
13195 | 123 |
} |
124 |
||
11418
66ca80da30e2
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
8476
diff
changeset
|
125 |
int os::get_last_error() { |
66ca80da30e2
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
8476
diff
changeset
|
126 |
return errno; |
66ca80da30e2
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
8476
diff
changeset
|
127 |
} |
66ca80da30e2
7126185: Clean up lasterror handling, add os::get_last_error()
phh
parents:
8476
diff
changeset
|
128 |
|
8476
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
129 |
bool os::is_debugger_attached() { |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
130 |
// not implemented |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
131 |
return false; |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
132 |
} |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
133 |
|
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
134 |
void os::wait_for_keypress_at_exit(void) { |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
135 |
// don't do anything on posix platforms |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
136 |
return; |
7e34c2d4cf9b
7022037: Pause when exiting if debugger is attached on windows
sla
parents:
8119
diff
changeset
|
137 |
} |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
138 |
|
14840
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
139 |
// Multiple threads can race in this code, and can remap over each other with MAP_FIXED, |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
140 |
// so on posix, unmap the section at the start and at the end of the chunk that we mapped |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
141 |
// rather than unmapping and remapping the whole chunk to get requested alignment. |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
142 |
char* os::reserve_memory_aligned(size_t size, size_t alignment) { |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
143 |
assert((alignment & (os::vm_allocation_granularity() - 1)) == 0, |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
144 |
"Alignment must be a multiple of allocation granularity (page size)"); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
145 |
assert((size & (alignment -1)) == 0, "size must be 'alignment' aligned"); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
146 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
147 |
size_t extra_size = size + alignment; |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
148 |
assert(extra_size >= size, "overflow, size is too large to allow alignment"); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
149 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
150 |
char* extra_base = os::reserve_memory(extra_size, NULL, alignment); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
151 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
152 |
if (extra_base == NULL) { |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
153 |
return NULL; |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
154 |
} |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
155 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
156 |
// Do manual alignment |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
157 |
char* aligned_base = (char*) align_size_up((uintptr_t) extra_base, alignment); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
158 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
159 |
// [ | | ] |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
160 |
// ^ extra_base |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
161 |
// ^ extra_base + begin_offset == aligned_base |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
162 |
// extra_base + begin_offset + size ^ |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
163 |
// extra_base + extra_size ^ |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
164 |
// |<>| == begin_offset |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
165 |
// end_offset == |<>| |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
166 |
size_t begin_offset = aligned_base - extra_base; |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
167 |
size_t end_offset = (extra_base + extra_size) - (aligned_base + size); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
168 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
169 |
if (begin_offset > 0) { |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
170 |
os::release_memory(extra_base, begin_offset); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
171 |
} |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
172 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
173 |
if (end_offset > 0) { |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
174 |
os::release_memory(extra_base + begin_offset + size, end_offset); |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
175 |
} |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
176 |
|
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
177 |
return aligned_base; |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
178 |
} |
8994c2377547
7173959: Jvm crashed during coherence exabus (tmb) testing
brutisso
parents:
13963
diff
changeset
|
179 |
|
33766
3290cae587f9
8138916: Logging write function does not allow for long enough messages
rprotacio
parents:
33148
diff
changeset
|
180 |
int os::log_vsnprintf(char* buf, size_t len, const char* fmt, va_list args) { |
3290cae587f9
8138916: Logging write function does not allow for long enough messages
rprotacio
parents:
33148
diff
changeset
|
181 |
return vsnprintf(buf, len, fmt, args); |
3290cae587f9
8138916: Logging write function does not allow for long enough messages
rprotacio
parents:
33148
diff
changeset
|
182 |
} |
3290cae587f9
8138916: Logging write function does not allow for long enough messages
rprotacio
parents:
33148
diff
changeset
|
183 |
|
37465
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37113
diff
changeset
|
184 |
int os::fileno(FILE* fp) { |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37113
diff
changeset
|
185 |
return ::fileno(fp); |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37113
diff
changeset
|
186 |
} |
1d5551f466ee
8146879: Add option for handling existing log files in UL
mlarsson
parents:
37113
diff
changeset
|
187 |
|
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
188 |
void os::Posix::print_load_average(outputStream* st) { |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
189 |
st->print("load average:"); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
190 |
double loadavg[3]; |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
191 |
os::loadavg(loadavg, 3); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
192 |
st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
193 |
st->cr(); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
194 |
} |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
195 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
196 |
void os::Posix::print_rlimit_info(outputStream* st) { |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
197 |
st->print("rlimit:"); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
198 |
struct rlimit rlim; |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
199 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
200 |
st->print(" STACK "); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
201 |
getrlimit(RLIMIT_STACK, &rlim); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
202 |
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
203 |
else st->print("%luk", rlim.rlim_cur >> 10); |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
204 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
205 |
st->print(", CORE "); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
206 |
getrlimit(RLIMIT_CORE, &rlim); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
207 |
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
208 |
else st->print("%luk", rlim.rlim_cur >> 10); |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
209 |
|
22826 | 210 |
// Isn't there on solaris |
22828 | 211 |
#if !defined(TARGET_OS_FAMILY_solaris) && !defined(TARGET_OS_FAMILY_aix) |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
212 |
st->print(", NPROC "); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
213 |
getrlimit(RLIMIT_NPROC, &rlim); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
214 |
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
215 |
else st->print("%lu", rlim.rlim_cur); |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
216 |
#endif |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
217 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
218 |
st->print(", NOFILE "); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
219 |
getrlimit(RLIMIT_NOFILE, &rlim); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
220 |
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
221 |
else st->print("%lu", rlim.rlim_cur); |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
222 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
223 |
st->print(", AS "); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
224 |
getrlimit(RLIMIT_AS, &rlim); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
225 |
if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); |
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
226 |
else st->print("%luk", rlim.rlim_cur >> 10); |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
227 |
st->cr(); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
228 |
} |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
229 |
|
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
230 |
void os::Posix::print_uname_info(outputStream* st) { |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
231 |
// kernel |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
232 |
st->print("uname:"); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
233 |
struct utsname name; |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
234 |
uname(&name); |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22894
diff
changeset
|
235 |
st->print("%s ", name.sysname); |
26569
5fcbc13c071c
8056930: Output host info under some condition for core dump
minqi
parents:
25946
diff
changeset
|
236 |
#ifdef ASSERT |
5fcbc13c071c
8056930: Output host info under some condition for core dump
minqi
parents:
25946
diff
changeset
|
237 |
st->print("%s ", name.nodename); |
5fcbc13c071c
8056930: Output host info under some condition for core dump
minqi
parents:
25946
diff
changeset
|
238 |
#endif |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22894
diff
changeset
|
239 |
st->print("%s ", name.release); |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22894
diff
changeset
|
240 |
st->print("%s ", name.version); |
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22894
diff
changeset
|
241 |
st->print("%s", name.machine); |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
242 |
st->cr(); |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
243 |
} |
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
244 |
|
31963
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
245 |
bool os::get_host_name(char* buf, size_t buflen) { |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
246 |
struct utsname name; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
247 |
uname(&name); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
248 |
jio_snprintf(buf, buflen, "%s", name.nodename); |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
249 |
return true; |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
250 |
} |
641ed52732ec
8026324: hs_err improvement: Add summary section to hs_err file
coleenp
parents:
31610
diff
changeset
|
251 |
|
16605
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
252 |
bool os::has_allocatable_memory_limit(julong* limit) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
253 |
struct rlimit rlim; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
254 |
int getrlimit_res = getrlimit(RLIMIT_AS, &rlim); |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
255 |
// if there was an error when calling getrlimit, assume that there is no limitation |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
256 |
// on virtual memory. |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
257 |
bool result; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
258 |
if ((getrlimit_res != 0) || (rlim.rlim_cur == RLIM_INFINITY)) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
259 |
result = false; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
260 |
} else { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
261 |
*limit = (julong)rlim.rlim_cur; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
262 |
result = true; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
263 |
} |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
264 |
#ifdef _LP64 |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
265 |
return result; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
266 |
#else |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
267 |
// arbitrary virtual space limit for 32 bit Unices found by testing. If |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
268 |
// getrlimit above returned a limit, bound it with this limit. Otherwise |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
269 |
// directly use it. |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
270 |
const julong max_virtual_limit = (julong)3800*M; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
271 |
if (result) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
272 |
*limit = MIN2(*limit, max_virtual_limit); |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
273 |
} else { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
274 |
*limit = max_virtual_limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
275 |
} |
12735
3e2e491f4f69
7165755: OS Information much longer on linux than other platforms
nloodin
parents:
11418
diff
changeset
|
276 |
|
16605
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
277 |
// bound by actually allocatable memory. The algorithm uses two bounds, an |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
278 |
// upper and a lower limit. The upper limit is the current highest amount of |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
279 |
// memory that could not be allocated, the lower limit is the current highest |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
280 |
// amount of memory that could be allocated. |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
281 |
// The algorithm iteratively refines the result by halving the difference |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
282 |
// between these limits, updating either the upper limit (if that value could |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
283 |
// not be allocated) or the lower limit (if the that value could be allocated) |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
284 |
// until the difference between these limits is "small". |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
285 |
|
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
286 |
// the minimum amount of memory we care about allocating. |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
287 |
const julong min_allocation_size = M; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
288 |
|
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
289 |
julong upper_limit = *limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
290 |
|
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
291 |
// first check a few trivial cases |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
292 |
if (is_allocatable(upper_limit) || (upper_limit <= min_allocation_size)) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
293 |
*limit = upper_limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
294 |
} else if (!is_allocatable(min_allocation_size)) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
295 |
// we found that not even min_allocation_size is allocatable. Return it |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
296 |
// anyway. There is no point to search for a better value any more. |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
297 |
*limit = min_allocation_size; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
298 |
} else { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
299 |
// perform the binary search. |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
300 |
julong lower_limit = min_allocation_size; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
301 |
while ((upper_limit - lower_limit) > min_allocation_size) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
302 |
julong temp_limit = ((upper_limit - lower_limit) / 2) + lower_limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
303 |
temp_limit = align_size_down_(temp_limit, min_allocation_size); |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
304 |
if (is_allocatable(temp_limit)) { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
305 |
lower_limit = temp_limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
306 |
} else { |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
307 |
upper_limit = temp_limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
308 |
} |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
309 |
} |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
310 |
*limit = lower_limit; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
311 |
} |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
312 |
return true; |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
313 |
#endif |
ba13efd453bc
7112912: Message "Error occurred during initialization of VM" on boxes with lots of RAM
tschatzl
parents:
14840
diff
changeset
|
314 |
} |
17121
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
315 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
316 |
const char* os::get_current_directory(char *buf, size_t buflen) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
317 |
return getcwd(buf, buflen); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
318 |
} |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
319 |
|
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
320 |
FILE* os::open(int fd, const char* mode) { |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
321 |
return ::fdopen(fd, mode); |
e40a97c700d9
8012260: ciReplay: Include PID into the name of replay data file
vlivanov
parents:
16605
diff
changeset
|
322 |
} |
18943 | 323 |
|
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
324 |
// Builds a platform dependent Agent_OnLoad_<lib_name> function name |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
325 |
// which is used to find statically linked in agents. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
326 |
// Parameters: |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
327 |
// sym_name: Symbol in library we are looking for |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
328 |
// lib_name: Name of library to look in, NULL for shared libs. |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
329 |
// is_absolute_path == true if lib_name is absolute path to agent |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
330 |
// such as "/a/b/libL.so" |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
331 |
// == false if only the base name of the library is passed in |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
332 |
// such as "L" |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
333 |
char* os::build_agent_function_name(const char *sym_name, const char *lib_name, |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
334 |
bool is_absolute_path) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
335 |
char *agent_entry_name; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
336 |
size_t len; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
337 |
size_t name_len; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
338 |
size_t prefix_len = strlen(JNI_LIB_PREFIX); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
339 |
size_t suffix_len = strlen(JNI_LIB_SUFFIX); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
340 |
const char *start; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
341 |
|
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
342 |
if (lib_name != NULL) { |
36585
00416e804a66
8147456: Parsing of argument for -agentpath can write outside of allocated memory
dsamersoff
parents:
36355
diff
changeset
|
343 |
name_len = strlen(lib_name); |
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
344 |
if (is_absolute_path) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
345 |
// Need to strip path, prefix and suffix |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
346 |
if ((start = strrchr(lib_name, *os::file_separator())) != NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
347 |
lib_name = ++start; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
348 |
} |
36585
00416e804a66
8147456: Parsing of argument for -agentpath can write outside of allocated memory
dsamersoff
parents:
36355
diff
changeset
|
349 |
if (strlen(lib_name) <= (prefix_len + suffix_len)) { |
19553
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
350 |
return NULL; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
351 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
352 |
lib_name += prefix_len; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
353 |
name_len = strlen(lib_name) - suffix_len; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
354 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
355 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
356 |
len = (lib_name != NULL ? name_len : 0) + strlen(sym_name) + 2; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
357 |
agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
358 |
if (agent_entry_name == NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
359 |
return NULL; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
360 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
361 |
strcpy(agent_entry_name, sym_name); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
362 |
if (lib_name != NULL) { |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
363 |
strcat(agent_entry_name, "_"); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
364 |
strncat(agent_entry_name, lib_name, name_len); |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
365 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
366 |
return agent_entry_name; |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
367 |
} |
9bbd930be684
8014135: The JVMTI specification does not conform to recent changes in JNI specification
bpittore
parents:
18943
diff
changeset
|
368 |
|
22891
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
369 |
int os::sleep(Thread* thread, jlong millis, bool interruptible) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
370 |
assert(thread == Thread::current(), "thread consistency check"); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
371 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
372 |
ParkEvent * const slp = thread->_SleepEvent ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
373 |
slp->reset() ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
374 |
OrderAccess::fence() ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
375 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
376 |
if (interruptible) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
377 |
jlong prevtime = javaTimeNanos(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
378 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
379 |
for (;;) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
380 |
if (os::is_interrupted(thread, true)) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
381 |
return OS_INTRPT; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
382 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
383 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
384 |
jlong newtime = javaTimeNanos(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
385 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
386 |
if (newtime - prevtime < 0) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
387 |
// time moving backwards, should only happen if no monotonic clock |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
388 |
// not a guarantee() because JVM should not abort on kernel/glibc bugs |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
389 |
assert(!os::supports_monotonic_clock(), "unexpected time moving backwards detected in os::sleep(interruptible)"); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
390 |
} else { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
391 |
millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
392 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
393 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
394 |
if (millis <= 0) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
395 |
return OS_OK; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
396 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
397 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
398 |
prevtime = newtime; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
399 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
400 |
{ |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
401 |
assert(thread->is_Java_thread(), "sanity check"); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
402 |
JavaThread *jt = (JavaThread *) thread; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
403 |
ThreadBlockInVM tbivm(jt); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
404 |
OSThreadWaitState osts(jt->osthread(), false /* not Object.wait() */); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
405 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
406 |
jt->set_suspend_equivalent(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
407 |
// cleared by handle_special_suspend_equivalent_condition() or |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
408 |
// java_suspend_self() via check_and_wait_while_suspended() |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
409 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
410 |
slp->park(millis); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
411 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
412 |
// were we externally suspended while we were waiting? |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
413 |
jt->check_and_wait_while_suspended(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
414 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
415 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
416 |
} else { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
417 |
OSThreadWaitState osts(thread->osthread(), false /* not Object.wait() */); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
418 |
jlong prevtime = javaTimeNanos(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
419 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
420 |
for (;;) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
421 |
// It'd be nice to avoid the back-to-back javaTimeNanos() calls on |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
422 |
// the 1st iteration ... |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
423 |
jlong newtime = javaTimeNanos(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
424 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
425 |
if (newtime - prevtime < 0) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
426 |
// time moving backwards, should only happen if no monotonic clock |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
427 |
// not a guarantee() because JVM should not abort on kernel/glibc bugs |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
428 |
assert(!os::supports_monotonic_clock(), "unexpected time moving backwards detected on os::sleep(!interruptible)"); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
429 |
} else { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
430 |
millis -= (newtime - prevtime) / NANOSECS_PER_MILLISEC; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
431 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
432 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
433 |
if (millis <= 0) break ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
434 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
435 |
prevtime = newtime; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
436 |
slp->park(millis); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
437 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
438 |
return OS_OK ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
439 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
440 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
441 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
442 |
//////////////////////////////////////////////////////////////////////////////// |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
443 |
// interrupt support |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
444 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
445 |
void os::interrupt(Thread* thread) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
446 |
assert(Thread::current() == thread || Threads_lock->owned_by_self(), |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
447 |
"possibility of dangling Thread pointer"); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
448 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
449 |
OSThread* osthread = thread->osthread(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
450 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
451 |
if (!osthread->interrupted()) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
452 |
osthread->set_interrupted(true); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
453 |
// More than one thread can get here with the same value of osthread, |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
454 |
// resulting in multiple notifications. We do, however, want the store |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
455 |
// to interrupted() to be visible to other threads before we execute unpark(). |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
456 |
OrderAccess::fence(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
457 |
ParkEvent * const slp = thread->_SleepEvent ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
458 |
if (slp != NULL) slp->unpark() ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
459 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
460 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
461 |
// For JSR166. Unpark even if interrupt status already was set |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
462 |
if (thread->is_Java_thread()) |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
463 |
((JavaThread*)thread)->parker()->unpark(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
464 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
465 |
ParkEvent * ev = thread->_ParkEvent ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
466 |
if (ev != NULL) ev->unpark() ; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
467 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
468 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
469 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
470 |
bool os::is_interrupted(Thread* thread, bool clear_interrupted) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
471 |
assert(Thread::current() == thread || Threads_lock->owned_by_self(), |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
472 |
"possibility of dangling Thread pointer"); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
473 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
474 |
OSThread* osthread = thread->osthread(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
475 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
476 |
bool interrupted = osthread->interrupted(); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
477 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
478 |
// NOTE that since there is no "lock" around the interrupt and |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
479 |
// is_interrupted operations, there is the possibility that the |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
480 |
// interrupted flag (in osThread) will be "false" but that the |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
481 |
// low-level events will be in the signaled state. This is |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
482 |
// intentional. The effect of this is that Object.wait() and |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
483 |
// LockSupport.park() will appear to have a spurious wakeup, which |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
484 |
// is allowed and not harmful, and the possibility is so rare that |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
485 |
// it is not worth the added complexity to add yet another lock. |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
486 |
// For the sleep event an explicit reset is performed on entry |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
487 |
// to os::sleep, so there is no early return. It has also been |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
488 |
// recommended not to put the interrupted flag into the "event" |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
489 |
// structure because it hides the issue. |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
490 |
if (interrupted && clear_interrupted) { |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
491 |
osthread->set_interrupted(false); |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
492 |
// consider thread->_SleepEvent->reset() ... optional optimization |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
493 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
494 |
|
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
495 |
return interrupted; |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
496 |
} |
1f5d1fff23fa
6546236: Thread interrupt() of Thread.sleep() can be lost on Solaris due to race with signal handler
fparain
parents:
22528
diff
changeset
|
497 |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
498 |
|
22826 | 499 |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
500 |
static const struct { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
501 |
int sig; const char* name; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
502 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
503 |
g_signal_info[] = |
22826 | 504 |
{ |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
505 |
{ SIGABRT, "SIGABRT" }, |
22826 | 506 |
#ifdef SIGAIO |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
507 |
{ SIGAIO, "SIGAIO" }, |
22826 | 508 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
509 |
{ SIGALRM, "SIGALRM" }, |
22826 | 510 |
#ifdef SIGALRM1 |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
511 |
{ SIGALRM1, "SIGALRM1" }, |
22826 | 512 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
513 |
{ SIGBUS, "SIGBUS" }, |
22826 | 514 |
#ifdef SIGCANCEL |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
515 |
{ SIGCANCEL, "SIGCANCEL" }, |
22826 | 516 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
517 |
{ SIGCHLD, "SIGCHLD" }, |
22826 | 518 |
#ifdef SIGCLD |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
519 |
{ SIGCLD, "SIGCLD" }, |
22826 | 520 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
521 |
{ SIGCONT, "SIGCONT" }, |
22826 | 522 |
#ifdef SIGCPUFAIL |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
523 |
{ SIGCPUFAIL, "SIGCPUFAIL" }, |
22826 | 524 |
#endif |
525 |
#ifdef SIGDANGER |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
526 |
{ SIGDANGER, "SIGDANGER" }, |
22826 | 527 |
#endif |
528 |
#ifdef SIGDIL |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
529 |
{ SIGDIL, "SIGDIL" }, |
22826 | 530 |
#endif |
531 |
#ifdef SIGEMT |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
532 |
{ SIGEMT, "SIGEMT" }, |
22826 | 533 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
534 |
{ SIGFPE, "SIGFPE" }, |
22826 | 535 |
#ifdef SIGFREEZE |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
536 |
{ SIGFREEZE, "SIGFREEZE" }, |
22826 | 537 |
#endif |
538 |
#ifdef SIGGFAULT |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
539 |
{ SIGGFAULT, "SIGGFAULT" }, |
22826 | 540 |
#endif |
541 |
#ifdef SIGGRANT |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
542 |
{ SIGGRANT, "SIGGRANT" }, |
22826 | 543 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
544 |
{ SIGHUP, "SIGHUP" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
545 |
{ SIGILL, "SIGILL" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
546 |
{ SIGINT, "SIGINT" }, |
22826 | 547 |
#ifdef SIGIO |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
548 |
{ SIGIO, "SIGIO" }, |
22826 | 549 |
#endif |
550 |
#ifdef SIGIOINT |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
551 |
{ SIGIOINT, "SIGIOINT" }, |
22826 | 552 |
#endif |
553 |
#ifdef SIGIOT |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
554 |
// SIGIOT is there for BSD compatibility, but on most Unices just a |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
555 |
// synonym for SIGABRT. The result should be "SIGABRT", not |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
556 |
// "SIGIOT". |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
557 |
#if (SIGIOT != SIGABRT ) |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
558 |
{ SIGIOT, "SIGIOT" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
559 |
#endif |
22826 | 560 |
#endif |
561 |
#ifdef SIGKAP |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
562 |
{ SIGKAP, "SIGKAP" }, |
22826 | 563 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
564 |
{ SIGKILL, "SIGKILL" }, |
22826 | 565 |
#ifdef SIGLOST |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
566 |
{ SIGLOST, "SIGLOST" }, |
22826 | 567 |
#endif |
568 |
#ifdef SIGLWP |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
569 |
{ SIGLWP, "SIGLWP" }, |
22826 | 570 |
#endif |
571 |
#ifdef SIGLWPTIMER |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
572 |
{ SIGLWPTIMER, "SIGLWPTIMER" }, |
22826 | 573 |
#endif |
574 |
#ifdef SIGMIGRATE |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
575 |
{ SIGMIGRATE, "SIGMIGRATE" }, |
22826 | 576 |
#endif |
577 |
#ifdef SIGMSG |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
578 |
{ SIGMSG, "SIGMSG" }, |
22826 | 579 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
580 |
{ SIGPIPE, "SIGPIPE" }, |
22826 | 581 |
#ifdef SIGPOLL |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
582 |
{ SIGPOLL, "SIGPOLL" }, |
22826 | 583 |
#endif |
584 |
#ifdef SIGPRE |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
585 |
{ SIGPRE, "SIGPRE" }, |
22826 | 586 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
587 |
{ SIGPROF, "SIGPROF" }, |
22826 | 588 |
#ifdef SIGPTY |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
589 |
{ SIGPTY, "SIGPTY" }, |
22826 | 590 |
#endif |
591 |
#ifdef SIGPWR |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
592 |
{ SIGPWR, "SIGPWR" }, |
22826 | 593 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
594 |
{ SIGQUIT, "SIGQUIT" }, |
22826 | 595 |
#ifdef SIGRECONFIG |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
596 |
{ SIGRECONFIG, "SIGRECONFIG" }, |
22826 | 597 |
#endif |
598 |
#ifdef SIGRECOVERY |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
599 |
{ SIGRECOVERY, "SIGRECOVERY" }, |
22826 | 600 |
#endif |
601 |
#ifdef SIGRESERVE |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
602 |
{ SIGRESERVE, "SIGRESERVE" }, |
22826 | 603 |
#endif |
604 |
#ifdef SIGRETRACT |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
605 |
{ SIGRETRACT, "SIGRETRACT" }, |
22826 | 606 |
#endif |
607 |
#ifdef SIGSAK |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
608 |
{ SIGSAK, "SIGSAK" }, |
22826 | 609 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
610 |
{ SIGSEGV, "SIGSEGV" }, |
22826 | 611 |
#ifdef SIGSOUND |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
612 |
{ SIGSOUND, "SIGSOUND" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
613 |
#endif |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
614 |
#ifdef SIGSTKFLT |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
615 |
{ SIGSTKFLT, "SIGSTKFLT" }, |
22826 | 616 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
617 |
{ SIGSTOP, "SIGSTOP" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
618 |
{ SIGSYS, "SIGSYS" }, |
22826 | 619 |
#ifdef SIGSYSERROR |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
620 |
{ SIGSYSERROR, "SIGSYSERROR" }, |
22826 | 621 |
#endif |
622 |
#ifdef SIGTALRM |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
623 |
{ SIGTALRM, "SIGTALRM" }, |
22826 | 624 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
625 |
{ SIGTERM, "SIGTERM" }, |
22826 | 626 |
#ifdef SIGTHAW |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
627 |
{ SIGTHAW, "SIGTHAW" }, |
22826 | 628 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
629 |
{ SIGTRAP, "SIGTRAP" }, |
22826 | 630 |
#ifdef SIGTSTP |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
631 |
{ SIGTSTP, "SIGTSTP" }, |
22826 | 632 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
633 |
{ SIGTTIN, "SIGTTIN" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
634 |
{ SIGTTOU, "SIGTTOU" }, |
22826 | 635 |
#ifdef SIGURG |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
636 |
{ SIGURG, "SIGURG" }, |
22826 | 637 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
638 |
{ SIGUSR1, "SIGUSR1" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
639 |
{ SIGUSR2, "SIGUSR2" }, |
22826 | 640 |
#ifdef SIGVIRT |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
641 |
{ SIGVIRT, "SIGVIRT" }, |
22826 | 642 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
643 |
{ SIGVTALRM, "SIGVTALRM" }, |
22826 | 644 |
#ifdef SIGWAITING |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
645 |
{ SIGWAITING, "SIGWAITING" }, |
22826 | 646 |
#endif |
647 |
#ifdef SIGWINCH |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
648 |
{ SIGWINCH, "SIGWINCH" }, |
22826 | 649 |
#endif |
650 |
#ifdef SIGWINDOW |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
651 |
{ SIGWINDOW, "SIGWINDOW" }, |
22826 | 652 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
653 |
{ SIGXCPU, "SIGXCPU" }, |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
654 |
{ SIGXFSZ, "SIGXFSZ" }, |
22826 | 655 |
#ifdef SIGXRES |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
656 |
{ SIGXRES, "SIGXRES" }, |
22826 | 657 |
#endif |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
658 |
{ -1, NULL } |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
659 |
}; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
660 |
|
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
661 |
// Returned string is a constant. For unknown signals "UNKNOWN" is returned. |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
662 |
const char* os::Posix::get_signal_name(int sig, char* out, size_t outlen) { |
22826 | 663 |
|
664 |
const char* ret = NULL; |
|
665 |
||
666 |
#ifdef SIGRTMIN |
|
667 |
if (sig >= SIGRTMIN && sig <= SIGRTMAX) { |
|
668 |
if (sig == SIGRTMIN) { |
|
669 |
ret = "SIGRTMIN"; |
|
670 |
} else if (sig == SIGRTMAX) { |
|
671 |
ret = "SIGRTMAX"; |
|
672 |
} else { |
|
673 |
jio_snprintf(out, outlen, "SIGRTMIN+%d", sig - SIGRTMIN); |
|
674 |
return out; |
|
675 |
} |
|
676 |
} |
|
677 |
#endif |
|
678 |
||
679 |
if (sig > 0) { |
|
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
680 |
for (int idx = 0; g_signal_info[idx].sig != -1; idx ++) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
681 |
if (g_signal_info[idx].sig == sig) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
682 |
ret = g_signal_info[idx].name; |
22826 | 683 |
break; |
684 |
} |
|
685 |
} |
|
686 |
} |
|
687 |
||
688 |
if (!ret) { |
|
689 |
if (!is_valid_signal(sig)) { |
|
690 |
ret = "INVALID"; |
|
691 |
} else { |
|
692 |
ret = "UNKNOWN"; |
|
693 |
} |
|
694 |
} |
|
695 |
||
27471 | 696 |
if (out && outlen > 0) { |
697 |
strncpy(out, ret, outlen); |
|
698 |
out[outlen - 1] = '\0'; |
|
699 |
} |
|
22826 | 700 |
return out; |
701 |
} |
|
702 |
||
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
703 |
int os::Posix::get_signal_number(const char* signal_name) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
704 |
char tmp[30]; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
705 |
const char* s = signal_name; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
706 |
if (s[0] != 'S' || s[1] != 'I' || s[2] != 'G') { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
707 |
jio_snprintf(tmp, sizeof(tmp), "SIG%s", signal_name); |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
708 |
s = tmp; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
709 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
710 |
for (int idx = 0; g_signal_info[idx].sig != -1; idx ++) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
711 |
if (strcmp(g_signal_info[idx].name, s) == 0) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
712 |
return g_signal_info[idx].sig; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
713 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
714 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
715 |
return -1; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
716 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
717 |
|
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
718 |
int os::get_signal_number(const char* signal_name) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
719 |
return os::Posix::get_signal_number(signal_name); |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
720 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
721 |
|
22826 | 722 |
// Returns true if signal number is valid. |
723 |
bool os::Posix::is_valid_signal(int sig) { |
|
724 |
// MacOS not really POSIX compliant: sigaddset does not return |
|
725 |
// an error for invalid signal numbers. However, MacOS does not |
|
726 |
// support real time signals and simply seems to have just 33 |
|
727 |
// signals with no holes in the signal range. |
|
728 |
#ifdef __APPLE__ |
|
729 |
return sig >= 1 && sig < NSIG; |
|
730 |
#else |
|
731 |
// Use sigaddset to check for signal validity. |
|
732 |
sigset_t set; |
|
733 |
if (sigaddset(&set, sig) == -1 && errno == EINVAL) { |
|
734 |
return false; |
|
735 |
} |
|
736 |
return true; |
|
737 |
#endif |
|
738 |
} |
|
739 |
||
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
740 |
// Returns: |
35047
b1f924d2efe8
8145073: Filename and linenumber are not printed for asserts any more.
david
parents:
34621
diff
changeset
|
741 |
// NULL for an invalid signal number |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
742 |
// "SIG<num>" for a valid but unknown signal number |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
743 |
// signal name otherwise. |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
744 |
const char* os::exception_name(int sig, char* buf, size_t size) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
745 |
if (!os::Posix::is_valid_signal(sig)) { |
35047
b1f924d2efe8
8145073: Filename and linenumber are not printed for asserts any more.
david
parents:
34621
diff
changeset
|
746 |
return NULL; |
34621
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
747 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
748 |
const char* const name = os::Posix::get_signal_name(sig, buf, size); |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
749 |
if (strcmp(name, "UNKNOWN") == 0) { |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
750 |
jio_snprintf(buf, size, "SIG%d", sig); |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
751 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
752 |
return buf; |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
753 |
} |
7676bec20997
8143291: Remove redundant coding around os::exception_name
stuefe
parents:
34305
diff
changeset
|
754 |
|
22826 | 755 |
#define NUM_IMPORTANT_SIGS 32 |
756 |
// Returns one-line short description of a signal set in a user provided buffer. |
|
757 |
const char* os::Posix::describe_signal_set_short(const sigset_t* set, char* buffer, size_t buf_size) { |
|
22827 | 758 |
assert(buf_size == (NUM_IMPORTANT_SIGS + 1), "wrong buffer size"); |
22826 | 759 |
// Note: for shortness, just print out the first 32. That should |
760 |
// cover most of the useful ones, apart from realtime signals. |
|
761 |
for (int sig = 1; sig <= NUM_IMPORTANT_SIGS; sig++) { |
|
762 |
const int rc = sigismember(set, sig); |
|
763 |
if (rc == -1 && errno == EINVAL) { |
|
764 |
buffer[sig-1] = '?'; |
|
765 |
} else { |
|
766 |
buffer[sig-1] = rc == 0 ? '0' : '1'; |
|
767 |
} |
|
768 |
} |
|
769 |
buffer[NUM_IMPORTANT_SIGS] = 0; |
|
770 |
return buffer; |
|
771 |
} |
|
772 |
||
773 |
// Prints one-line description of a signal set. |
|
774 |
void os::Posix::print_signal_set_short(outputStream* st, const sigset_t* set) { |
|
775 |
char buf[NUM_IMPORTANT_SIGS + 1]; |
|
776 |
os::Posix::describe_signal_set_short(set, buf, sizeof(buf)); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22894
diff
changeset
|
777 |
st->print("%s", buf); |
22826 | 778 |
} |
779 |
||
780 |
// Writes one-line description of a combination of sigaction.sa_flags into a user |
|
781 |
// provided buffer. Returns that buffer. |
|
782 |
const char* os::Posix::describe_sa_flags(int flags, char* buffer, size_t size) { |
|
783 |
char* p = buffer; |
|
784 |
size_t remaining = size; |
|
785 |
bool first = true; |
|
786 |
int idx = 0; |
|
787 |
||
788 |
assert(buffer, "invalid argument"); |
|
789 |
||
790 |
if (size == 0) { |
|
791 |
return buffer; |
|
792 |
} |
|
793 |
||
794 |
strncpy(buffer, "none", size); |
|
795 |
||
796 |
const struct { |
|
35155 | 797 |
// NB: i is an unsigned int here because SA_RESETHAND is on some |
798 |
// systems 0x80000000, which is implicitly unsigned. Assignining |
|
799 |
// it to an int field would be an overflow in unsigned-to-signed |
|
800 |
// conversion. |
|
801 |
unsigned int i; |
|
22826 | 802 |
const char* s; |
803 |
} flaginfo [] = { |
|
804 |
{ SA_NOCLDSTOP, "SA_NOCLDSTOP" }, |
|
805 |
{ SA_ONSTACK, "SA_ONSTACK" }, |
|
806 |
{ SA_RESETHAND, "SA_RESETHAND" }, |
|
807 |
{ SA_RESTART, "SA_RESTART" }, |
|
808 |
{ SA_SIGINFO, "SA_SIGINFO" }, |
|
809 |
{ SA_NOCLDWAIT, "SA_NOCLDWAIT" }, |
|
810 |
{ SA_NODEFER, "SA_NODEFER" }, |
|
811 |
#ifdef AIX |
|
812 |
{ SA_ONSTACK, "SA_ONSTACK" }, |
|
813 |
{ SA_OLDSTYLE, "SA_OLDSTYLE" }, |
|
814 |
#endif |
|
815 |
{ 0, NULL } |
|
816 |
}; |
|
817 |
||
818 |
for (idx = 0; flaginfo[idx].s && remaining > 1; idx++) { |
|
819 |
if (flags & flaginfo[idx].i) { |
|
820 |
if (first) { |
|
821 |
jio_snprintf(p, remaining, "%s", flaginfo[idx].s); |
|
822 |
first = false; |
|
823 |
} else { |
|
824 |
jio_snprintf(p, remaining, "|%s", flaginfo[idx].s); |
|
825 |
} |
|
826 |
const size_t len = strlen(p); |
|
827 |
p += len; |
|
828 |
remaining -= len; |
|
829 |
} |
|
830 |
} |
|
831 |
||
832 |
buffer[size - 1] = '\0'; |
|
833 |
||
834 |
return buffer; |
|
835 |
} |
|
836 |
||
837 |
// Prints one-line description of a combination of sigaction.sa_flags. |
|
838 |
void os::Posix::print_sa_flags(outputStream* st, int flags) { |
|
839 |
char buffer[0x100]; |
|
840 |
os::Posix::describe_sa_flags(flags, buffer, sizeof(buffer)); |
|
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22894
diff
changeset
|
841 |
st->print("%s", buffer); |
22826 | 842 |
} |
843 |
||
844 |
// Helper function for os::Posix::print_siginfo_...(): |
|
845 |
// return a textual description for signal code. |
|
846 |
struct enum_sigcode_desc_t { |
|
847 |
const char* s_name; |
|
848 |
const char* s_desc; |
|
849 |
}; |
|
850 |
||
851 |
static bool get_signal_code_description(const siginfo_t* si, enum_sigcode_desc_t* out) { |
|
852 |
||
853 |
const struct { |
|
854 |
int sig; int code; const char* s_code; const char* s_desc; |
|
855 |
} t1 [] = { |
|
856 |
{ SIGILL, ILL_ILLOPC, "ILL_ILLOPC", "Illegal opcode." }, |
|
857 |
{ SIGILL, ILL_ILLOPN, "ILL_ILLOPN", "Illegal operand." }, |
|
858 |
{ SIGILL, ILL_ILLADR, "ILL_ILLADR", "Illegal addressing mode." }, |
|
859 |
{ SIGILL, ILL_ILLTRP, "ILL_ILLTRP", "Illegal trap." }, |
|
860 |
{ SIGILL, ILL_PRVOPC, "ILL_PRVOPC", "Privileged opcode." }, |
|
861 |
{ SIGILL, ILL_PRVREG, "ILL_PRVREG", "Privileged register." }, |
|
862 |
{ SIGILL, ILL_COPROC, "ILL_COPROC", "Coprocessor error." }, |
|
863 |
{ SIGILL, ILL_BADSTK, "ILL_BADSTK", "Internal stack error." }, |
|
864 |
#if defined(IA64) && defined(LINUX) |
|
865 |
{ SIGILL, ILL_BADIADDR, "ILL_BADIADDR", "Unimplemented instruction address" }, |
|
866 |
{ SIGILL, ILL_BREAK, "ILL_BREAK", "Application Break instruction" }, |
|
867 |
#endif |
|
868 |
{ SIGFPE, FPE_INTDIV, "FPE_INTDIV", "Integer divide by zero." }, |
|
869 |
{ SIGFPE, FPE_INTOVF, "FPE_INTOVF", "Integer overflow." }, |
|
870 |
{ SIGFPE, FPE_FLTDIV, "FPE_FLTDIV", "Floating-point divide by zero." }, |
|
871 |
{ SIGFPE, FPE_FLTOVF, "FPE_FLTOVF", "Floating-point overflow." }, |
|
872 |
{ SIGFPE, FPE_FLTUND, "FPE_FLTUND", "Floating-point underflow." }, |
|
873 |
{ SIGFPE, FPE_FLTRES, "FPE_FLTRES", "Floating-point inexact result." }, |
|
874 |
{ SIGFPE, FPE_FLTINV, "FPE_FLTINV", "Invalid floating-point operation." }, |
|
875 |
{ SIGFPE, FPE_FLTSUB, "FPE_FLTSUB", "Subscript out of range." }, |
|
876 |
{ SIGSEGV, SEGV_MAPERR, "SEGV_MAPERR", "Address not mapped to object." }, |
|
877 |
{ SIGSEGV, SEGV_ACCERR, "SEGV_ACCERR", "Invalid permissions for mapped object." }, |
|
878 |
#ifdef AIX |
|
879 |
// no explanation found what keyerr would be |
|
880 |
{ SIGSEGV, SEGV_KEYERR, "SEGV_KEYERR", "key error" }, |
|
881 |
#endif |
|
882 |
#if defined(IA64) && !defined(AIX) |
|
883 |
{ SIGSEGV, SEGV_PSTKOVF, "SEGV_PSTKOVF", "Paragraph stack overflow" }, |
|
884 |
#endif |
|
34233
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
885 |
#if defined(__sparc) && defined(SOLARIS) |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
886 |
// define Solaris Sparc M7 ADI SEGV signals |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
887 |
#if !defined(SEGV_ACCADI) |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
888 |
#define SEGV_ACCADI 3 |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
889 |
#endif |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
890 |
{ SIGSEGV, SEGV_ACCADI, "SEGV_ACCADI", "ADI not enabled for mapped object." }, |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
891 |
#if !defined(SEGV_ACCDERR) |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
892 |
#define SEGV_ACCDERR 4 |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
893 |
#endif |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
894 |
{ SIGSEGV, SEGV_ACCDERR, "SEGV_ACCDERR", "ADI disrupting exception." }, |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
895 |
#if !defined(SEGV_ACCPERR) |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
896 |
#define SEGV_ACCPERR 5 |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
897 |
#endif |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
898 |
{ SIGSEGV, SEGV_ACCPERR, "SEGV_ACCPERR", "ADI precise exception." }, |
2cf348387c44
8141445: Use of Solaris/SPARC M7 libadimalloc.so can generate unknown signal in hs_err file
gthornbr
parents:
33766
diff
changeset
|
899 |
#endif // defined(__sparc) && defined(SOLARIS) |
22826 | 900 |
{ SIGBUS, BUS_ADRALN, "BUS_ADRALN", "Invalid address alignment." }, |
901 |
{ SIGBUS, BUS_ADRERR, "BUS_ADRERR", "Nonexistent physical address." }, |
|
902 |
{ SIGBUS, BUS_OBJERR, "BUS_OBJERR", "Object-specific hardware error." }, |
|
903 |
{ SIGTRAP, TRAP_BRKPT, "TRAP_BRKPT", "Process breakpoint." }, |
|
904 |
{ SIGTRAP, TRAP_TRACE, "TRAP_TRACE", "Process trace trap." }, |
|
905 |
{ SIGCHLD, CLD_EXITED, "CLD_EXITED", "Child has exited." }, |
|
906 |
{ SIGCHLD, CLD_KILLED, "CLD_KILLED", "Child has terminated abnormally and did not create a core file." }, |
|
907 |
{ SIGCHLD, CLD_DUMPED, "CLD_DUMPED", "Child has terminated abnormally and created a core file." }, |
|
908 |
{ SIGCHLD, CLD_TRAPPED, "CLD_TRAPPED", "Traced child has trapped." }, |
|
909 |
{ SIGCHLD, CLD_STOPPED, "CLD_STOPPED", "Child has stopped." }, |
|
910 |
{ SIGCHLD, CLD_CONTINUED,"CLD_CONTINUED","Stopped child has continued." }, |
|
911 |
#ifdef SIGPOLL |
|
912 |
{ SIGPOLL, POLL_OUT, "POLL_OUT", "Output buffers available." }, |
|
913 |
{ SIGPOLL, POLL_MSG, "POLL_MSG", "Input message available." }, |
|
914 |
{ SIGPOLL, POLL_ERR, "POLL_ERR", "I/O error." }, |
|
915 |
{ SIGPOLL, POLL_PRI, "POLL_PRI", "High priority input available." }, |
|
916 |
{ SIGPOLL, POLL_HUP, "POLL_HUP", "Device disconnected. [Option End]" }, |
|
917 |
#endif |
|
918 |
{ -1, -1, NULL, NULL } |
|
919 |
}; |
|
920 |
||
921 |
// Codes valid in any signal context. |
|
922 |
const struct { |
|
923 |
int code; const char* s_code; const char* s_desc; |
|
924 |
} t2 [] = { |
|
925 |
{ SI_USER, "SI_USER", "Signal sent by kill()." }, |
|
926 |
{ SI_QUEUE, "SI_QUEUE", "Signal sent by the sigqueue()." }, |
|
927 |
{ SI_TIMER, "SI_TIMER", "Signal generated by expiration of a timer set by timer_settime()." }, |
|
928 |
{ SI_ASYNCIO, "SI_ASYNCIO", "Signal generated by completion of an asynchronous I/O request." }, |
|
929 |
{ SI_MESGQ, "SI_MESGQ", "Signal generated by arrival of a message on an empty message queue." }, |
|
930 |
// Linux specific |
|
931 |
#ifdef SI_TKILL |
|
932 |
{ SI_TKILL, "SI_TKILL", "Signal sent by tkill (pthread_kill)" }, |
|
933 |
#endif |
|
934 |
#ifdef SI_DETHREAD |
|
935 |
{ SI_DETHREAD, "SI_DETHREAD", "Signal sent by execve() killing subsidiary threads" }, |
|
936 |
#endif |
|
937 |
#ifdef SI_KERNEL |
|
938 |
{ SI_KERNEL, "SI_KERNEL", "Signal sent by kernel." }, |
|
939 |
#endif |
|
940 |
#ifdef SI_SIGIO |
|
941 |
{ SI_SIGIO, "SI_SIGIO", "Signal sent by queued SIGIO" }, |
|
942 |
#endif |
|
943 |
||
944 |
#ifdef AIX |
|
945 |
{ SI_UNDEFINED, "SI_UNDEFINED","siginfo contains partial information" }, |
|
946 |
{ SI_EMPTY, "SI_EMPTY", "siginfo contains no useful information" }, |
|
947 |
#endif |
|
948 |
||
949 |
#ifdef __sun |
|
950 |
{ SI_NOINFO, "SI_NOINFO", "No signal information" }, |
|
951 |
{ SI_RCTL, "SI_RCTL", "kernel generated signal via rctl action" }, |
|
952 |
{ SI_LWP, "SI_LWP", "Signal sent via lwp_kill" }, |
|
953 |
#endif |
|
954 |
||
955 |
{ -1, NULL, NULL } |
|
956 |
}; |
|
957 |
||
958 |
const char* s_code = NULL; |
|
959 |
const char* s_desc = NULL; |
|
960 |
||
961 |
for (int i = 0; t1[i].sig != -1; i ++) { |
|
962 |
if (t1[i].sig == si->si_signo && t1[i].code == si->si_code) { |
|
963 |
s_code = t1[i].s_code; |
|
964 |
s_desc = t1[i].s_desc; |
|
965 |
break; |
|
966 |
} |
|
967 |
} |
|
968 |
||
969 |
if (s_code == NULL) { |
|
970 |
for (int i = 0; t2[i].s_code != NULL; i ++) { |
|
971 |
if (t2[i].code == si->si_code) { |
|
972 |
s_code = t2[i].s_code; |
|
973 |
s_desc = t2[i].s_desc; |
|
974 |
} |
|
975 |
} |
|
976 |
} |
|
977 |
||
978 |
if (s_code == NULL) { |
|
979 |
out->s_name = "unknown"; |
|
980 |
out->s_desc = "unknown"; |
|
981 |
return false; |
|
982 |
} |
|
983 |
||
984 |
out->s_name = s_code; |
|
985 |
out->s_desc = s_desc; |
|
986 |
||
987 |
return true; |
|
988 |
} |
|
989 |
||
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
990 |
void os::print_siginfo(outputStream* os, const void* si0) { |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
991 |
|
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
992 |
const siginfo_t* const si = (const siginfo_t*) si0; |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
993 |
|
22826 | 994 |
char buf[20]; |
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
995 |
os->print("siginfo:"); |
22826 | 996 |
|
997 |
if (!si) { |
|
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
998 |
os->print(" <null>"); |
22826 | 999 |
return; |
1000 |
} |
|
1001 |
||
1002 |
const int sig = si->si_signo; |
|
1003 |
||
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1004 |
os->print(" si_signo: %d (%s)", sig, os::Posix::get_signal_name(sig, buf, sizeof(buf))); |
22826 | 1005 |
|
1006 |
enum_sigcode_desc_t ed; |
|
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1007 |
get_signal_code_description(si, &ed); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1008 |
os->print(", si_code: %d (%s)", si->si_code, ed.s_name); |
22826 | 1009 |
|
1010 |
if (si->si_errno) { |
|
1011 |
os->print(", si_errno: %d", si->si_errno); |
|
1012 |
} |
|
1013 |
||
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1014 |
// Output additional information depending on the signal code. |
22826 | 1015 |
|
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1016 |
// Note: Many implementations lump si_addr, si_pid, si_uid etc. together as unions, |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1017 |
// so it depends on the context which member to use. For synchronous error signals, |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1018 |
// we print si_addr, unless the signal was sent by another process or thread, in |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1019 |
// which case we print out pid or tid of the sender. |
22826 | 1020 |
if (si->si_code == SI_USER || si->si_code == SI_QUEUE) { |
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1021 |
const pid_t pid = si->si_pid; |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1022 |
os->print(", si_pid: %ld", (long) pid); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1023 |
if (IS_VALID_PID(pid)) { |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1024 |
const pid_t me = getpid(); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1025 |
if (me == pid) { |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1026 |
os->print(" (current process)"); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1027 |
} |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1028 |
} else { |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1029 |
os->print(" (invalid)"); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1030 |
} |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1031 |
os->print(", si_uid: %ld", (long) si->si_uid); |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1032 |
if (sig == SIGCHLD) { |
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1033 |
os->print(", si_status: %d", si->si_status); |
22826 | 1034 |
} |
1035 |
} else if (sig == SIGSEGV || sig == SIGBUS || sig == SIGILL || |
|
1036 |
sig == SIGTRAP || sig == SIGFPE) { |
|
33148
68fa8b6c4340
8042893: compiler: PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC needs to be removed from source files
david
parents:
33105
diff
changeset
|
1037 |
os->print(", si_addr: " PTR_FORMAT, p2i(si->si_addr)); |
22826 | 1038 |
#ifdef SIGPOLL |
1039 |
} else if (sig == SIGPOLL) { |
|
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1040 |
os->print(", si_band: %ld", si->si_band); |
22826 | 1041 |
#endif |
1042 |
} |
|
35176
11a9d4022d9e
8144219: [posix] Remove redundant code around os::print_siginfo()
stuefe
parents:
35077
diff
changeset
|
1043 |
|
22826 | 1044 |
} |
1045 |
||
34305
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1046 |
int os::Posix::unblock_thread_signal_mask(const sigset_t *set) { |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1047 |
return pthread_sigmask(SIG_UNBLOCK, set, NULL); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1048 |
} |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1049 |
|
35077
8b86440d3bf1
8145114: const-correctness for ucontext_t* reading functions
stuefe
parents:
35047
diff
changeset
|
1050 |
address os::Posix::ucontext_get_pc(const ucontext_t* ctx) { |
34305
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1051 |
#ifdef TARGET_OS_FAMILY_linux |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1052 |
return Linux::ucontext_get_pc(ctx); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1053 |
#elif defined(TARGET_OS_FAMILY_solaris) |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1054 |
return Solaris::ucontext_get_pc(ctx); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1055 |
#elif defined(TARGET_OS_FAMILY_aix) |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1056 |
return Aix::ucontext_get_pc(ctx); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1057 |
#elif defined(TARGET_OS_FAMILY_bsd) |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1058 |
return Bsd::ucontext_get_pc(ctx); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1059 |
#else |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1060 |
VMError::report_and_die("unimplemented ucontext_get_pc"); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1061 |
#endif |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1062 |
} |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1063 |
|
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1064 |
void os::Posix::ucontext_set_pc(ucontext_t* ctx, address pc) { |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1065 |
#ifdef TARGET_OS_FAMILY_linux |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1066 |
Linux::ucontext_set_pc(ctx, pc); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1067 |
#elif defined(TARGET_OS_FAMILY_solaris) |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1068 |
Solaris::ucontext_set_pc(ctx, pc); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1069 |
#elif defined(TARGET_OS_FAMILY_aix) |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1070 |
Aix::ucontext_set_pc(ctx, pc); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1071 |
#elif defined(TARGET_OS_FAMILY_bsd) |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1072 |
Bsd::ucontext_set_pc(ctx, pc); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1073 |
#else |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1074 |
VMError::report_and_die("unimplemented ucontext_get_pc"); |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1075 |
#endif |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1076 |
} |
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1077 |
|
36355
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1078 |
char* os::Posix::describe_pthread_attr(char* buf, size_t buflen, const pthread_attr_t* attr) { |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1079 |
size_t stack_size = 0; |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1080 |
size_t guard_size = 0; |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1081 |
int detachstate = 0; |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1082 |
pthread_attr_getstacksize(attr, &stack_size); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1083 |
pthread_attr_getguardsize(attr, &guard_size); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1084 |
pthread_attr_getdetachstate(attr, &detachstate); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1085 |
jio_snprintf(buf, buflen, "stacksize: " SIZE_FORMAT "k, guardsize: " SIZE_FORMAT "k, %s", |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1086 |
stack_size / 1024, guard_size / 1024, |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1087 |
(detachstate == PTHREAD_CREATE_DETACHED ? "detached" : "joinable")); |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1088 |
return buf; |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1089 |
} |
dd339cbafd31
8149036: Add tracing for thread related events at os level
stuefe
parents:
36174
diff
changeset
|
1090 |
|
34305
e399e6b44631
8136978: Much nearly duplicated code for vmError support
sebastian
parents:
34233
diff
changeset
|
1091 |
|
18943 | 1092 |
os::WatcherThreadCrashProtection::WatcherThreadCrashProtection() { |
1093 |
assert(Thread::current()->is_Watcher_thread(), "Must be WatcherThread"); |
|
1094 |
} |
|
1095 |
||
1096 |
/* |
|
1097 |
* See the caveats for this class in os_posix.hpp |
|
1098 |
* Protects the callback call so that SIGSEGV / SIGBUS jumps back into this |
|
1099 |
* method and returns false. If none of the signals are raised, returns true. |
|
1100 |
* The callback is supposed to provide the method that should be protected. |
|
1101 |
*/ |
|
1102 |
bool os::WatcherThreadCrashProtection::call(os::CrashProtectionCallback& cb) { |
|
19691
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1103 |
sigset_t saved_sig_mask; |
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1104 |
|
18943 | 1105 |
assert(Thread::current()->is_Watcher_thread(), "Only for WatcherThread"); |
1106 |
assert(!WatcherThread::watcher_thread()->has_crash_protection(), |
|
1107 |
"crash_protection already set?"); |
|
1108 |
||
19691
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1109 |
// we cannot rely on sigsetjmp/siglongjmp to save/restore the signal mask |
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1110 |
// since on at least some systems (OS X) siglongjmp will restore the mask |
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1111 |
// for the process, not the thread |
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1112 |
pthread_sigmask(0, NULL, &saved_sig_mask); |
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1113 |
if (sigsetjmp(_jmpbuf, 0) == 0) { |
18943 | 1114 |
// make sure we can see in the signal handler that we have crash protection |
1115 |
// installed |
|
1116 |
WatcherThread::watcher_thread()->set_crash_protection(this); |
|
1117 |
cb.call(); |
|
1118 |
// and clear the crash protection |
|
1119 |
WatcherThread::watcher_thread()->set_crash_protection(NULL); |
|
1120 |
return true; |
|
1121 |
} |
|
1122 |
// this happens when we siglongjmp() back |
|
19691
5116fb76692a
8023720: (hotspot) setjmp/longjmp changes the process signal mask on OS X
sla
parents:
18943
diff
changeset
|
1123 |
pthread_sigmask(SIG_SETMASK, &saved_sig_mask, NULL); |
18943 | 1124 |
WatcherThread::watcher_thread()->set_crash_protection(NULL); |
1125 |
return false; |
|
1126 |
} |
|
1127 |
||
1128 |
void os::WatcherThreadCrashProtection::restore() { |
|
1129 |
assert(WatcherThread::watcher_thread()->has_crash_protection(), |
|
1130 |
"must have crash protection"); |
|
1131 |
||
1132 |
siglongjmp(_jmpbuf, 1); |
|
1133 |
} |
|
1134 |
||
1135 |
void os::WatcherThreadCrashProtection::check_crash_protection(int sig, |
|
1136 |
Thread* thread) { |
|
1137 |
||
1138 |
if (thread != NULL && |
|
1139 |
thread->is_Watcher_thread() && |
|
1140 |
WatcherThread::watcher_thread()->has_crash_protection()) { |
|
1141 |
||
1142 |
if (sig == SIGSEGV || sig == SIGBUS) { |
|
1143 |
WatcherThread::watcher_thread()->crash_protection()->restore(); |
|
1144 |
} |
|
1145 |
} |
|
1146 |
} |
|
31610 | 1147 |
|
33105
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31991
diff
changeset
|
1148 |
#define check_with_errno(check_type, cond, msg) \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31991
diff
changeset
|
1149 |
do { \ |
294e48b4f704
8080775: Better argument formatting for assert() and friends
david
parents:
31991
diff
changeset
|
1150 |
int err = errno; \ |
37113 | 1151 |
check_type(cond, "%s; error='%s' (errno=%s)", msg, os::strerror(err), \ |
1152 |
os::errno_name(err)); \ |
|
31610 | 1153 |
} while (false) |
1154 |
||
1155 |
#define assert_with_errno(cond, msg) check_with_errno(assert, cond, msg) |
|
1156 |
#define guarantee_with_errno(cond, msg) check_with_errno(guarantee, cond, msg) |
|
1157 |
||
1158 |
// POSIX unamed semaphores are not supported on OS X. |
|
1159 |
#ifndef __APPLE__ |
|
1160 |
||
1161 |
PosixSemaphore::PosixSemaphore(uint value) { |
|
1162 |
int ret = sem_init(&_semaphore, 0, value); |
|
1163 |
||
1164 |
guarantee_with_errno(ret == 0, "Failed to initialize semaphore"); |
|
1165 |
} |
|
1166 |
||
1167 |
PosixSemaphore::~PosixSemaphore() { |
|
1168 |
sem_destroy(&_semaphore); |
|
1169 |
} |
|
1170 |
||
1171 |
void PosixSemaphore::signal(uint count) { |
|
1172 |
for (uint i = 0; i < count; i++) { |
|
1173 |
int ret = sem_post(&_semaphore); |
|
1174 |
||
1175 |
assert_with_errno(ret == 0, "sem_post failed"); |
|
1176 |
} |
|
1177 |
} |
|
1178 |
||
1179 |
void PosixSemaphore::wait() { |
|
1180 |
int ret; |
|
1181 |
||
1182 |
do { |
|
1183 |
ret = sem_wait(&_semaphore); |
|
1184 |
} while (ret != 0 && errno == EINTR); |
|
1185 |
||
1186 |
assert_with_errno(ret == 0, "sem_wait failed"); |
|
1187 |
} |
|
1188 |
||
1189 |
bool PosixSemaphore::trywait() { |
|
1190 |
int ret; |
|
1191 |
||
1192 |
do { |
|
1193 |
ret = sem_trywait(&_semaphore); |
|
1194 |
} while (ret != 0 && errno == EINTR); |
|
1195 |
||
1196 |
assert_with_errno(ret == 0 || errno == EAGAIN, "trywait failed"); |
|
1197 |
||
1198 |
return ret == 0; |
|
1199 |
} |
|
1200 |
||
31991
a7dd5bba0fd8
8132232: Signature mismatch between declaration and definition of PosixSemaphore::timedwait
simonis
parents:
31963
diff
changeset
|
1201 |
bool PosixSemaphore::timedwait(struct timespec ts) { |
31610 | 1202 |
while (true) { |
1203 |
int result = sem_timedwait(&_semaphore, &ts); |
|
1204 |
if (result == 0) { |
|
1205 |
return true; |
|
1206 |
} else if (errno == EINTR) { |
|
1207 |
continue; |
|
1208 |
} else if (errno == ETIMEDOUT) { |
|
1209 |
return false; |
|
1210 |
} else { |
|
1211 |
assert_with_errno(false, "timedwait failed"); |
|
1212 |
return false; |
|
1213 |
} |
|
1214 |
} |
|
1215 |
} |
|
1216 |
||
1217 |
#endif // __APPLE__ |