summaryrefslogtreecommitdiff
path: root/tests/test-atomic.c
diff options
context:
space:
mode:
authorAlex Wang <alexw@nicira.com>2013-07-31 16:09:11 -0700
committerBen Pfaff <blp@nicira.com>2013-07-31 16:07:46 -0700
commit13d94ee9c8c5e031a6fb46903802c56784c4d410 (patch)
tree4cf2043e5d92504fad5d8c1f62dda910139b434b /tests/test-atomic.c
parent431495b10f1c3aa577b8306ad996c41ff0581309 (diff)
downloadopenvswitch-13d94ee9c8c5e031a6fb46903802c56784c4d410.tar.gz
ovs-atomic-pthreads: Fix "has incomplete type" error.
Commit 97be153858b4cd175cbe7862b8e1624bf22ab98a (clang: Add annotations for thread safety check.) defined 'struct ovs_mutex' variable in 'atomic_flag' in 'ovs-atomic-pthreads.h'. This casued "mutex: has incomplete type" error in compilation when 'ovs-atomic-pthreads.h' is included. This commit goes back to use 'pthread_mutex_t' for that variable and adds test for the 'atomic_flag' related functions. Reported-by: Gurucharan Shetty <gshetty@nicira.com> Signed-off-by: Alex Wang <alexw@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'tests/test-atomic.c')
-rw-r--r--tests/test-atomic.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/test-atomic.c b/tests/test-atomic.c
index 27bf5520e..e9bd6bda0 100644
--- a/tests/test-atomic.c
+++ b/tests/test-atomic.c
@@ -61,6 +61,16 @@
ovs_assert(value == 8); \
}
+static void
+test_atomic_flag(void)
+{
+ atomic_flag flag = ATOMIC_FLAG_INIT;
+ ovs_assert(atomic_flag_test_and_set(&flag) == false);
+ ovs_assert(flag.b == true);
+ atomic_flag_clear(&flag);
+ ovs_assert(flag.b == false);
+}
+
int
main(void)
{
@@ -90,5 +100,7 @@ main(void)
TEST_ATOMIC_TYPE(atomic_uint64_t, uint64_t);
TEST_ATOMIC_TYPE(atomic_int64_t, int64_t);
+ test_atomic_flag();
+
return 0;
}