Skip to content

Commit 61f4001

Browse files
[llvm-exegesis] Define SYS_gettid if not available
This patch defines SYS_gettid as __NR_gettid if SYS_gettid is not available to avoid compile time errors due to SYS_gettid not being defined. This happens with certain libcs (like bionic) that do not define SYS_gettid.
1 parent fd98f80 commit 61f4001

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ namespace exegesis {
2424

2525
#if defined(__linux__)
2626

27+
// The SYS_* macros for system calls are provided by the libc whereas the
28+
// __NR_* macros are from the linux headers. This means that sometimes
29+
// SYS_* macros might not be available for certain system calls depending
30+
// upon the libc. This happens with the gettid syscall and bionic for
31+
// example, so we use __NR_gettid when no SYS_gettid is available.
32+
#ifndef SYS_gettid
33+
#define SYS_gettid __NR_gettid
34+
#endif
35+
2736
long SubprocessMemory::getCurrentTID() {
2837
// We're using the raw syscall here rather than the gettid() function provided
2938
// by most libcs for compatibility as gettid() was only added to glibc in

0 commit comments

Comments
 (0)