aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/support/stack_lockfree_test.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-07-16 08:45:15 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-07-16 08:45:15 -0700
commite0981dfa05e49acdd9fc5e8abb83a91d84d1a104 (patch)
tree09086d0cbdb4e130b6c66c837eed27d4f8c30bbc /test/core/support/stack_lockfree_test.c
parentb0c13ad7698e577298f199007cc2d7a0a3049d1c (diff)
parentf101af1ab4c553ff2a8cd8f72e8ca156ef188b86 (diff)
Merge github.com:grpc/grpc into i-want-to-wait-free
Diffstat (limited to 'test/core/support/stack_lockfree_test.c')
-rw-r--r--test/core/support/stack_lockfree_test.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/test/core/support/stack_lockfree_test.c b/test/core/support/stack_lockfree_test.c
index 6141f9811d..02ec3154d5 100644
--- a/test/core/support/stack_lockfree_test.c
+++ b/test/core/support/stack_lockfree_test.c
@@ -59,13 +59,13 @@ static void test_serial_sized(int size) {
GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
/* Now add repeatedly more items and check them */
- for (i=1; i<size; i*=2) {
+ for (i = 1; i < size; i *= 2) {
int j;
- for (j=0; j<=i; j++) {
- GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j==0));
+ for (j = 0; j <= i; j++) {
+ GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j == 0));
}
- for (j=0; j<=i; j++) {
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == i-j);
+ for (j = 0; j <= i; j++) {
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == i - j);
}
GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
}
@@ -75,7 +75,7 @@ static void test_serial_sized(int size) {
static void test_serial() {
int i;
- for (i=128; i<MAX_STACK_SIZE; i*=2) {
+ for (i = 128; i < MAX_STACK_SIZE; i *= 2) {
test_serial_sized(i);
}
test_serial_sized(MAX_STACK_SIZE);
@@ -94,9 +94,9 @@ static void test_mt_body(void *v) {
int lo, hi;
int i;
int res;
- lo = arg->rank*arg->stack_size/arg->nthreads;
- hi = (arg->rank+1)*arg->stack_size/arg->nthreads;
- for (i=lo; i<hi; i++) {
+ lo = arg->rank * arg->stack_size / arg->nthreads;
+ hi = (arg->rank + 1) * arg->stack_size / arg->nthreads;
+ for (i = lo; i < hi; i++) {
gpr_stack_lockfree_push(arg->stack, i);
if ((res = gpr_stack_lockfree_pop(arg->stack)) != -1) {
arg->sum += res;
@@ -116,7 +116,7 @@ static void test_mt_sized(int size, int nth) {
gpr_thd_options options = gpr_thd_options_default();
stack = gpr_stack_lockfree_create(size);
- for (i=0; i<nth; i++) {
+ for (i = 0; i < nth; i++) {
args[i].stack = stack;
args[i].stack_size = size;
args[i].nthreads = nth;
@@ -132,17 +132,17 @@ static void test_mt_sized(int size, int nth) {
gpr_thd_join(thds[i]);
sum = sum + args[i].sum;
}
- GPR_ASSERT((unsigned)sum == ((unsigned)size*(size-1))/2);
+ GPR_ASSERT((unsigned)sum == ((unsigned)size * (size - 1)) / 2);
gpr_stack_lockfree_destroy(stack);
}
static void test_mt() {
int size, nth;
- for (nth=1; nth < MAX_THREADS; nth++) {
- for (size=128; size < MAX_STACK_SIZE; size*=2) {
- test_mt_sized(size,nth);
+ for (nth = 1; nth < MAX_THREADS; nth++) {
+ for (size = 128; size < MAX_STACK_SIZE; size *= 2) {
+ test_mt_sized(size, nth);
}
- test_mt_sized(MAX_STACK_SIZE,nth);
+ test_mt_sized(MAX_STACK_SIZE, nth);
}
}