Mercurial > hg > truffle
comparison src/os/bsd/vm/osThread_bsd.hpp @ 4961:0368109684cb
7132070: Use a mach_port_t as the OSThread thread_id rather than pthread_t on BSD/OSX
Summary: Change OSThread to use mach thread_t
Reviewed-by: phh, dcubed
author | sla |
---|---|
date | Sun, 19 Feb 2012 13:11:39 +0100 |
parents | f08d439fab8c |
children | 0105f367a14c |
comparison
equal
deleted
inserted
replaced
4960:86ce3208eb18 | 4961:0368109684cb |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. | 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | 4 * |
5 * This code is free software; you can redistribute it and/or modify it | 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 | 6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
38 } | 38 } |
39 | 39 |
40 private: | 40 private: |
41 | 41 |
42 #ifdef _ALLBSD_SOURCE | 42 #ifdef _ALLBSD_SOURCE |
43 // _thread_id and _pthread_id are the same on BSD | 43 |
44 // keep both to minimize code divergence in os_bsd.cpp | 44 #ifdef __APPLE__ |
45 thread_t _thread_id; | |
46 #else | |
45 pthread_t _thread_id; | 47 pthread_t _thread_id; |
48 #endif | |
49 | |
50 // _pthread_id is the pthread id, which is used by library calls | |
51 // (e.g. pthread_kill). | |
46 pthread_t _pthread_id; | 52 pthread_t _pthread_id; |
53 | |
47 #else | 54 #else |
48 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each | 55 // _thread_id is kernel thread id (similar to LWP id on Solaris). Each |
49 // thread has a unique thread_id (BsdThreads or NPTL). It can be used | 56 // thread has a unique thread_id (BsdThreads or NPTL). It can be used |
50 // to access /proc. | 57 // to access /proc. |
51 pid_t _thread_id; | 58 pid_t _thread_id; |
62 // Methods to save/restore caller's signal mask | 69 // Methods to save/restore caller's signal mask |
63 sigset_t caller_sigmask() const { return _caller_sigmask; } | 70 sigset_t caller_sigmask() const { return _caller_sigmask; } |
64 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } | 71 void set_caller_sigmask(sigset_t sigmask) { _caller_sigmask = sigmask; } |
65 | 72 |
66 #ifdef _ALLBSD_SOURCE | 73 #ifdef _ALLBSD_SOURCE |
74 #ifdef __APPLE__ | |
75 thread_t thread_id() const { | |
76 return _thread_id; | |
77 } | |
78 #else | |
67 pthread_t thread_id() const { | 79 pthread_t thread_id() const { |
68 return _thread_id; | 80 return _thread_id; |
69 } | 81 } |
82 #endif | |
70 #else | 83 #else |
71 pid_t thread_id() const { | 84 pid_t thread_id() const { |
72 return _thread_id; | 85 return _thread_id; |
73 } | 86 } |
74 #endif | 87 #endif |
82 bool valid_reposition_failure() { | 95 bool valid_reposition_failure() { |
83 return false; | 96 return false; |
84 } | 97 } |
85 #endif // ASSERT | 98 #endif // ASSERT |
86 #ifdef _ALLBSD_SOURCE | 99 #ifdef _ALLBSD_SOURCE |
100 #ifdef __APPLE__ | |
101 void set_thread_id(thread_t id) { | |
102 _thread_id = id; | |
103 } | |
104 #else | |
87 void set_thread_id(pthread_t id) { | 105 void set_thread_id(pthread_t id) { |
88 _thread_id = id; | 106 _thread_id = id; |
89 } | 107 } |
108 #endif | |
90 #else | 109 #else |
91 void set_thread_id(pid_t id) { | 110 void set_thread_id(pid_t id) { |
92 _thread_id = id; | 111 _thread_id = id; |
93 } | 112 } |
94 #endif | 113 #endif |