[Mesa-dev] [PATCH 1/4] gallium/util: remove PIPE_THREAD_ROUTINE()

Timothy Arceri tarceri at itsqueeze.com
Mon Mar 6 00:58:26 UTC 2017


This was made unnecessary with fd33a6bcd7f12.

This was mostly done with:
find ./src -type f -exec sed -i -- \
's:PIPE_THREAD_ROUTINE(\([^,]*\), \([^)]*\)):int\n\1(void \*\2):g' {} \;

With some small manual tidy ups.
---
 src/gallium/auxiliary/os/os_thread.h         | 5 +----
 src/gallium/auxiliary/util/u_queue.c         | 3 ++-
 src/gallium/drivers/ddebug/dd_draw.c         | 3 ++-
 src/gallium/drivers/ddebug/dd_pipe.h         | 3 ++-
 src/gallium/drivers/llvmpipe/lp_rast.c       | 3 ++-
 src/gallium/drivers/radeon/r600_gpu_load.c   | 3 ++-
 src/gallium/drivers/rbug/rbug_core.c         | 6 ++++--
 src/gallium/state_trackers/nine/nine_state.c | 3 ++-
 src/gallium/tests/unit/pipe_barrier_test.c   | 3 ++-
 9 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index b15dd05..bb767fa 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -40,24 +40,21 @@
 #include "pipe/p_compiler.h"
 #include "util/u_debug.h" /* for assert */
 
 #include "c11/threads.h"
 
 #ifdef HAVE_PTHREAD
 #include <signal.h>
 #endif
 
 
-#define PIPE_THREAD_ROUTINE( name, param ) \
-   int name( void *param )
-
-static inline thrd_t pipe_thread_create( PIPE_THREAD_ROUTINE((*routine), ), void *param )
+static inline thrd_t pipe_thread_create(int (*routine)(void *), void *param)
 {
    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);
diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index b20abc8f..a3aed29 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -128,21 +128,22 @@ util_queue_fence_destroy(struct util_queue_fence *fence)
 
 /****************************************************************************
  * util_queue implementation
  */
 
 struct thread_input {
    struct util_queue *queue;
    int thread_index;
 };
 
-static PIPE_THREAD_ROUTINE(util_queue_thread_func, input)
+static int
+util_queue_thread_func(void *input)
 {
    struct util_queue *queue = ((struct thread_input*)input)->queue;
    int thread_index = ((struct thread_input*)input)->thread_index;
 
    FREE(input);
 
    if (queue->name) {
       char name[16];
       util_snprintf(name, sizeof(name), "%s:%i", queue->name, thread_index);
       pipe_thread_setname(name);
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index 59afde8..e01d2ae 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -892,21 +892,22 @@ dd_dump_record(struct dd_context *dctx, struct dd_draw_record *record,
 
    dd_dump_call(f, &record->draw_state.base, &record->call);
    fprintf(f, "%s\n", record->driver_state_log);
 
    dctx->pipe->dump_debug_state(dctx->pipe, f,
                                 PIPE_DUMP_DEVICE_STATUS_REGISTERS);
    dd_dump_dmesg(f);
    fclose(f);
 }
 
-PIPE_THREAD_ROUTINE(dd_thread_pipelined_hang_detect, input)
+int
+dd_thread_pipelined_hang_detect(void *input)
 {
    struct dd_context *dctx = (struct dd_context *)input;
    struct dd_screen *dscreen = dd_screen(dctx->base.screen);
 
    mtx_lock(&dctx->mutex);
 
    while (!dctx->kill_thread) {
       struct dd_draw_record **record = &dctx->records;
 
       /* Loop over all records. */
diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h
index 64d5510..deb1ab7 100644
--- a/src/gallium/drivers/ddebug/dd_pipe.h
+++ b/src/gallium/drivers/ddebug/dd_pipe.h
@@ -244,21 +244,22 @@ struct dd_context
    struct dd_draw_record *records;
    int max_log_buffer_size;
 };
 
 
 struct pipe_context *
 dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe);
 
 void
 dd_init_draw_functions(struct dd_context *dctx);
-PIPE_THREAD_ROUTINE(dd_thread_pipelined_hang_detect, input);
+int
+dd_thread_pipelined_hang_detect(void *input);
 
 
 static inline struct dd_context *
 dd_context(struct pipe_context *pipe)
 {
    return (struct dd_context *)pipe;
 }
 
 static inline struct dd_screen *
 dd_screen(struct pipe_screen *screen)
diff --git a/src/gallium/drivers/llvmpipe/lp_rast.c b/src/gallium/drivers/llvmpipe/lp_rast.c
index 9e56c96..2f222d0 100644
--- a/src/gallium/drivers/llvmpipe/lp_rast.c
+++ b/src/gallium/drivers/llvmpipe/lp_rast.c
@@ -774,21 +774,22 @@ lp_rast_finish( struct lp_rasterizer *rast )
 }
 
 
 /**
  * This is the thread's main entrypoint.
  * It's a simple loop:
  *   1. wait for work
  *   2. do work
  *   3. signal that we're done
  */
-static PIPE_THREAD_ROUTINE( thread_function, init_data )
+static int
+thread_function(void *init_data)
 {
    struct lp_rasterizer_task *task = (struct lp_rasterizer_task *) init_data;
    struct lp_rasterizer *rast = task->rast;
    boolean debug = false;
    char thread_name[16];
    unsigned fpstate;
 
    util_snprintf(thread_name, sizeof thread_name, "llvmpipe-%u", task->thread_index);
    pipe_thread_setname(thread_name);
 
diff --git a/src/gallium/drivers/radeon/r600_gpu_load.c b/src/gallium/drivers/radeon/r600_gpu_load.c
index e4411ad..67a2f35 100644
--- a/src/gallium/drivers/radeon/r600_gpu_load.c
+++ b/src/gallium/drivers/radeon/r600_gpu_load.c
@@ -125,21 +125,22 @@ static void r600_update_mmio_counters(struct r600_common_screen *rscreen,
 		UPDATE_COUNTER(scratch_ram, SCRATCH_RAM_BUSY);
 		UPDATE_COUNTER(ce, CE_BUSY);
 	}
 
 	value = gui_busy || sdma_busy;
 	UPDATE_COUNTER(gpu, IDENTITY);
 }
 
 #undef UPDATE_COUNTER
 
-static PIPE_THREAD_ROUTINE(r600_gpu_load_thread, param)
+static int
+r600_gpu_load_thread(void *param)
 {
 	struct r600_common_screen *rscreen = (struct r600_common_screen*)param;
 	const int period_us = 1000000 / SAMPLES_PER_SEC;
 	int sleep_us = period_us;
 	int64_t cur_time, last_time = os_time_get();
 
 	while (!p_atomic_read(&rscreen->gpu_load_stop_thread)) {
 		if (sleep_us)
 			os_time_sleep(sleep_us);
 
diff --git a/src/gallium/drivers/rbug/rbug_core.c b/src/gallium/drivers/rbug/rbug_core.c
index a5d3ee4..5752e5e 100644
--- a/src/gallium/drivers/rbug/rbug_core.c
+++ b/src/gallium/drivers/rbug/rbug_core.c
@@ -51,21 +51,22 @@
    (type*)((char*)ptr - offsetof(type, field))
 
 struct rbug_rbug
 {
    struct rbug_screen *rb_screen;
    struct rbug_connection *con;
    thrd_t thread;
    boolean running;
 };
 
-PIPE_THREAD_ROUTINE(rbug_thread, void_rbug);
+int
+rbug_thread(void *void_rbug);
 
 
 /**********************************************************
  * Helper functions
  */
 
 
 static struct rbug_context *
 rbug_get_context_locked(struct rbug_screen *rb_screen, rbug_context_t ctx)
 {
@@ -792,21 +793,22 @@ rbug_con(struct rbug_rbug *tr_rbug)
       if (!rbug_header(tr_rbug, header, serial))
          break;
    }
 
    debug_printf("%s - connection closed\n", __FUNCTION__);
 
    rbug_disconnect(tr_rbug->con);
    tr_rbug->con = NULL;
 }
 
-PIPE_THREAD_ROUTINE(rbug_thread, void_tr_rbug)
+int
+rbug_thread(void *void_tr_rbug)
 {
    struct rbug_rbug *tr_rbug = void_tr_rbug;
    uint16_t port = 13370;
    int s = -1;
    int c;
 
    u_socket_init();
 
    for (;port <= 13379 && s < 0; port++)
       s = u_socket_listen_on_port(port);
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index e6d215a..5ec3d34 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -81,21 +81,22 @@ nine_csmt_wait_processed(struct csmt_context *ctx)
 {
     mtx_lock(&ctx->mutex_processed);
     while (!p_atomic_read(&ctx->processed)) {
         cnd_wait(&ctx->event_processed, &ctx->mutex_processed);
     }
     mtx_unlock(&ctx->mutex_processed);
 }
 
 /* CSMT worker thread */
 static
-PIPE_THREAD_ROUTINE(nine_csmt_worker, arg)
+int
+nine_csmt_worker(void *arg)
 {
     struct csmt_context *ctx = arg;
     struct csmt_instruction *instr;
     DBG("CSMT worker spawned\n");
 
     pipe_thread_setname("CSMT-Worker");
 
     while (1) {
         nine_queue_wait_flush(ctx->pool);
         mtx_lock(&ctx->thread_running);
diff --git a/src/gallium/tests/unit/pipe_barrier_test.c b/src/gallium/tests/unit/pipe_barrier_test.c
index d5d7fb7..34a77b8 100644
--- a/src/gallium/tests/unit/pipe_barrier_test.c
+++ b/src/gallium/tests/unit/pipe_barrier_test.c
@@ -59,21 +59,22 @@ static volatile int proceeded = 0;
       fprintf(stdout, fmt, ##__VA_ARGS__); \
    }
 
 #define CHECK(_cond) \
    if (!(_cond)) { \
       fprintf(stderr, "%s:%u: `%s` failed\n", __FILE__, __LINE__, #_cond); \
       _exit(EXIT_FAILURE); \
    }
 
 
-static PIPE_THREAD_ROUTINE(thread_function, thread_data)
+static int
+thread_function(void *thread_data)
 {
    int thread_id = *((int *) thread_data);
 
    LOG("thread %d starting\n", thread_id);
    os_time_sleep(thread_id * 100 * 1000);
    LOG("thread %d before barrier\n", thread_id);
 
    CHECK(p_atomic_read(&proceeded) == 0);
    p_atomic_inc(&waiting);
 
-- 
2.9.3



More information about the mesa-dev mailing list