[Mesa-dev] [PATCH 2/5] gallium/util: replace pipe_condvar_destroy() with cnd_destroy()
Timothy Arceri
tarceri at itsqueeze.com
Sat Mar 4 23:41:30 UTC 2017
pipe_condvar_destroy() was made unnecessary with fd33a6bcd7f12.
---
src/gallium/auxiliary/os/os_thread.h | 7 ++-----
src/gallium/auxiliary/util/u_queue.c | 10 +++++-----
src/gallium/auxiliary/util/u_ringbuffer.c | 2 +-
src/gallium/drivers/llvmpipe/lp_fence.c | 2 +-
4 files changed, 9 insertions(+), 12 deletions(-)
diff --git a/src/gallium/auxiliary/os/os_thread.h b/src/gallium/auxiliary/os/os_thread.h
index e1dc210..e230d06 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_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) \
cnd_broadcast(&(cond))
@@ -201,21 +198,21 @@ static inline void pipe_barrier_init(pipe_barrier *barrier, unsigned count)
barrier->waiters = 0;
barrier->sequence = 0;
pipe_mutex_init(barrier->mutex);
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);
+ cnd_destroy(&barrier->condvar);
}
static inline void pipe_barrier_wait(pipe_barrier *barrier)
{
pipe_mutex_lock(barrier->mutex);
assert(barrier->waiters < barrier->count);
barrier->waiters++;
if (barrier->waiters < barrier->count) {
@@ -254,21 +251,21 @@ pipe_semaphore_init(pipe_semaphore *sema, int init_val)
{
pipe_mutex_init(sema->mutex);
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);
+ cnd_destroy(&sema->cond);
}
/** Signal/increment semaphore counter */
static inline void
pipe_semaphore_signal(pipe_semaphore *sema)
{
pipe_mutex_lock(sema->mutex);
sema->counter++;
pipe_condvar_signal(sema->cond);
pipe_mutex_unlock(sema->mutex);
diff --git a/src/gallium/auxiliary/util/u_queue.c b/src/gallium/auxiliary/util/u_queue.c
index dff5b15..87f0120 100644
--- a/src/gallium/auxiliary/util/u_queue.c
+++ b/src/gallium/auxiliary/util/u_queue.c
@@ -115,21 +115,21 @@ util_queue_fence_init(struct util_queue_fence *fence)
memset(fence, 0, sizeof(*fence));
pipe_mutex_init(fence->mutex);
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);
+ cnd_destroy(&fence->cond);
pipe_mutex_destroy(fence->mutex);
}
/****************************************************************************
* util_queue implementation
*/
struct thread_input {
struct util_queue *queue;
int thread_index;
@@ -242,22 +242,22 @@ util_queue_init(struct util_queue *queue,
}
}
add_to_atexit_list(queue);
return true;
fail:
FREE(queue->threads);
if (queue->jobs) {
- pipe_condvar_destroy(queue->has_space_cond);
- pipe_condvar_destroy(queue->has_queued_cond);
+ cnd_destroy(&queue->has_space_cond);
+ cnd_destroy(&queue->has_queued_cond);
pipe_mutex_destroy(queue->lock);
FREE(queue->jobs);
}
/* also util_queue_is_initialized can be used to check for success */
memset(queue, 0, sizeof(*queue));
return false;
}
static void
util_queue_killall_and_wait(struct util_queue *queue)
@@ -274,22 +274,22 @@ util_queue_killall_and_wait(struct util_queue *queue)
pipe_thread_wait(queue->threads[i]);
queue->num_threads = 0;
}
void
util_queue_destroy(struct util_queue *queue)
{
util_queue_killall_and_wait(queue);
remove_from_atexit_list(queue);
- pipe_condvar_destroy(queue->has_space_cond);
- pipe_condvar_destroy(queue->has_queued_cond);
+ cnd_destroy(&queue->has_space_cond);
+ cnd_destroy(&queue->has_queued_cond);
pipe_mutex_destroy(queue->lock);
FREE(queue->jobs);
FREE(queue->threads);
}
void
util_queue_add_job(struct util_queue *queue,
void *job,
struct util_queue_fence *fence,
util_queue_execute_func execute,
diff --git a/src/gallium/auxiliary/util/u_ringbuffer.c b/src/gallium/auxiliary/util/u_ringbuffer.c
index e3be3ef..334be6a 100644
--- a/src/gallium/auxiliary/util/u_ringbuffer.c
+++ b/src/gallium/auxiliary/util/u_ringbuffer.c
@@ -40,21 +40,21 @@ struct util_ringbuffer *util_ringbuffer_create( unsigned dwords )
return ring;
fail:
FREE(ring->buf);
FREE(ring);
return NULL;
}
void util_ringbuffer_destroy( struct util_ringbuffer *ring )
{
- pipe_condvar_destroy(ring->change);
+ cnd_destroy(&ring->change);
pipe_mutex_destroy(ring->mutex);
FREE(ring->buf);
FREE(ring);
}
/**
* Return number of free entries in the ring
*/
static inline unsigned util_ringbuffer_space( const struct util_ringbuffer *ring )
{
diff --git a/src/gallium/drivers/llvmpipe/lp_fence.c b/src/gallium/drivers/llvmpipe/lp_fence.c
index 1529981..3b35eb2 100644
--- a/src/gallium/drivers/llvmpipe/lp_fence.c
+++ b/src/gallium/drivers/llvmpipe/lp_fence.c
@@ -66,21 +66,21 @@ lp_fence_create(unsigned rank)
/** Destroy a fence. Called when refcount hits zero. */
void
lp_fence_destroy(struct lp_fence *fence)
{
if (LP_DEBUG & DEBUG_FENCE)
debug_printf("%s %d\n", __FUNCTION__, fence->id);
pipe_mutex_destroy(fence->mutex);
- pipe_condvar_destroy(fence->signalled);
+ cnd_destroy(&fence->signalled);
FREE(fence);
}
/**
* Called by the rendering threads to increment the fence counter.
* When the counter == the rank, the fence is finished.
*/
void
lp_fence_signal(struct lp_fence *fence)
--
2.9.3
More information about the mesa-dev
mailing list