File tree Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Expand file tree Collapse file tree 3 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -209,7 +209,18 @@ __thread cudaStream_t default_stream = 0;
209
209
__thread bool g_sync_flag = true ;
210
210
bool hl_start_flag = false ;
211
211
212
- #define gettid () syscall(SYS_gettid)
212
+ inline pid_t gettid () {
213
+ #if defined(__APPLE__) || defined(__OSX__)
214
+ pid_t tid = syscall (SYS_thread_selfid);
215
+ #else
216
+ #ifndef __NR_gettid
217
+ #define __NR_gettid 224
218
+ #endif
219
+ pid_t tid = syscall (__NR_gettid);
220
+ #endif
221
+ CHECK_NE (tid, -1 );
222
+ return tid;
223
+ }
213
224
214
225
void hl_init (int device) {
215
226
CHECK (hl_start_flag)
Original file line number Diff line number Diff line change @@ -18,7 +18,18 @@ limitations under the License. */
18
18
19
19
#include < sys/syscall.h>
20
20
#include < unistd.h>
21
- inline pid_t gettid () { return syscall (SYS_gettid); }
21
+ inline pid_t gettid () {
22
+ #if defined(__APPLE__) || defined(__OSX__)
23
+ pid_t tid = syscall (SYS_thread_selfid);
24
+ #else
25
+ #ifndef __NR_gettid
26
+ #define __NR_gettid 224
27
+ #endif
28
+ pid_t tid = syscall (__NR_gettid);
29
+ #endif
30
+ CHECK_NE (tid, -1 );
31
+ return tid;
32
+ }
22
33
23
34
#include " Queue.h"
24
35
#include " ThreadLocal.h"
Original file line number Diff line number Diff line change @@ -156,7 +156,15 @@ class ThreadLocalD {
156
156
static void dataDestructor (void * p) { delete (T*)p; }
157
157
158
158
void updateMap (T* p) {
159
- pid_t tid = syscall (SYS_gettid);
159
+ #if defined(__APPLE__) || defined(__OSX__)
160
+ pid_t tid = syscall (SYS_thread_selfid);
161
+ #else
162
+ #ifndef __NR_gettid
163
+ #define __NR_gettid 224
164
+ #endif
165
+ pid_t tid = syscall (__NR_gettid);
166
+ #endif
167
+ CHECK_NE (tid, -1 );
160
168
std::lock_guard<std::mutex> guard (mutex_);
161
169
auto ret = threadMap_.insert (std::make_pair (tid, p));
162
170
if (!ret.second ) {
You can’t perform that action at this time.
0 commit comments