Skip to content

Commit 3f42970

Browse files
committed
test: Use _MCF_atomic_*
(cherry picked from commit 3f0d277) Signed-off-by: LIU Hao <lh_mouse@126.com>
1 parent b7d0027 commit 3f42970

14 files changed

+18
-18
lines changed

test/c11_tss_deleted_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tls_destructor(void* ptr)
2323
{
2424
(void) ptr;
2525
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
26-
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
26+
_MCF_atomic_xadd_32_rlx(&count, 1);
2727
}
2828

2929
static

test/c11_tss_dtor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void
2121
tls_destructor(void* ptr)
2222
{
2323
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
24-
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
24+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2525
}
2626

2727
static

test/gthr_tls_deleted_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tls_destructor(void* ptr)
2323
{
2424
(void) ptr;
2525
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
26-
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
26+
_MCF_atomic_xadd_32_rlx(&count, 1);
2727
}
2828

2929
static

test/gthr_tls_dtor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void
2121
tls_destructor(void* ptr)
2222
{
2323
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
24-
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
24+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2525
}
2626

2727
static

test/libcxx_tls_deleted_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tls_destructor(void* ptr)
2323
{
2424
(void) ptr;
2525
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
26-
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
26+
_MCF_atomic_xadd_32_rlx(&count, 1);
2727
}
2828

2929
static

test/libcxx_tls_dtor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void
2121
tls_destructor(void* ptr)
2222
{
2323
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
24-
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
24+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2525
}
2626

2727
static

test/once_abort.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ thread_proc(_MCF_thread* self)
3535
_MCF_once_abort(&once);
3636

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

4444
_MCF_sleep((const int64_t[]) { -100 });
45-
__atomic_fetch_add(&num_ready, 1, __ATOMIC_RELAXED);
45+
_MCF_atomic_xadd_32_rlx(&num_ready, 1);
4646
}
4747
else
4848
assert(0);

test/once_release.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ thread_proc(_MCF_thread* self)
3535
_MCF_once_release(&once);
3636

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

4444
_MCF_sleep((const int64_t[]) { -100 });
45-
__atomic_fetch_add(&num_ready, 1, __ATOMIC_RELAXED);
45+
_MCF_atomic_xadd_32_rlx(&num_ready, 1);
4646
}
4747
else
4848
assert(0);

test/once_zero_timeout.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ thread_proc(_MCF_thread* self)
3636
_MCF_once_release(&once);
3737

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

4545
_MCF_sleep((const int64_t[]) { -100 });
46-
__atomic_fetch_add(&num_ready, 1, __ATOMIC_RELAXED);
46+
_MCF_atomic_xadd_32_rlx(&num_ready, 1);
4747
}
4848
else if(r == -1) {
4949
_MCF_sleep((const int64_t[]) { -100 });
50-
__atomic_fetch_add(&num_timed_out, 1, __ATOMIC_RELAXED);
50+
_MCF_atomic_xadd_32_rlx(&num_timed_out, 1);
5151
}
5252
else
5353
assert(0);

test/tls_deleted_key.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ tls_destructor(void* ptr)
2323
{
2424
(void) ptr;
2525
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
26-
__atomic_fetch_add(&count, 1, __ATOMIC_RELAXED);
26+
_MCF_atomic_xadd_32_rlx(&count, 1);
2727
}
2828

2929
static

test/tls_dtor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ tls_destructor(void* ptr)
2222
{
2323
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
2424
assert(_MCF_tls_get(key) == __MCF_nullptr);
25-
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
25+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2626
}
2727

2828
static

test/tls_dtor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void
2424
tls_destructor(int* ptr)
2525
{
2626
::fprintf(stderr, "thread %d tls_destructor\n", (int) ::_MCF_thread_self_tid());
27-
__atomic_fetch_add(ptr, 1, __ATOMIC_RELAXED);
27+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2828
}
2929

3030
static NS::thread_specific_ptr<int> tss_ptr(tls_destructor);

test/tls_dtor_static.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void
2121
tls_destructor(void* ptr)
2222
{
2323
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
24-
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
24+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2525
}
2626

2727
static

test/tls_foreign_dtor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void
2222
tls_destructor(void* ptr)
2323
{
2424
fprintf(stderr, "thread %d tls_destructor\n", (int) _MCF_thread_self_tid());
25-
__atomic_fetch_add((int*) ptr, 1, __ATOMIC_RELAXED);
25+
_MCF_atomic_xadd_32_rlx(ptr, 1);
2626
}
2727

2828
static __attribute__((__stdcall__))

0 commit comments

Comments
 (0)