mirror of
https://github.com/gabime/spdlog.git
synced 2024-11-15 16:35:45 +08:00
Use gettid() syscall under linux to get thread id
This commit is contained in:
parent
a09107927b
commit
4292d3d9af
@ -32,8 +32,11 @@
|
|||||||
# define WIN32_LEAN_AND_MEAN
|
# define WIN32_LEAN_AND_MEAN
|
||||||
# endif
|
# endif
|
||||||
# include <Windows.h>
|
# include <Windows.h>
|
||||||
|
#elif __linux__
|
||||||
|
#include <sys/syscall.h> //Use gettid() syscall under linux to get thread id
|
||||||
|
#include <unistd.h>
|
||||||
#else
|
#else
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../common.h"
|
#include "../common.h"
|
||||||
@ -168,13 +171,15 @@ inline int utc_minutes_offset(const std::tm& tm = details::os::localtime())
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Return current thread id as 64 bit integer
|
||||||
inline uint64_t thread_id()
|
inline uint64_t thread_id()
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
return ::GetCurrentThreadId();
|
return ::GetCurrentThreadId();
|
||||||
#else
|
#elif __linux__
|
||||||
|
return (uint64_t) syscall(SYS_gettid);
|
||||||
|
#else
|
||||||
return (uint64_t) pthread_self();
|
return (uint64_t) pthread_self();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user