util: move pipe_thread_is_self from gallium to src/util
authorMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 12:11:13 +0000 (14:11 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 26 Jun 2017 00:17:03 +0000 (02:17 +0200)
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/gallium/auxiliary/os/os_thread.h
src/gallium/state_trackers/nine/nine_state.c
src/util/u_thread.h

index 0a238e5749307146719a4de5b8a8adc43b014606..10d4695da683a8e5efad05fda9a91513d90c4126 100644 (file)
 #include "util/u_thread.h"
 
 
-static inline int pipe_thread_is_self( thrd_t thread )
-{
-#if defined(HAVE_PTHREAD)
-#  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
-      (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
-   return pthread_equal(pthread_self(), thread);
-#  endif
-#endif
-   return 0;
-}
-
 #define pipe_mutex_assert_locked(mutex) \
    __pipe_mutex_assert_locked(&(mutex))
 
index 30935760ae4dfd469c435ab4de54f8308db0e974..a9a41af66ec8a35b355e349f4568d1d95ac3d3c2 100644 (file)
@@ -293,7 +293,7 @@ nine_context_get_pipe_multithread( struct NineDevice9 *device )
     if (!device->csmt_active)
         return device->context.pipe;
 
-    if (!pipe_thread_is_self(ctx->worker))
+    if (!u_thread_is_self(ctx->worker))
         nine_csmt_process(device);
 
     return device->context.pipe;
index 8eab3a5b94a194e4816a92139fd01dfcab82bcba..6b5458af86a4085989819635ee15a2c618b852a1 100644 (file)
@@ -28,6 +28,7 @@
 #define U_THREAD_H_
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #include "c11/threads.h"
 
@@ -88,4 +89,15 @@ u_thread_get_time_nano(thrd_t thread)
 #endif
 }
 
+static inline bool u_thread_is_self(thrd_t thread)
+{
+#if defined(HAVE_PTHREAD)
+#  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
+      (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
+   return pthread_equal(pthread_self(), thread);
+#  endif
+#endif
+   return false;
+}
+
 #endif /* U_THREAD_H_ */