[llvm] 61f4001 - [llvm-exegesis] Define SYS_gettid if not available

Aiden Grossman via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 18 01:56:53 PDT 2024


Author: Aiden Grossman
Date: 2024-04-18T08:52:21Z
New Revision: 61f400165c64894374d23ffbcbebc8650d974961

URL: https://github.com/llvm/llvm-project/commit/61f400165c64894374d23ffbcbebc8650d974961
DIFF: https://github.com/llvm/llvm-project/commit/61f400165c64894374d23ffbcbebc8650d974961.diff

LOG: [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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp b/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
index 4699fbbea5def0..1d44e09ad61e1d 100644
--- a/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
+++ b/llvm/tools/llvm-exegesis/lib/SubprocessMemory.cpp
@@ -24,6 +24,15 @@ namespace exegesis {
 
 #if defined(__linux__)
 
+// The SYS_* macros for system calls are provided by the libc whereas the
+// __NR_* macros are from the linux headers. This means that sometimes
+// SYS_* macros might not be available for certain system calls depending
+// upon the libc. This happens with the gettid syscall and bionic for
+// example, so we use __NR_gettid when no SYS_gettid is available.
+#ifndef SYS_gettid
+#define SYS_gettid __NR_gettid
+#endif
+
 long SubprocessMemory::getCurrentTID() {
   // We're using the raw syscall here rather than the gettid() function provided
   // by most libcs for compatibility as gettid() was only added to glibc in


        


More information about the llvm-commits mailing list