X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=impatomic.cc;h=4b5d1c28941246fe1c0a1e2dc1567e4bac22a81e;hb=6b12232a5e3db3bc7f4cbcfa772ba86f1de04cc9;hp=df11202d8ade74f9e677bd8ebb46b2fc1bf062cd;hpb=247e28f81f258c3c380be00a89430186f8ac11ed;p=c11tester.git diff --git a/impatomic.cc b/impatomic.cc index df11202d..4b5d1c28 100644 --- a/impatomic.cc +++ b/impatomic.cc @@ -1,13 +1,14 @@ #include "impatomic.h" #include "common.h" #include "model.h" +#include "threads-model.h" +#include "action.h" namespace std { bool atomic_flag_test_and_set_explicit ( volatile atomic_flag * __a__, memory_order __x__ ) { volatile bool * __p__ = &((__a__)->__f__); - model->switch_to_master(new ModelAction(ATOMIC_RMWR, __x__, (void *) __p__)); - bool result = (bool) thread_current()->get_return_value(); + bool result = (bool) model->switch_to_master(new ModelAction(ATOMIC_RMWR, __x__, (void *) __p__)); model->switch_to_master(new ModelAction(ATOMIC_RMW, __x__, (void *) __p__, true)); return result; } @@ -25,16 +26,15 @@ void atomic_flag_clear_explicit void atomic_flag_clear( volatile atomic_flag* __a__ ) { atomic_flag_clear_explicit( __a__, memory_order_seq_cst ); } -void atomic_flag_fence( const volatile atomic_flag* __a__, memory_order __x__ ) -{ - ASSERT(0); +void __atomic_flag_wait__( volatile atomic_flag* __a__ ) { + while ( atomic_flag_test_and_set( __a__ ) ) + ; } -void __atomic_flag_wait__( volatile atomic_flag* __a__ ) -{ while ( atomic_flag_test_and_set( __a__ ) ); } - void __atomic_flag_wait_explicit__( volatile atomic_flag* __a__, - memory_order __x__ ) -{ while ( atomic_flag_test_and_set_explicit( __a__, __x__ ) ); } + memory_order __x__ ) { + while ( atomic_flag_test_and_set_explicit( __a__, __x__ )) + ; +} }