mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-24 20:45:06 +02:00
WIP
This commit is contained in:
parent
ddd057f97b
commit
dcd14e4642
1 changed files with 18 additions and 1 deletions
|
@ -15,6 +15,9 @@
|
||||||
;; (atom? obj)
|
;; (atom? obj)
|
||||||
;; (atom obj)
|
;; (atom obj)
|
||||||
|
|
||||||
|
(import (scheme base) (scheme write))
|
||||||
|
(include-c-header "<ck_pr.h>")
|
||||||
|
|
||||||
(define-c atom?
|
(define-c atom?
|
||||||
"(void *data, int argc, closure _, object k, object obj)"
|
"(void *data, int argc, closure _, object k, object obj)"
|
||||||
" object result = Cyc_is_atomic(obj);
|
" object result = Cyc_is_atomic(obj);
|
||||||
|
@ -32,6 +35,7 @@
|
||||||
tmp.tag = atomic_tag;
|
tmp.tag = atomic_tag;
|
||||||
tmp.obj = obj;
|
tmp.obj = obj;
|
||||||
atm = gc_alloc(((gc_thread_data *)data)->heap, sizeof(atomic_type), (char *)(&tmp), (gc_thread_data *)data, &heap_grown);
|
atm = gc_alloc(((gc_thread_data *)data)->heap, sizeof(atomic_type), (char *)(&tmp), (gc_thread_data *)data, &heap_grown);
|
||||||
|
ck_pr_store_ptr(&(atm->obj), obj); // Needed??
|
||||||
return_closcall1(data, k, atm); ")
|
return_closcall1(data, k, atm); ")
|
||||||
|
|
||||||
(define (atom . obj)
|
(define (atom . obj)
|
||||||
|
@ -39,8 +43,15 @@
|
||||||
(make-atom (car obj))
|
(make-atom (car obj))
|
||||||
(make-atom #f)))
|
(make-atom #f)))
|
||||||
|
|
||||||
;; TODO:
|
|
||||||
;; - ref atomic
|
;; - ref atomic
|
||||||
|
(define-c ref
|
||||||
|
"(void *data, int argc, closure _, object k, object obj)"
|
||||||
|
" atomic a;
|
||||||
|
if (Cyc_is_atomic(obj) != boolean_t) {
|
||||||
|
Cyc_rt_raise2(data, \"Type error: expected atom\", obj);
|
||||||
|
}
|
||||||
|
a = (atomic) obj;
|
||||||
|
return_closcall1(data, k, ck_pr_load_ptr(&(a->obj)));")
|
||||||
|
|
||||||
;; TODO:
|
;; TODO:
|
||||||
;; - swap, see https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/swap!
|
;; - swap, see https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/swap!
|
||||||
|
@ -48,3 +59,9 @@
|
||||||
|
|
||||||
;; TODO:
|
;; TODO:
|
||||||
;; - compare and swap?
|
;; - compare and swap?
|
||||||
|
|
||||||
|
(define a (make-atom '(1 2)))
|
||||||
|
(write
|
||||||
|
(list
|
||||||
|
a
|
||||||
|
(ref a)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue