Mercurial > hg > Members > Moririn
view src/parallel_execution/AtomicReference.cbc @ 462:8d7e5d48cad3
Running CPU examples
author | Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 20 Dec 2017 22:05:08 +0900 |
parents | 0c024ea61601 |
children | ac244346c85d |
line wrap: on
line source
#include "../context.h" #include "Atomic.h" #include <stdio.h> Atomic* createAtomicReference(struct Context* context) { struct Atomic* atomic = new Atomic(); struct AtomicReference* atomicReference = new AtomicReference(); atomic->atomic = (union Data*)atomicReference; atomic->checkAndSet = C_checkAndSetAtomicReference; return atomic; } __code checkAndSetAtomicReference(struct AtomicReference* atomic, union Data** ptr, union Data* oldData, union Data* newData, __code next(...), __code fail(...)) { if (__sync_bool_compare_and_swap(ptr, oldData, newData)) { goto next(...); } goto fail(...); }