File tree Expand file tree Collapse file tree 4 files changed +36
-6
lines changed
Expand file tree Collapse file tree 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(""); }
12201220 @defines << "HAVE_INOTIFY"
12211221 end
12221222
1223+ if has_function ( "gettid" , [ "unistd.d" , "sys/types.h" ] )
1224+ @defines << "HAVE_GETTID"
1225+ end
1226+
12231227 # glibc has useless lchmod() so we don't try to use lchmod() on linux
12241228 if !@linux and has_function ( "lchmod" , [ "sys/stat.h" , "unistd.h" ] )
12251229 @have_lchmod = true
Original file line number Diff line number Diff line change 2020#include " metrics.hpp"
2121#include " util/logger.hpp"
2222
23- #include < sys/syscall.h >
23+ #include " missing/gettid.h "
2424
2525/* HACK: returns a value that should identify a native thread
2626 * for debugging threading issues. The winpthreads library
@@ -291,11 +291,7 @@ namespace rubinius {
291291
292292 NativeMethod::init_thread (state);
293293
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 ()));
299295
300296 // Lock the thread object and unlock it at __run__ in the ruby land.
301297 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