From 823de49e8336f4a135cd9d52a31b1b1ace407810 Mon Sep 17 00:00:00 2001 From: Dmitry Dorofeev Date: Sat, 1 Aug 2020 21:50:19 +0300 Subject: [PATCH] Fix to support FreeBSD pthread_getthreadid_np call Former-commit-id: 955faef23a6c080f40896cb9d68391b5586812e9 --- src/fastlock.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/fastlock.cpp b/src/fastlock.cpp index 60eb653bf..7aef14d7c 100644 --- a/src/fastlock.cpp +++ b/src/fastlock.cpp @@ -35,7 +35,11 @@ #include #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include #ifdef __linux__ @@ -167,7 +171,12 @@ extern "C" pid_t gettid() #else if (pidCache == -1) { uint64_t tidT; +#ifdef __FreeBSD__ +// Check https://github.com/ClickHouse/ClickHouse/commit/8d51824ddcb604b6f179a0216f0d32ba5612bd2e + tidT = pthread_getthreadid_np(); +#else pthread_threadid_np(nullptr, &tidT); +#endif serverAssert(tidT < UINT_MAX); pidCache = (int)tidT; } @@ -493,4 +502,4 @@ void fastlock_auto_adjust_waits() #else g_fHighCpuPressure = g_fTestMode; #endif -} \ No newline at end of file +}