aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/core/support/spinlock_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/core/support/spinlock_test.c')
-rw-r--r--test/core/support/spinlock_test.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/test/core/support/spinlock_test.c b/test/core/support/spinlock_test.c
index b236a88ab7..185538ee93 100644
--- a/test/core/support/spinlock_test.c
+++ b/test/core/support/spinlock_test.c
@@ -32,7 +32,7 @@
/* Tests for gpr_spinlock. */
struct test {
int thread_count; /* number of threads */
- gpr_thd_id *threads;
+ gpr_thd_id* threads;
int64_t iterations; /* number of iterations per thread */
int64_t counter;
@@ -42,8 +42,8 @@ struct test {
};
/* Return pointer to a new struct test. */
-static struct test *test_new(int threads, int64_t iterations, int incr_step) {
- struct test *m = gpr_malloc(sizeof(*m));
+static struct test* test_new(int threads, int64_t iterations, int incr_step) {
+ struct test* m = gpr_malloc(sizeof(*m));
m->thread_count = threads;
m->threads = gpr_malloc(sizeof(*m->threads) * (size_t)threads);
m->iterations = iterations;
@@ -55,13 +55,13 @@ static struct test *test_new(int threads, int64_t iterations, int incr_step) {
}
/* Return pointer to a new struct test. */
-static void test_destroy(struct test *m) {
+static void test_destroy(struct test* m) {
gpr_free(m->threads);
gpr_free(m);
}
/* Create m->threads threads, each running (*body)(m) */
-static void test_create_threads(struct test *m, void (*body)(void *arg)) {
+static void test_create_threads(struct test* m, void (*body)(void* arg)) {
int i;
for (i = 0; i != m->thread_count; i++) {
gpr_thd_options opt = gpr_thd_options_default();
@@ -71,7 +71,7 @@ static void test_create_threads(struct test *m, void (*body)(void *arg)) {
}
/* Wait until all threads report done. */
-static void test_wait(struct test *m) {
+static void test_wait(struct test* m) {
int i;
for (i = 0; i != m->thread_count; i++) {
gpr_thd_join(m->threads[i]);
@@ -84,10 +84,10 @@ static void test_wait(struct test *m) {
incr_step controls by how much m->refcount should be incremented/decremented
(if at all) each time in the tests.
*/
-static void test(const char *name, void (*body)(void *m), int timeout_s,
+static void test(const char* name, void (*body)(void* m), int timeout_s,
int incr_step) {
int64_t iterations = 1024;
- struct test *m;
+ struct test* m;
gpr_timespec start = gpr_now(GPR_CLOCK_REALTIME);
gpr_timespec time_taken;
gpr_timespec deadline = gpr_time_add(
@@ -112,8 +112,8 @@ static void test(const char *name, void (*body)(void *m), int timeout_s,
}
/* Increment m->counter on each iteration; then mark thread as done. */
-static void inc(void *v /*=m*/) {
- struct test *m = v;
+static void inc(void* v /*=m*/) {
+ struct test* m = v;
int64_t i;
for (i = 0; i != m->iterations; i++) {
gpr_spinlock_lock(&m->mu);
@@ -124,8 +124,8 @@ static void inc(void *v /*=m*/) {
/* Increment m->counter under lock acquired with trylock, m->iterations times;
then mark thread as done. */
-static void inctry(void *v /*=m*/) {
- struct test *m = v;
+static void inctry(void* v /*=m*/) {
+ struct test* m = v;
int64_t i;
for (i = 0; i != m->iterations;) {
if (gpr_spinlock_trylock(&m->mu)) {
@@ -138,7 +138,7 @@ static void inctry(void *v /*=m*/) {
/* ------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char* argv[]) {
grpc_test_init(argc, argv);
test("spinlock", &inc, 1, 1);
test("spinlock try", &inctry, 1, 1);