From 2f520337c2ee6d8f6dca5c3069e1c60d081699fc Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Thu, 25 Jun 2020 12:30:27 -0400 Subject: [PATCH] Port: Add logging thread id support on GNU Hurd MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau Change-Id: I8db78267136ba172964f3c8c1f40115e28ac6446 --- src/logging/log.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/logging/log.c b/src/logging/log.c index 6f8de7b4..49f69958 100644 --- a/src/logging/log.c +++ b/src/logging/log.c @@ -330,6 +330,9 @@ extern unsigned long pthread_getsequence_np(pthread_t *); #if defined(__MACH__) #include #endif +#if defined(__GNU__) + #include +#endif #define INLINE _BT_LOG_INLINE #define VAR_UNUSED(var) (void)var @@ -843,8 +846,12 @@ static void pid_callback(int *const pid, int *const tid) *tid = gettid(); #elif defined(__linux__) *tid = syscall(SYS_gettid); - #elif defined(__MACH__) + #elif defined(__APPLE__) && defined(__MACH__) *tid = (int)pthread_mach_thread_np(pthread_self()); + #elif defined(__GNU__) + mach_port_t mach_port = mach_thread_self(); + mach_port_deallocate(mach_task_self(), mach_port); + *tid = (int)mach_port; #else #define Platform not supported #endif -- 2.34.1