Mercurial > hg > truffle
annotate src/os/bsd/vm/osThread_bsd.hpp @ 6082:4b37c0dafe3a
7170010: conditional "ZIP_DEBUGINFO_FILES ?= 0" setting is not reliable on Windows
Summary: Always disable ZIP_DEBUGINFO_FILES on Windows.
Reviewed-by: acorn
author | dcubed |
---|---|
date | Fri, 18 May 2012 09:15:15 -0700 |
parents | 0105f367a14c |
children | 960a442eae91 |
rev | line source |
---|---|
3960 | 1 /* |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
3960 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef OS_BSD_VM_OSTHREAD_BSD_HPP | |
26 #define OS_BSD_VM_OSTHREAD_BSD_HPP | |
27 | |
28 private: | |
29 int _thread_type; | |
30 | |
31 public: | |
32 | |
33 int thread_type() const { | |
34 return _thread_type; | |
35 } | |
36 void set_thread_type(int type) { | |
37 _thread_type = type; | |
38 } | |
39 | |
40 private: | |
41 | |
42 #ifdef _ALLBSD_SOURCE | |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
43 |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
44 #ifdef __APPLE__ |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
45 thread_t _thread_id; |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
46 #else |
3960 | 47 pthread_t _thread_id; |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
48 #endif |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
49 |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
50 // _pthread_id is the pthread id, which is used by library calls |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
51 // (e.g. pthread_kill). |
3960 | 52 pthread_t _pthread_id; |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
53 |
3960 | 54 #else |
55 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each | |
56 // thread has a unique thread_id (BsdThreads or NPTL). It can be used | |
57 // to access /proc. | |
58 pid_t _thread_id; | |
59 | |
60 // _pthread_id is the pthread id, which is used by library calls | |
61 // (e.g. pthread_kill). | |
62 pthread_t _pthread_id; | |
63 #endif | |
64 | |
65 sigset_t _caller_sigmask; // Caller's signal mask | |
66 | |
67 public: | |
68 | |
69 // Methods to save/restore caller's signal mask | |
70 sigset_t caller_sigmask() const { return _caller_sigmask; } | |
71 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } | |
72 | |
73 #ifdef _ALLBSD_SOURCE | |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
74 #ifdef __APPLE__ |
6006
0105f367a14c
7160570: Intrinsification support for tracing framework
rbackman
parents:
4961
diff
changeset
|
75 static size_t thread_id_size() { return sizeof(thread_t); } |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
76 thread_t thread_id() const { |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
77 return _thread_id; |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
78 } |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
79 #else |
6006
0105f367a14c
7160570: Intrinsification support for tracing framework
rbackman
parents:
4961
diff
changeset
|
80 static size_t thread_id_size() { return sizeof(pthread_t); } |
3960 | 81 pthread_t thread_id() const { |
82 return _thread_id; | |
83 } | |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
84 #endif |
3960 | 85 #else |
6006
0105f367a14c
7160570: Intrinsification support for tracing framework
rbackman
parents:
4961
diff
changeset
|
86 static size_t thread_id_size() { return sizeof(pid_t); } |
3960 | 87 pid_t thread_id() const { |
88 return _thread_id; | |
89 } | |
90 #endif | |
91 #ifndef PRODUCT | |
92 // Used for debugging, return a unique integer for each thread. | |
93 intptr_t thread_identifier() const { return (intptr_t)_pthread_id; } | |
94 #endif | |
95 #ifdef ASSERT | |
96 // We expect no reposition failures so kill vm if we get one. | |
97 // | |
98 bool valid_reposition_failure() { | |
99 return false; | |
100 } | |
101 #endif // ASSERT | |
102 #ifdef _ALLBSD_SOURCE | |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
103 #ifdef __APPLE__ |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
104 void set_thread_id(thread_t id) { |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
105 _thread_id = id; |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
106 } |
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
107 #else |
3960 | 108 void set_thread_id(pthread_t id) { |
109 _thread_id = id; | |
110 } | |
4961
0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
sla
parents:
3960
diff
changeset
|
111 #endif |
3960 | 112 #else |
113 void set_thread_id(pid_t id) { | |
114 _thread_id = id; | |
115 } | |
116 #endif | |
117 pthread_t pthread_id() const { | |
118 return _pthread_id; | |
119 } | |
120 void set_pthread_id(pthread_t tid) { | |
121 _pthread_id = tid; | |
122 } | |
123 | |
124 // *************************************************************** | |
125 // suspension support. | |
126 // *************************************************************** | |
127 | |
128 public: | |
129 // flags that support signal based suspend/resume on Bsd are in a | |
130 // separate class to avoid confusion with many flags in OSThread that | |
131 // are used by VM level suspend/resume. | |
132 os::Bsd::SuspendResume sr; | |
133 | |
134 // _ucontext and _siginfo are used by SR_handler() to save thread context, | |
135 // and they will later be used to walk the stack or reposition thread PC. | |
136 // If the thread is not suspended in SR_handler() (e.g. self suspend), | |
137 // the value in _ucontext is meaningless, so we must use the last Java | |
138 // frame information as the frame. This will mean that for threads | |
139 // that are parked on a mutex the profiler (and safepoint mechanism) | |
140 // will see the thread as if it were still in the Java frame. This | |
141 // not a problem for the profiler since the Java frame is a close | |
142 // enough result. For the safepoint mechanism when the give it the | |
143 // Java frame we are not at a point where the safepoint needs the | |
144 // frame to that accurate (like for a compiled safepoint) since we | |
145 // should be in a place where we are native and will block ourselves | |
146 // if we transition. | |
147 private: | |
148 void* _siginfo; | |
149 ucontext_t* _ucontext; | |
150 int _expanding_stack; /* non zero if manually expanding stack */ | |
151 address _alt_sig_stack; /* address of base of alternate signal stack */ | |
152 | |
153 public: | |
154 void* siginfo() const { return _siginfo; } | |
155 void set_siginfo(void* ptr) { _siginfo = ptr; } | |
156 ucontext_t* ucontext() const { return _ucontext; } | |
157 void set_ucontext(ucontext_t* ptr) { _ucontext = ptr; } | |
158 void set_expanding_stack(void) { _expanding_stack = 1; } | |
159 void clear_expanding_stack(void) { _expanding_stack = 0; } | |
160 int expanding_stack(void) { return _expanding_stack; } | |
161 | |
162 void set_alt_sig_stack(address val) { _alt_sig_stack = val; } | |
163 address alt_sig_stack(void) { return _alt_sig_stack; } | |
164 | |
165 private: | |
166 Monitor* _startThread_lock; // sync parent and child in thread creation | |
167 | |
168 public: | |
169 | |
170 Monitor* startThread_lock() const { | |
171 return _startThread_lock; | |
172 } | |
173 | |
174 // *************************************************************** | |
175 // Platform dependent initialization and cleanup | |
176 // *************************************************************** | |
177 | |
178 private: | |
179 | |
180 void pd_initialize(); | |
181 void pd_destroy(); | |
182 | |
183 // Reconciliation History | |
184 // osThread_solaris.hpp 1.24 99/08/27 13:11:54 | |
185 // End | |
186 | |
187 #endif // OS_BSD_VM_OSTHREAD_BSD_HPP |