From d346b8852aa46085bac0bcd0854f2d3043c88e0f Mon Sep 17 00:00:00 2001 From: Tom Jones Date: Mon, 29 Jan 2024 10:55:09 +0000 Subject: vlib: Add FreeBSD thread specific header and calls Type: improvement Change-Id: Ia84683936da02968991ea717316a834a5da1a517 Signed-off-by: Tom Jones --- src/vlib/threads.c | 11 +++++++++++ 1 file changed, 11 insertions(+) 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 #include +#ifdef __FreeBSD__ +#include +#endif /* __FreeBSD__ */ #include #include #include @@ -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; -- cgit 1.2.3-korg