X-Git-Url: http://plrg.eecs.uci.edu/git/?p=c11tester.git;a=blobdiff_plain;f=impatomic.cc;h=a25518030544acde77e682aaf6938ad4852265c1;hp=0a35b4b65d0513da09bdc47d81614c7d14f7ab88;hb=2605bd1432a07fe6c8b6afdb7123567d46b60ba1;hpb=81ea453e58cbb85fddff3aa8919dfbc59c3140eb diff --git a/impatomic.cc b/impatomic.cc index 0a35b4b6..a2551803 100644 --- a/impatomic.cc +++ b/impatomic.cc @@ -1,14 +1,14 @@ #include "impatomic.h" #include "common.h" #include "model.h" -#include "threads.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; } @@ -17,7 +17,7 @@ bool atomic_flag_test_and_set( volatile atomic_flag* __a__ ) { return atomic_flag_test_and_set_explicit( __a__, memory_order_seq_cst ); } void atomic_flag_clear_explicit -( volatile atomic_flag* __a__, memory_order __x__ ) + ( volatile atomic_flag* __a__, memory_order __x__ ) { volatile bool * __p__ = &((__a__)->__f__); model->switch_to_master(new ModelAction(ATOMIC_WRITE, __x__, (void *) __p__, false)); @@ -26,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__ )) + ; +} }