diff --git a/src/fastlock.cpp b/src/fastlock.cpp index f413ebd0a..4cada72cc 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; } @@ -498,4 +507,4 @@ void fastlock_auto_adjust_waits() #else g_fHighCpuPressure = g_fTestMode; #endif -} \ No newline at end of file +}