From: Michael Jeanson Date: Thu, 14 Dec 2023 20:42:15 +0000 (-0500) Subject: logging: Add freebsd support X-Git-Url: https://git.efficios.com/?a=commitdiff_plain;h=27b0e85b66b4814957292ca620793a071b541aa9;p=babeltrace.git logging: Add freebsd support Add the FreeBSD platform specific code to get a thread id for the logging system. Change-Id: Ifd2a53c5c47e1b23a7f0a90c1fc0768e7f4dbcb3 Signed-off-by: Michael Jeanson Reviewed-on: https://review.lttng.org/c/babeltrace/+/11582 Reviewed-by: Philippe Proulx --- diff --git a/src/logging/log-api.c b/src/logging/log-api.c index 55729bd1..ae7c10c5 100644 --- a/src/logging/log-api.c +++ b/src/logging/log-api.c @@ -36,6 +36,10 @@ # include #endif +#ifdef __FreeBSD__ +# include +#endif + #include "common/assert.h" #include "common/common.h" #include "common/macros.h" @@ -192,6 +196,18 @@ void append_pid_tid_to_msg_buf(char ** const at) mach_port_deallocate(mach_task_self(), mach_port); tid = (unsigned int) mach_port; } +#elif defined(__FreeBSD__) + { + long ltid; + + thr_self(<id); + + /* + * The thread ID is an integer in the range from + * `PID_MAX + 2` (100001) to `INT_MAX`. + */ + tid = (unsigned int) ltid; + } #else # error "Platform not supported" #endif