Skip to content

Commit

Permalink
use gettid on Linux after all, via syscall()
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha committed Nov 14, 2024
1 parent 8245a20 commit e0e33b5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/runtime/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Author: Jared Roesch
#include <limits.h> // NOLINT
#endif

#ifdef __linux
#include <sys/syscall.h>
#endif

#include "runtime/object.h"
#include "runtime/io.h"
#include "runtime/array_ref.h"
Expand Down Expand Up @@ -323,8 +327,9 @@ extern "C" LEAN_EXPORT obj_res lean_io_get_thread_id(obj_arg) {
#elif defined(__APPLE__)
pthread_threadid_np(NULL, &tid);
#else
// should use gettid, but that is glibc 2.30+
tid = static_cast<uint64>(pthread_self());
// since Linux 2.4.11, our glibc 2.27 requires at least 3.2
// glibc 2.30 would provide a wrapper
tid = (pid_t)syscall(SYS_gettid);
#endif
return lean_io_result_mk_ok(box_uint64(tid));
}
Expand Down

0 comments on commit e0e33b5

Please sign in to comment.