[igt-dev] [PATCH i-g-t 22/29] lib: Add FreeBSD-specific pthread logic

D Scott Phillips d.scott.phillips at intel.com
Wed Dec 11 00:52:28 UTC 2019


Add a definition for FreeBSD's platform specific method of
fetching a thread-id and delivering a signal to the current
thread.

Signed-off-by: D Scott Phillips <d.scott.phillips at intel.com>
---
 lib/igt_aux.h               | 7 +++++++
 lib/igt_core.c              | 2 ++
 tests/i915/gem_close_race.c | 2 ++
 3 files changed, 11 insertions(+)

diff --git a/lib/igt_aux.h b/lib/igt_aux.h
index 04d22904..5cbef592 100644
--- a/lib/igt_aux.h
+++ b/lib/igt_aux.h
@@ -45,8 +45,15 @@
 # ifndef HAVE_GETTID
 #  define gettid() (pid_t)(syscall(__NR_gettid))
 # endif
+#else
+# ifndef HAVE_GETTID
+#  include <pthread_np.h>
+#  define gettid() (pid_t)(pthread_getthreadid_np())
+# endif
 #endif
+#if defined(__linux__)
 #define sigev_notify_thread_id _sigev_un._tid
+#endif
 
 /* auxialiary igt helpers from igt_aux.c */
 /* generally useful helpers */
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 8df89905..c89030ba 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -2398,6 +2398,8 @@ static void fatal_sig_handler(int sig)
 		pid_t tid = gettid();
 
 		syscall(SYS_tgkill, pid, tid, sig);
+#elif defined(__FreeBSD__)
+		pthread_kill(pthread_self(), sig);
 #else
 		pthread_t tid = pthread_self();
 		union sigval value = { .sival_ptr = NULL };
diff --git a/tests/i915/gem_close_race.c b/tests/i915/gem_close_race.c
index 57e00480..cbef33e2 100644
--- a/tests/i915/gem_close_race.c
+++ b/tests/i915/gem_close_race.c
@@ -51,7 +51,9 @@
 static uint32_t devid;
 static bool has_64bit_relocations;
 
+#if defined(__linux__)
 #define sigev_notify_thread_id _sigev_un._tid
+#endif
 
 static void selfcopy(int fd, uint32_t handle, int loops)
 {
-- 
2.23.0



More information about the igt-dev mailing list