Thanks very much for the fix.
On Wed, Jul 31, 2013 at 4:09 PM, Ben Pfaff <[email protected]> wrote: > On Wed, Jul 31, 2013 at 04:09:11PM -0700, Alex Wang wrote: > > 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 <[email protected]> > > Signed-off-by: Alex Wang <[email protected]> > > I had to remove OVS_ACQUIRES from the xpthread*() prototypes: > > ../lib/ovs-thread.h:89:50: error: 'exclusive_lock_function' attribute > requires arguments whose type is annotated with 'lockable' attribute; type > here is 'pthread_mutex_t *' [-Werror,-Wthread-safety-attributes] > void xpthread_mutex_lock(pthread_mutex_t *mutex) OVS_ACQUIRES(mutex); > > Also I didn't see a reason to put the test into a macro instead of a > function, so I changed it. > > Here's the incremental that I folded in: > > diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h > index fe0e8d2..9b8eeef 100644 > --- a/lib/ovs-thread.h > +++ b/lib/ovs-thread.h > @@ -86,8 +86,8 @@ void ovs_mutex_cond_wait(pthread_cond_t *, const struct > ovs_mutex *); > > /* Wrappers for pthread_mutex_*() that abort the process on any error. > * This is still needed when ovs-atomic-pthreads.h is used. */ > -void xpthread_mutex_lock(pthread_mutex_t *mutex) OVS_ACQUIRES(mutex); > -void xpthread_mutex_unlock(pthread_mutex_t *mutex) OVS_RELEASES(mutex); > +void xpthread_mutex_lock(pthread_mutex_t *mutex); > +void xpthread_mutex_unlock(pthread_mutex_t *mutex); > > /* Wrappers for pthread_mutexattr_*() that abort the process on any > error. */ > void xpthread_mutexattr_init(pthread_mutexattr_t *); > diff --git a/tests/test-atomic.c b/tests/test-atomic.c > index 480c3cd..e9bd6bd 100644 > --- a/tests/test-atomic.c > +++ b/tests/test-atomic.c > @@ -61,14 +61,15 @@ > ovs_assert(value == 8); \ > } > > -#define TEST_ATOMIC_FLAG_TEST_SET() \ > - { \ > - 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); \ > - } > +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) > @@ -99,6 +100,7 @@ main(void) > TEST_ATOMIC_TYPE(atomic_uint64_t, uint64_t); > TEST_ATOMIC_TYPE(atomic_int64_t, int64_t); > > - TEST_ATOMIC_FLAG_TEST_SET(); > + test_atomic_flag(); > + > return 0; > } >
_______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
