[Mesa-dev] [PATCH 01/11] util: move pipe_thread_is_self from gallium to src/util

Marek Olšák maraeo at gmail.com
Thu Jun 22 01:02:56 UTC 2017


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/auxiliary/os/os_thread.h         | 11 -----------
 src/gallium/state_trackers/nine/nine_state.c |  2 +-
 src/util/u_thread.h                          | 12 ++++++++++++
 3 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index 0a238e5..10d4695 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -35,31 +35,20 @@
 
 #ifndef OS_THREAD_H_
 #define OS_THREAD_H_
 
 
 #include "pipe/p_compiler.h"
 #include "util/u_debug.h" /* for assert */
 #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))
 
 static inline void
 __pipe_mutex_assert_locked(mtx_t *mutex)
 {
 #ifdef DEBUG
    /* NOTE: this would not work for recursive mutexes, but
     * mtx_t doesn't support those
     */
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 3093576..a9a41af 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -286,21 +286,21 @@ nine_context_get_pipe( struct NineDevice9 *device )
 }
 
 struct pipe_context *
 nine_context_get_pipe_multithread( struct NineDevice9 *device )
 {
     struct csmt_context *ctx = device->csmt_ctx;
 
     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;
 }
 
 struct pipe_context *
 nine_context_get_pipe_acquire( struct NineDevice9 *device )
 {
     nine_csmt_pause(device);
     return device->context.pipe;
diff --git a/src/util/u_thread.h b/src/util/u_thread.h
index 8eab3a5..6b5458a 100644
--- a/src/util/u_thread.h
+++ b/src/util/u_thread.h
@@ -21,20 +21,21 @@
  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  * OTHER DEALINGS IN THE SOFTWARE.
  *
  **************************************************************************/
 
 #ifndef U_THREAD_H_
 #define U_THREAD_H_
 
 #include <stdint.h>
+#include <stdbool.h>
 
 #include "c11/threads.h"
 
 #ifdef HAVE_PTHREAD
 #include <signal.h>
 #endif
 
 
 static inline thrd_t u_thread_create(int (*routine)(void *), void *param)
 {
@@ -81,11 +82,22 @@ u_thread_get_time_nano(thrd_t thread)
    clockid_t cid;
 
    pthread_getcpuclockid(thread, &cid);
    clock_gettime(cid, &ts);
    return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
 #else
    return 0;
 #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_ */
-- 
2.7.4



More information about the mesa-dev mailing list