Skip to content

Commit

Permalink
test: Use _MCF_atomic_*
Browse files Browse the repository at this point in the history
  • Loading branch information
lhmouse committed Nov 4, 2024
1 parent 0df1177 commit 3f0d277
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion test/c11_tss_deleted_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tls_destructor(void* ptr)
{
(void) ptr;
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&count, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/c11_tss_dtor.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void
tls_destructor(void* ptr)
{
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/gthr_tls_deleted_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tls_destructor(void* ptr)
{
(void) ptr;
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&count, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/gthr_tls_dtor.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void
tls_destructor(void* ptr)
{
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/libcxx_tls_deleted_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tls_destructor(void* ptr)
{
(void) ptr;
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&count, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/libcxx_tls_dtor.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void
tls_destructor(void* ptr)
{
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static
Expand Down
4 changes: 2 additions & 2 deletions test/once_abort.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ thread_proc(_MCF_thread* self)
_MCF_once_abort(&once);

_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_init, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_init, 1);
}
else if(r == 0) {
/* Assume `resource` has been initialized. */
assert(resource == 1);

_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_ready, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_ready, 1);
}
else
assert(0);
Expand Down
4 changes: 2 additions & 2 deletions test/once_release.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ thread_proc(_MCF_thread* self)
_MCF_once_release(&once);

_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_init, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_init, 1);
}
else if(r == 0) {
/* Assume `resource` has been initialized. */
assert(resource == 1);

_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_ready, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_ready, 1);
}
else
assert(0);
Expand Down
6 changes: 3 additions & 3 deletions test/once_zero_timeout.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ thread_proc(_MCF_thread* self)
_MCF_once_release(&once);

_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_init, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_init, 1);
}
else if(r == 0) {
/* Assume `resource` has been initialized. */
assert(resource == 1);

_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_ready, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_ready, 1);
}
else if(r == -1) {
_MCF_sleep((const int64_t[]) { -100 });
__atomic_fetch_add(&num_timed_out, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&num_timed_out, 1);
}
else
assert(0);
Expand Down
2 changes: 1 addition & 1 deletion test/tls_deleted_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ tls_destructor(void* ptr)
{
(void) ptr;
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(&count, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/tls_dtor.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ tls_destructor(void* ptr)
{
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
assert(_MCF_tls_get(key) == __MCF_nullptr);
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/tls_dtor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ void
tls_destructor(int* ptr)
{
::fprintf(stderr, "thread %d tls_destructor\n", (int) ::_MCF_thread_self_tid());
__atomic_fetch_add(ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static NS::thread_specific_ptr<int> tss_ptr(tls_destructor);
Expand Down
2 changes: 1 addition & 1 deletion test/tls_dtor_static.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void
tls_destructor(void* ptr)
{
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static
Expand Down
2 changes: 1 addition & 1 deletion test/tls_foreign_dtor.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ void
tls_destructor(void* ptr)
{
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
_MCF_atomic_xadd_32_rlx(ptr, 1);
}

static __attribute__((__stdcall__))
Expand Down

0 comments on commit 3f0d277

Please sign in to comment.