view src/parallel_execution/examples/DPPMC/AtomicTImpl.cbc @ 900:600340b6c03b

fix generate_stub
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Wed, 27 Jan 2021 16:22:19 +0900
parents 88cdab47903f
children e4f918ebd927
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(struct AtomicT_intImpl_int* atomicT_int, int oldData, int newData, __code next(...), __code fail(...)) {
    if (__sync_bool_compare_and_swap(&atomicT_int->atomic, oldData, newData)) {
        goto next(...);
    }
    goto fail(...);
}

__code set(struct AtomicT_intImpl_int* atomicT_int, int newData, __code next(...) ) {
	atomicT_int->atomic = newData;
   goto next(...);
}