vlib: Add FreeBSD thread specific header and calls

Type: improvement
Change-Id: Ia84683936da02968991ea717316a834a5da1a517
Signed-off-by: Tom Jones <thj@freebsd.org>
diff --git a/src/vlib/threads.c b/src/vlib/threads.c
index 3994afc..bbcb4ec 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 @@
   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_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;