diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2013-05-13 13:29:47 +0200 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2013-07-04 17:42:49 +0200 |
commit | 5444e768ee1abe6e021bece19a9a932351f88c88 (patch) | |
tree | 944d3e69c83659ecd706ca2d24023d9c9c2a82c7 /tests/test-thread-pool.c | |
parent | 22fc860b0a0b689eacf4a01f5aa2ccbf36043a12 (diff) |
add a header file for atomic operations
We're already using them in several places, but __sync builtins are just
too ugly to type, and do not provide seqcst load/store operations.
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tests/test-thread-pool.c')
-rw-r--r-- | tests/test-thread-pool.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test-thread-pool.c b/tests/test-thread-pool.c index 22915aac10..b62338f375 100644 --- a/tests/test-thread-pool.c +++ b/tests/test-thread-pool.c @@ -17,15 +17,15 @@ typedef struct { static int worker_cb(void *opaque) { WorkerTestData *data = opaque; - return __sync_fetch_and_add(&data->n, 1); + return atomic_fetch_inc(&data->n); } static int long_cb(void *opaque) { WorkerTestData *data = opaque; - __sync_fetch_and_add(&data->n, 1); + atomic_inc(&data->n); g_usleep(2000000); - __sync_fetch_and_add(&data->n, 1); + atomic_inc(&data->n); return 0; } @@ -169,7 +169,7 @@ static void test_cancel(void) /* Cancel the jobs that haven't been started yet. */ num_canceled = 0; for (i = 0; i < 100; i++) { - if (__sync_val_compare_and_swap(&data[i].n, 0, 3) == 0) { + if (atomic_cmpxchg(&data[i].n, 0, 3) == 0) { data[i].ret = -ECANCELED; bdrv_aio_cancel(data[i].aiocb); active--; |