diff options
Diffstat (limited to 'csu/tst-atomic.c')
-rw-r--r-- | csu/tst-atomic.c | 82 |
1 files changed, 81 insertions, 1 deletions
diff --git a/csu/tst-atomic.c b/csu/tst-atomic.c index e5686e377d..943c050735 100644 --- a/csu/tst-atomic.c +++ b/csu/tst-atomic.c @@ -48,6 +48,22 @@ do_test (void) puts ("atomic_compare_and_exchange_val_acq test 2 failed"); ret = 1; } + + mem = -15; + if (atomic_compare_and_exchange_val_acq (&mem, -56, -15) != -15 + || mem != -56) + { + puts ("atomic_compare_and_exchange_val_acq test 3 failed"); + ret = 1; + } + + mem = -1; + if (atomic_compare_and_exchange_val_acq (&mem, 17, 0) != -1 + || mem != -1) + { + puts ("atomic_compare_and_exchange_val_acq test 4 failed"); + ret = 1; + } #endif mem = 24; @@ -66,6 +82,22 @@ do_test (void) ret = 1; } + mem = -15; + if (atomic_compare_and_exchange_bool_acq (&mem, -56, -15) + || mem != -56) + { + puts ("atomic_compare_and_exchange_bool_acq test 3 failed"); + ret = 1; + } + + mem = -1; + if (! atomic_compare_and_exchange_bool_acq (&mem, 17, 0) + || mem != -1) + { + puts ("atomic_compare_and_exchange_bool_acq test 4 failed"); + ret = 1; + } + mem = 64; if (atomic_exchange (&mem, 31) != 64 || mem != 31) @@ -150,7 +182,7 @@ do_test (void) if (! atomic_decrement_and_test (&mem) || mem != 0) { - puts ("atomic_decrement_and_test test 1 failed"); + puts ("atomic_decrement_and_test test 3 failed"); ret = 1; } @@ -202,6 +234,30 @@ do_test (void) ret = 1; } + mem = -12; + if (atomic_add_negative (&mem, 14) + || mem != 2) + { + puts ("atomic_add_negative test 4 failed"); + ret = 1; + } + + mem = 0; + if (! atomic_add_negative (&mem, -1) + || mem != -1) + { + puts ("atomic_add_negative test 5 failed"); + ret = 1; + } + + mem = -31; + if (atomic_add_negative (&mem, 31) + || mem != 0) + { + puts ("atomic_add_negative test 6 failed"); + ret = 1; + } + mem = -34; if (atomic_add_zero (&mem, 31) || mem != -3) @@ -226,6 +282,30 @@ do_test (void) ret = 1; } + mem = -18; + if (atomic_add_zero (&mem, 20) + || mem != 2) + { + puts ("atomic_add_zero test 4 failed"); + ret = 1; + } + + mem = 10; + if (atomic_add_zero (&mem, -20) + || mem != -10) + { + puts ("atomic_add_zero test 5 failed"); + ret = 1; + } + + mem = 10; + if (! atomic_add_zero (&mem, -10) + || mem != 0) + { + puts ("atomic_add_zero test 6 failed"); + ret = 1; + } + mem = 0; atomic_bit_set (&mem, 1); if (mem != 2) |