logging: Add freebsd support
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 14 Dec 2023 20:42:15 +0000 (15:42 -0500)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Fri, 15 Dec 2023 16:53:26 +0000 (11:53 -0500)
Add the FreeBSD platform specific code to get a thread id for the
logging system.

Change-Id: Ifd2a53c5c47e1b23a7f0a90c1fc0768e7f4dbcb3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/11582
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/logging/log-api.c

index 55729bd17eab9b3595d5ae4d1d13855c5bb9d226..ae7c10c55aa99fbeba95f08d4282160090c6e1f7 100644 (file)
 # include <mach.h>
 #endif
 
+#ifdef __FreeBSD__
+# include <sys/thr.h>
+#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(&ltid);
+
+               /*
+                * 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
This page took 0.027301 seconds and 4 git commands to generate.