plasma-umass / coz

Coz: Causal Profiling
Other
4.08k stars 159 forks source link

Does not compile with glibc < 2.30 #154

Closed llvilanova closed 4 years ago

llvilanova commented 4 years ago

Commit f7b60a68d36f026c4054bdf4c52463b63832fa1b deleted libcoz/ccutil/thread.h, which defined gettid() for glibc versions not defining it. The result is an undeclared gettid() when compiling with glibc pre-2.30.

emeryberger commented 4 years ago

@ccurtsinger is this straightforward to restore?

pmcgleenon commented 4 years ago

As per the comment above gettid() isn't available in glibc versions < 2.3

I worked around that with this change

$  git diff
diff --git a/libcoz/perf.h b/libcoz/perf.h
index 88f26cf..4ad60f8 100644
--- a/libcoz/perf.h
+++ b/libcoz/perf.h
@@ -18,6 +18,11 @@
 #include "ccutil/log.h"
 #include "ccutil/wrapped_array.h"

+#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 30
+#include <sys/syscall.h>
+#define gettid() syscall(SYS_gettid)
+#endif
+
 // Workaround for missing hw_breakpoint.h include file:
 //   This include file just defines constants used to configure watchpoint registers.
 //   This will be constant across x86 systems.