summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Jones <thj@freebsd.org>2024-01-29 10:55:09 +0000
committerDamjan Marion <dmarion@0xa5.net>2024-04-24 16:40:24 +0000
commitd346b8852aa46085bac0bcd0854f2d3043c88e0f (patch)
treea3ca931a3a75a2a1951634033e2af9fdfc9bbfd1
parent1817c8e60936fff78615120d3235a6387e0489c0 (diff)
vlib: Add FreeBSD thread specific header and calls
Type: improvement Change-Id: Ia84683936da02968991ea717316a834a5da1a517 Signed-off-by: Tom Jones <thj@freebsd.org>
-rw-r--r--src/vlib/threads.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 3994afc2cea..bbcb4ec2979 100644
--- a/src/vlib/threads.c
+++ b/src/vlib/threads.c
@@ -16,6 +16,9 @@
#include <signal.h>
#include <math.h>
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#endif /* __FreeBSD__ */
#include <vppinfra/format.h>
#include <vppinfra/time_range.h>
#include <vppinfra/interrupt.h>
@@ -272,7 +275,11 @@ vlib_thread_init (vlib_main_t * vm)
w->thread_mheap = clib_mem_get_heap ();
w->thread_stack = vlib_thread_stacks[0];
w->cpu_id = tm->main_lcore;
+#ifdef __FreeBSD__
+ w->lwp = pthread_getthreadid_np ();
+#else
w->lwp = syscall (SYS_gettid);
+#endif /* __FreeBSD__ */
w->thread_id = pthread_self ();
tm->n_vlib_mains = 1;
@@ -448,7 +455,11 @@ vlib_worker_thread_bootstrap_fn (void *arg)
{
vlib_worker_thread_t *w = arg;
+#ifdef __FreeBSD__
+ w->lwp = pthread_getthreadid_np ();
+#else
w->lwp = syscall (SYS_gettid);
+#endif /* __FreeBSD__ */
w->thread_id = pthread_self ();
__os_thread_index = w - vlib_worker_threads;