From 13d94ee9c8c5e031a6fb46903802c56784c4d410 Mon Sep 17 00:00:00 2001 From: Alex Wang Date: Wed, 31 Jul 2013 16:09:11 -0700 Subject: 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 Signed-off-by: Alex Wang Signed-off-by: Ben Pfaff --- tests/test-atomic.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/test-atomic.c') 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; } -- cgit v1.2.1