[Mesa-dev] [PATCH 7/7] gallium/util: replace pipe_thread with thrd_t

Timothy Arceri tarceri at itsqueeze.com
Sun Mar 5 01:32:07 UTC 2017


pipe_thread was made unnecessary with fd33a6bcd7f12.
---
 src/gallium/auxiliary/os/os_thread.h          | 16 ++++++----------
 src/gallium/auxiliary/util/u_queue.h          |  2 +-
 src/gallium/drivers/ddebug/dd_pipe.h          |  2 +-
 src/gallium/drivers/llvmpipe/lp_rast_priv.h   |  2 +-
 src/gallium/drivers/radeon/r600_pipe_common.h |  2 +-
 src/gallium/drivers/rbug/rbug_core.c          |  2 +-
 src/gallium/state_trackers/nine/nine_state.c  |  4 ++--
 src/gallium/tests/unit/pipe_barrier_test.c    |  2 +-
 8 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index a429f4e..ad2cda4 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -40,71 +40,67 @@
 #include "pipe/p_compiler.h"
 #include "util/u_debug.h" /* for assert */
 
 #include "c11/threads.h"
 
 #ifdef HAVE_PTHREAD
 #include <signal.h>
 #endif
 
 
-/* pipe_thread
- */
-typedef thrd_t pipe_thread;
-
 #define PIPE_THREAD_ROUTINE( name, param ) \
    int name( void *param )
 
-static inline pipe_thread pipe_thread_create( PIPE_THREAD_ROUTINE((*routine), ), void *param )
+static inline thrd_t pipe_thread_create( PIPE_THREAD_ROUTINE((*routine), ), void *param )
 {
-   pipe_thread thread;
+   thrd_t thread;
 #ifdef HAVE_PTHREAD
    sigset_t saved_set, new_set;
    int ret;
 
    sigfillset(&new_set);
    pthread_sigmask(SIG_SETMASK, &new_set, &saved_set);
    ret = thrd_create( &thread, routine, param );
    pthread_sigmask(SIG_SETMASK, &saved_set, NULL);
 #else
    int ret;
    ret = thrd_create( &thread, routine, param );
 #endif
    if (ret)
       return 0;
 
    return thread;
 }
 
-static inline int pipe_thread_wait( pipe_thread thread )
+static inline int pipe_thread_wait( thrd_t thread )
 {
    return thrd_join( thread, NULL );
 }
 
-static inline int pipe_thread_destroy( pipe_thread thread )
+static inline int pipe_thread_destroy( thrd_t thread )
 {
    return thrd_detach( thread );
 }
 
 static inline void pipe_thread_setname( const char *name )
 {
 #if defined(HAVE_PTHREAD)
 #  if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__) && \
       (__GLIBC__ >= 3 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 12))
    pthread_setname_np(pthread_self(), name);
 #  endif
 #endif
    (void)name;
 }
 
 
-static inline int pipe_thread_is_self( pipe_thread thread )
+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;
 }
 
@@ -300,21 +296,21 @@ pipe_tsd_set(pipe_tsd *tsd, void *value)
 }
 
 
 
 /*
  * Thread statistics.
  */
 
 /* Return the time of a thread's CPU time clock. */
 static inline int64_t
-pipe_thread_get_time_nano(pipe_thread thread)
+pipe_thread_get_time_nano(thrd_t thread)
 {
 #if defined(PIPE_OS_LINUX) && defined(HAVE_PTHREAD)
    struct timespec ts;
    clockid_t cid;
 
    pthread_getcpuclockid(thread, &cid);
    clock_gettime(cid, &ts);
    return (int64_t)ts.tv_sec * 1000000000 + ts.tv_nsec;
 #else
    return 0;
diff --git a/src/gallium/auxiliary/util/u_queue.h b/src/gallium/auxiliary/util/u_queue.h
index 8d4804f..635545f 100644
--- a/src/gallium/auxiliary/util/u_queue.h
+++ b/src/gallium/auxiliary/util/u_queue.h
@@ -53,21 +53,21 @@ struct util_queue_job {
    util_queue_execute_func execute;
    util_queue_execute_func cleanup;
 };
 
 /* Put this into your context. */
 struct util_queue {
    const char *name;
    mtx_t lock;
    pipe_condvar has_queued_cond;
    pipe_condvar has_space_cond;
-   pipe_thread *threads;
+   thrd_t *threads;
    int num_queued;
    unsigned num_threads;
    int kill_threads;
    int max_jobs;
    int write_idx, read_idx; /* ring buffer pointers */
    struct util_queue_job *jobs;
 
    /* for cleanup at exit(), protected by exit_mutex */
    struct list_head head;
 };
diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h
index dc7c325..64d5510 100644
--- a/src/gallium/drivers/ddebug/dd_pipe.h
+++ b/src/gallium/drivers/ddebug/dd_pipe.h
@@ -227,21 +227,21 @@ struct dd_context
     * After each draw call, a new dd_draw_record is created that contains
     * a copy of all states, the output of pipe_context::dump_debug_state,
     * and it has a fence number assigned. That's done without knowing whether
     * that draw call is problematic or not. The record is added into the list
     * of all records.
     *
     * An independent, separate thread loops over the list of records and checks
     * their fences. Records with signalled fences are freed. On fence timeout,
     * the thread dumps the record of the oldest unsignalled fence.
     */
-   pipe_thread thread;
+   thrd_t thread;
    mtx_t mutex;
    int kill_thread;
    struct pipe_resource *fence;
    struct pipe_transfer *fence_transfer;
    uint32_t *mapped_fence;
    uint32_t sequence_no;
    struct dd_draw_record *records;
    int max_log_buffer_size;
 };
 
diff --git a/src/gallium/drivers/llvmpipe/lp_rast_priv.h b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
index 9aa7e87..3cc52b8 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast_priv.h
+++ b/src/gallium/drivers/llvmpipe/lp_rast_priv.h
@@ -120,21 +120,21 @@ struct lp_rasterizer
    /** The incoming queue of scenes ready to rasterize */
    struct lp_scene_queue *full_scenes;
 
    /** The scene currently being rasterized by the threads */
    struct lp_scene *curr_scene;
 
    /** A task object for each rasterization thread */
    struct lp_rasterizer_task tasks[LP_MAX_THREADS];
 
    unsigned num_threads;
-   pipe_thread threads[LP_MAX_THREADS];
+   thrd_t threads[LP_MAX_THREADS];
 
    /** For synchronizing the rasterization threads */
    pipe_barrier barrier;
 };
 
 
 void
 lp_rast_shade_quads_mask(struct lp_rasterizer_task *task,
                          const struct lp_rast_shader_inputs *inputs,
                          unsigned x, unsigned y,
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h
index 726dbb3..3516884 100644
--- a/src/gallium/drivers/radeon/r600_pipe_common.h
+++ b/src/gallium/drivers/radeon/r600_pipe_common.h
@@ -388,21 +388,21 @@ struct r600_common_screen {
 	 */
 	unsigned			num_compilations;
 	/* Along with ST_DEBUG=precompile, this should show if applications
 	 * are loading shaders on demand. This is a monotonic counter.
 	 */
 	unsigned			num_shaders_created;
 	unsigned			num_shader_cache_hits;
 
 	/* GPU load thread. */
 	mtx_t				gpu_load_mutex;
-	pipe_thread			gpu_load_thread;
+	thrd_t				gpu_load_thread;
 	union r600_mmio_counters	mmio_counters;
 	volatile unsigned		gpu_load_stop_thread; /* bool */
 
 	char				renderer_string[100];
 
 	/* Performance counters. */
 	struct r600_perfcounters	*perfcounters;
 
 	/* If pipe_screen wants to recompute and re-emit the framebuffer,
 	 * sampler, and image states of all contexts, it should atomically
diff --git a/src/gallium/drivers/rbug/rbug_core.c b/src/gallium/drivers/rbug/rbug_core.c
index b3082da..a5d3ee4 100644
--- a/src/gallium/drivers/rbug/rbug_core.c
+++ b/src/gallium/drivers/rbug/rbug_core.c
@@ -47,21 +47,21 @@
 #define U642VOID(x) ((void *)(unsigned long)(x))
 #define VOID2U64(x) ((uint64_t)(unsigned long)(x))
 
 #define container_of(ptr, type, field) \
    (type*)((char*)ptr - offsetof(type, field))
 
 struct rbug_rbug
 {
    struct rbug_screen *rb_screen;
    struct rbug_connection *con;
-   pipe_thread thread;
+   thrd_t thread;
    boolean running;
 };
 
 PIPE_THREAD_ROUTINE(rbug_thread, void_rbug);
 
 
 /**********************************************************
  * Helper functions
  */
 
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index c3483e4..bfceeee 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -53,21 +53,21 @@
 
 #define DBG_CHANNEL DBG_DEVICE
 
 /* Nine CSMT */
 
 struct csmt_instruction {
     int (* func)(struct NineDevice9 *This, struct csmt_instruction *instr);
 };
 
 struct csmt_context {
-    pipe_thread worker;
+    thrd_t worker;
     struct nine_queue_pool* pool;
     BOOL terminate;
     pipe_condvar event_processed;
     mtx_t mutex_processed;
     struct NineDevice9 *device;
     BOOL processed;
     BOOL toPause;
     BOOL hasPaused;
     mtx_t thread_running;
     mtx_t thread_resume;
@@ -210,21 +210,21 @@ nine_csmt_process( struct NineDevice9 *device )
     nine_csmt_wait_processed(ctx);
 }
 
 /* Destroys a CSMT context.
  * Waits for the worker thread to terminate.
  */
 void
 nine_csmt_destroy( struct NineDevice9 *device, struct csmt_context *ctx )
 {
     struct csmt_instruction* instr;
-    pipe_thread render_thread = ctx->worker;
+    thrd_t render_thread = ctx->worker;
 
     DBG("device=%p ctx=%p\n", device, ctx);
 
     /* Push nop and flush the queue. */
     instr = nine_queue_alloc(ctx->pool, sizeof(struct csmt_instruction));
     assert(instr);
     instr->func = nop_func;
 
     p_atomic_set(&ctx->processed, FALSE);
     /* Signal worker to terminate. */
diff --git a/src/gallium/tests/unit/pipe_barrier_test.c b/src/gallium/tests/unit/pipe_barrier_test.c
index bb7989a..d5d7fb7 100644
--- a/src/gallium/tests/unit/pipe_barrier_test.c
+++ b/src/gallium/tests/unit/pipe_barrier_test.c
@@ -39,21 +39,21 @@
 
 #include "os/os_thread.h"
 #include "os/os_time.h"
 #include "util/u_atomic.h"
 
 
 #define NUM_THREADS 10
 
 static int verbosity = 0;
 
-static pipe_thread threads[NUM_THREADS];
+static thrd_t threads[NUM_THREADS];
 static pipe_barrier barrier;
 static int thread_ids[NUM_THREADS];
 
 static volatile int waiting = 0;
 static volatile int proceeded = 0;
 
 
 #define LOG(fmt, ...) \
    if (verbosity > 0) { \
       fprintf(stdout, fmt, ##__VA_ARGS__); \
-- 
2.9.3



More information about the mesa-dev mailing list