Fix to support FreeBSD pthread_getthreadid_np call
Former-commit-id: 955faef23a6c080f40896cb9d68391b5586812e9
This commit is contained in:
parent
3b66147997
commit
a830b2fdbf
@ -35,7 +35,11 @@
|
|||||||
#include <sched.h>
|
#include <sched.h>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
#include <pthread_np.h>
|
||||||
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#endif
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <map>
|
#include <map>
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
@ -167,7 +171,12 @@ extern "C" pid_t gettid()
|
|||||||
#else
|
#else
|
||||||
if (pidCache == -1) {
|
if (pidCache == -1) {
|
||||||
uint64_t tidT;
|
uint64_t tidT;
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
// Check https://github.com/ClickHouse/ClickHouse/commit/8d51824ddcb604b6f179a0216f0d32ba5612bd2e
|
||||||
|
tidT = pthread_getthreadid_np();
|
||||||
|
#else
|
||||||
pthread_threadid_np(nullptr, &tidT);
|
pthread_threadid_np(nullptr, &tidT);
|
||||||
|
#endif
|
||||||
serverAssert(tidT < UINT_MAX);
|
serverAssert(tidT < UINT_MAX);
|
||||||
pidCache = (int)tidT;
|
pidCache = (int)tidT;
|
||||||
}
|
}
|
||||||
@ -493,4 +502,4 @@ void fastlock_auto_adjust_waits()
|
|||||||
#else
|
#else
|
||||||
g_fHighCpuPressure = g_fTestMode;
|
g_fHighCpuPressure = g_fTestMode;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user