[Mesa-dev] [PATCH 1/5] gallium/util: replace pipe_condvar_init() with cnd_init()
Timothy Arceri
tarceri at itsqueeze.com
Sat Mar 4 23:41:29 UTC 2017
pipe_condvar_init() was made unnecessary with fd33a6bcd7f12.
---
src/gallium/auxiliary/os/os_thread.h | 7 ++-----
src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 2 +-
src/gallium/auxiliary/util/u_queue.c | 6 +++---
src/gallium/auxiliary/util/u_ringbuffer.c | 2 +-
src/gallium/drivers/llvmpipe/lp_fence.c | 2 +-
src/gallium/drivers/rbug/rbug_context.c | 2 +-
src/gallium/state_trackers/nine/nine_queue.c | 4 ++--
src/gallium/state_trackers/nine/nine_state.c | 2 +-
8 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index 0caf955..e1dc210 100644
--- a/src/gallium/auxiliary/os/os_thread.h
+++ b/src/gallium/auxiliary/os/os_thread.h
@@ -141,23 +141,20 @@ __pipe_mutex_assert_locked(pipe_mutex *mutex)
assert(ret == thrd_busy);
if (ret == thrd_success)
mtx_unlock(mutex);
#endif
}
/* pipe_condvar
*/
typedef cnd_t pipe_condvar;
-#define pipe_condvar_init(cond) \
- cnd_init(&(cond))
-
#define pipe_condvar_destroy(cond) \
cnd_destroy(&(cond))
#define pipe_condvar_wait(cond, mutex) \
cnd_wait(&(cond), &(mutex))
#define pipe_condvar_signal(cond) \
cnd_signal(&(cond))
#define pipe_condvar_broadcast(cond) \
@@ -197,21 +194,21 @@ typedef struct {
pipe_mutex mutex;
pipe_condvar condvar;
} pipe_barrier;
static inline void pipe_barrier_init(pipe_barrier *barrier, unsigned count)
{
barrier->count = count;
barrier->waiters = 0;
barrier->sequence = 0;
pipe_mutex_init(barrier->mutex);
- pipe_condvar_init(barrier->condvar);
+ cnd_init(&barrier->condvar);
}
static inline void pipe_barrier_destroy(pipe_barrier *barrier)
{
assert(barrier->waiters == 0);
pipe_mutex_destroy(barrier->mutex);
pipe_condvar_destroy(barrier->condvar);
}
static inline void pipe_barrier_wait(pipe_barrier *barrier)
@@ -249,21 +246,21 @@ typedef struct
pipe_mutex mutex;
pipe_condvar cond;
int counter;
} pipe_semaphore;
static inline void
pipe_semaphore_init(pipe_semaphore *sema, int init_val)
{
pipe_mutex_init(sema->mutex);
- pipe_condvar_init(sema->cond);
+ cnd_init(&sema->cond);
sema->counter = init_val;
}
static inline void
pipe_semaphore_destroy(pipe_semaphore *sema)
{
pipe_mutex_destroy(sema->mutex);
pipe_condvar_destroy(sema->cond);
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index fdbcf9e..541a6d9 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -343,21 +343,21 @@ pb_slab_create(struct pb_slab_manager *mgr)
buf = slab->buffers;
for (i=0; i < numBuffers; ++i) {
pipe_reference_init(&buf->base.reference, 0);
buf->base.size = mgr->bufSize;
buf->base.alignment = 0;
buf->base.usage = 0;
buf->base.vtbl = &pb_slab_buffer_vtbl;
buf->slab = slab;
buf->start = i* mgr->bufSize;
buf->mapCount = 0;
- pipe_condvar_init(buf->event);
+ cnd_init(&buf->event);
LIST_ADDTAIL(&buf->head, &slab->freeBuffers);
slab->numFree++;
buf++;
}
/* Add this slab to the list of partial slabs */
LIST_ADDTAIL(&slab->head, &mgr->slabs);
return PIPE_OK;
diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index 8dd4cb3..dff5b15 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -107,21 +107,21 @@ util_queue_fence_wait(struct util_queue_fence *fence)
while (!fence->signalled)
pipe_condvar_wait(fence->cond, fence->mutex);
pipe_mutex_unlock(fence->mutex);
}
void
util_queue_fence_init(struct util_queue_fence *fence)
{
memset(fence, 0, sizeof(*fence));
pipe_mutex_init(fence->mutex);
- pipe_condvar_init(fence->cond);
+ cnd_init(&fence->cond);
fence->signalled = true;
}
void
util_queue_fence_destroy(struct util_queue_fence *fence)
{
assert(fence->signalled);
pipe_condvar_destroy(fence->cond);
pipe_mutex_destroy(fence->mutex);
}
@@ -206,22 +206,22 @@ util_queue_init(struct util_queue *queue,
queue->max_jobs = max_jobs;
queue->jobs = (struct util_queue_job*)
CALLOC(max_jobs, sizeof(struct util_queue_job));
if (!queue->jobs)
goto fail;
pipe_mutex_init(queue->lock);
queue->num_queued = 0;
- pipe_condvar_init(queue->has_queued_cond);
- pipe_condvar_init(queue->has_space_cond);
+ cnd_init(&queue->has_queued_cond);
+ cnd_init(&queue->has_space_cond);
queue->threads = (pipe_thread*)CALLOC(num_threads, sizeof(pipe_thread));
if (!queue->threads)
goto fail;
/* start threads */
for (i = 0; i < num_threads; i++) {
struct thread_input *input = MALLOC_STRUCT(thread_input);
input->queue = queue;
input->thread_index = i;
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.c b/src/gallium/auxiliary/util/u_ringbuffer.c
index 19830a9..e3be3ef 100644
--- a/src/gallium/auxiliary/util/u_ringbuffer.c
+++ b/src/gallium/auxiliary/util/u_ringbuffer.c
@@ -28,21 +28,21 @@ struct util_ringbuffer *util_ringbuffer_create( unsigned dwords )
return NULL;
assert(util_is_power_of_two(dwords));
ring->buf = MALLOC( dwords * sizeof(unsigned) );
if (ring->buf == NULL)
goto fail;
ring->mask = dwords - 1;
- pipe_condvar_init(ring->change);
+ cnd_init(&ring->change);
pipe_mutex_init(ring->mutex);
return ring;
fail:
FREE(ring->buf);
FREE(ring);
return NULL;
}
void util_ringbuffer_destroy( struct util_ringbuffer *ring )
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c
index a21a3c7..1529981 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.c
+++ b/src/gallium/drivers/llvmpipe/lp_fence.c
@@ -46,21 +46,21 @@ lp_fence_create(unsigned rank)
{
static int fence_id;
struct lp_fence *fence = CALLOC_STRUCT(lp_fence);
if (!fence)
return NULL;
pipe_reference_init(&fence->reference, 1);
pipe_mutex_init(fence->mutex);
- pipe_condvar_init(fence->signalled);
+ cnd_init(&fence->signalled);
fence->id = fence_id++;
fence->rank = rank;
if (LP_DEBUG & DEBUG_FENCE)
debug_printf("%s %d\n", __FUNCTION__, fence->id);
return fence;
}
diff --git a/src/gallium/drivers/rbug/rbug_context.c b/src/gallium/drivers/rbug/rbug_context.c
index 1dd0f6d..9634f88 100644
--- a/src/gallium/drivers/rbug/rbug_context.c
+++ b/src/gallium/drivers/rbug/rbug_context.c
@@ -1197,21 +1197,21 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
struct rbug_screen *rb_screen = rbug_screen(_screen);
if (!rb_screen)
return NULL;
rb_pipe = CALLOC_STRUCT(rbug_context);
if (!rb_pipe)
return NULL;
pipe_mutex_init(rb_pipe->draw_mutex);
- pipe_condvar_init(rb_pipe->draw_cond);
+ cnd_init(&rb_pipe->draw_cond);
pipe_mutex_init(rb_pipe->call_mutex);
pipe_mutex_init(rb_pipe->list_mutex);
make_empty_list(&rb_pipe->shaders);
rb_pipe->base.screen = _screen;
rb_pipe->base.priv = pipe->priv; /* expose wrapped data */
rb_pipe->base.draw = NULL;
rb_pipe->base.stream_uploader = pipe->stream_uploader;
rb_pipe->base.const_uploader = pipe->const_uploader;
diff --git a/src/gallium/state_trackers/nine/nine_queue.c b/src/gallium/state_trackers/nine/nine_queue.c
index 9f0bf8b..004d581 100644
--- a/src/gallium/state_trackers/nine/nine_queue.c
+++ b/src/gallium/state_trackers/nine/nine_queue.c
@@ -233,24 +233,24 @@ nine_queue_create(void)
ctx = CALLOC_STRUCT(nine_queue_pool);
if (!ctx)
goto failed;
for (i = 0; i < NINE_CMD_BUFS; i++) {
ctx->pool[i].mem_pool = MALLOC(NINE_QUEUE_SIZE);
if (!ctx->pool[i].mem_pool)
goto failed;
}
- pipe_condvar_init(ctx->event_pop);
+ cnd_init(&ctx->event_pop);
pipe_mutex_init(ctx->mutex_pop);
- pipe_condvar_init(ctx->event_push);
+ cnd_init(&ctx->event_push);
pipe_mutex_init(ctx->mutex_push);
/* Block until first cmdbuf has been flushed. */
ctx->worker_wait = TRUE;
return ctx;
failed:
if (ctx) {
for (i = 0; i < NINE_CMD_BUFS; i++) {
if (ctx->pool[i].mem_pool)
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index bdb0ba1..e1a2ff0 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -144,21 +144,21 @@ nine_csmt_create( struct NineDevice9 *This )
ctx = CALLOC_STRUCT(csmt_context);
if (!ctx)
return NULL;
ctx->pool = nine_queue_create();
if (!ctx->pool) {
FREE(ctx);
return NULL;
}
- pipe_condvar_init(ctx->event_processed);
+ cnd_init(&ctx->event_processed);
pipe_mutex_init(ctx->mutex_processed);
pipe_mutex_init(ctx->thread_running);
pipe_mutex_init(ctx->thread_resume);
#if DEBUG
pipe_thread_setname("Main thread");
#endif
ctx->device = This;
--
2.9.3
More information about the mesa-dev
mailing list