Mercurial > hg > Gears > Gears
view src/parallel_execution/examples/DPP2/AtomicTImpl.cbc @ 846:348d6f20134e
...
author | anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 21 Jan 2021 17:25:57 +0900 |
parents | 6f98515b995f |
children | 7294be69d520 |
line wrap: on
line source
#include "../../../context.h" #impl "AtomicT_int.h" for "AtomicT_intImpl_int.h" #include <stdio.h> AtomicT_int* createAtomicT_intImpl_int(struct Context* context,int init) { struct AtomicT_int* atomicT_int = new AtomicT_int(); struct AtomicT_intImpl_int* atomic_t_impl = new AtomicT_intImpl_int(); atomicT_int->atomicT_int = (union Data*)atomic_t_impl; atomicT_int->checkAndSet = C_checkAndSet_AtomicT_intImpl; atomicT_int->set = C_set_AtomicT_intImpl; atomic_t_impl->atomic = init; atomic_t_impl->init = init; return atomicT_int; } __code checkAndSet_AtomicT_intImpl(struct AtomicT_intImpl_int* atomicT_int, int* ptr,int init, int newData, __code next(...), __code fail(...)) { if (__sync_bool_compare_and_swap(ptr, init, newData)) { goto next(...); } goto fail(...); } __code set_AtomicT_intImpl(struct AtomicT_intImpl_int* atomicT_int, int* ptr, int newData, __code next(...) ) { *ptr = newData; goto next(...); }