Merge branch 'unstable' of https://github.com/JohnSully/KeyDB into unstable

Former-commit-id: 143f7f634db8adb1f5386d28832a17f7382b750b
This commit is contained in:
John Sully 2020-09-21 04:42:46 +00:00
commit b243fa876f

View File

@ -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;
} }