Fix to support FreeBSD pthread_getthreadid_np call

Former-commit-id: 955faef23a6c080f40896cb9d68391b5586812e9
This commit is contained in:
Dmitry Dorofeev 2020-08-01 21:50:19 +03:00 committed by John Sully
parent 3b66147997
commit a830b2fdbf

View File

@ -35,7 +35,11 @@
#include <sched.h>
#include <atomic>
#include <assert.h>
#ifdef __FreeBSD__
#include <pthread_np.h>
#else
#include <pthread.h>
#endif
#include <limits.h>
#include <map>
#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;
}