File tree 4 files changed +36
-6
lines changed
4 files changed +36
-6
lines changed Original file line number Diff line number Diff line change @@ -1220,6 +1220,10 @@ int main() { return tgetnum(""); }
1220
1220
@defines << "HAVE_INOTIFY"
1221
1221
end
1222
1222
1223
+ if has_function ( "gettid" , [ "unistd.d" , "sys/types.h" ] )
1224
+ @defines << "HAVE_GETTID"
1225
+ end
1226
+
1223
1227
# glibc has useless lchmod() so we don't try to use lchmod() on linux
1224
1228
if !@linux and has_function ( "lchmod" , [ "sys/stat.h" , "unistd.h" ] )
1225
1229
@have_lchmod = true
Original file line number Diff line number Diff line change 20
20
#include " metrics.hpp"
21
21
#include " util/logger.hpp"
22
22
23
- #include < sys/syscall.h >
23
+ #include " missing/gettid.h "
24
24
25
25
/* HACK: returns a value that should identify a native thread
26
26
* for debugging threading issues. The winpthreads library
@@ -291,11 +291,7 @@ namespace rubinius {
291
291
292
292
NativeMethod::init_thread (state);
293
293
294
- #ifdef __APPLE__
295
- vm->thread ->pid (state, Fixnum::from (syscall (SYS_thread_selfid)));
296
- #else
297
- vm->thread ->pid (state, Fixnum::from (syscall (SYS_gettid)));
298
- #endif
294
+ vm->thread ->pid (state, Fixnum::from (gettid ()));
299
295
300
296
// Lock the thread object and unlock it at __run__ in the ruby land.
301
297
vm->thread ->alive (state, cTrue);
Original file line number Diff line number Diff line change
1
+ #include " vm/missing/gettid.h"
2
+
3
+ #ifndef HAVE_GETTID
4
+ #include < sys/syscall.h>
5
+
6
+ pid_t gettid (void ) {
7
+ #if defined(__APPLE__)
8
+ return (pid_t )syscall (SYS_thread_selfid);
9
+ #elif defined(__FreeBSD__)
10
+ long tid;
11
+ syscall (SYS_thr_self, &tid);
12
+ return (pid_t )(tid);
13
+ #elif defined(SYS_gettid)
14
+ return (pid_t )syscall (SYS_gettid);
15
+ #else
16
+ return 0 ;
17
+ #endif
18
+ }
19
+ #endif
Original file line number Diff line number Diff line change
1
+ #include "vm/config.h"
2
+
3
+ #include <unistd.h>
4
+
5
+ #ifdef HAVE_GETTID
6
+ #include <sys/types.h>
7
+ #else
8
+ extern "C" {
9
+ pid_t gettid (void );
10
+ }
11
+ #endif
You can’t perform that action at this time.
0 commit comments