From 2ca6aa4910efcfa5dc4d0e8661d3a74eac28a727 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 5 Jan 2021 18:39:36 -0800 Subject: [PATCH] Initial file --- ck-polyfill.c | 28 ++++++++++++++++++++++++++++ ck_pr.h | 9 +++++++++ 2 files changed, 37 insertions(+) create mode 100644 ck-polyfill.c create mode 100644 ck_pr.h diff --git a/ck-polyfill.c b/ck-polyfill.c new file mode 100644 index 00000000..3ba00187 --- /dev/null +++ b/ck-polyfill.c @@ -0,0 +1,28 @@ +/** + * Cyclone Scheme + * https://github.com/justinethier/cyclone + * + * Copyright (c) 2020, Justin Ethier + * All rights reserved. + * + * FFI module to support calling Scheme code from C. + */ + +#include "cyclone/types.h" +#include "cyclone/runtime.h" +#include +#include + +// TODO: global pthread mutex lock for this? obviously not ideal but the +// whole purpose of this module is a minimal interface for compatibility +// not speed + +bool +ck_pr_cas_int(int *target, int old_value, int new_value) +{ + if (*target == old_value) { + *target = new_value; + return true; + } + return false; +} diff --git a/ck_pr.h b/ck_pr.h new file mode 100644 index 00000000..0075fbce --- /dev/null +++ b/ck_pr.h @@ -0,0 +1,9 @@ +#ifndef CYCLONE_CK_POLYFILL_H +#define CYCLONE_CK_POLYFILL_H + +#include + + bool + ck_pr_cas_int(int *target, int old_value, int new_value); + +#endif /* CYCLONE_CK_POLYFILL_H */