From 27cf09172c4f212d0aef23b23c802bb791ec9209 Mon Sep 17 00:00:00 2001 From: Peter Dillinger Date: Fri, 3 Feb 2023 16:49:54 -0800 Subject: [PATCH] Fix compile gettid on older Linux (#11184) Summary: Seen only in post-PR CI job benchmark-linux. Some context: https://stackoverflow.com/questions/30680550/c-gettid-was-not-declared-in-this-scope Pull Request resolved: https://github.com/facebook/rocksdb/pull/11184 Test Plan: watch CI Reviewed By: cbi42 Differential Revision: D43013891 Pulled By: pdillinger fbshipit-source-id: 48b3b7231080a0f803fdc36d13946d5524770302 --- port/stack_trace.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/port/stack_trace.cc b/port/stack_trace.cc index 5c7e4db49..51d136b04 100644 --- a/port/stack_trace.cc +++ b/port/stack_trace.cc @@ -31,14 +31,18 @@ void* SaveStack(int* /*num_frames*/, int /*first_frames_to_skip*/) { #include #include -#if defined(OS_FREEBSD) +#ifdef OS_FREEBSD #include -#endif +#endif // OS_FREEBSD #ifdef OS_LINUX #include #include #include -#endif +#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 30) +#include +#define gettid() syscall(SYS_gettid) +#endif // GLIBC version +#endif // OS_LINUX #include "port/lang.h"