Initial file

This commit is contained in:
Justin Ethier 2021-01-05 18:39:36 -08:00
parent c18ca25ad9
commit 2ca6aa4910
2 changed files with 37 additions and 0 deletions

28
ck-polyfill.c Normal file
View file

@ -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 <ck_pr.h>
#include <unistd.h>
// 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;
}

9
ck_pr.h Normal file
View file

@ -0,0 +1,9 @@
#ifndef CYCLONE_CK_POLYFILL_H
#define CYCLONE_CK_POLYFILL_H
#include <stdbool.h>
bool
ck_pr_cas_int(int *target, int old_value, int new_value);
#endif /* CYCLONE_CK_POLYFILL_H */