about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2014-08-19 12:12:04 -0700
committerKartik K. Agaram <vc@akkartik.com>2014-08-19 12:14:51 -0700
commit624b9e86a110b492d2cb2c8bcf8cb3a60200c056 (patch)
treebb5416e7a9ca608b9a1a1b9fcf39df9ec6ab265c
parent889e4b958e0755eb18f4d545ba4f191d9ea0296c (diff)
downloadmu-624b9e86a110b492d2cb2c8bcf8cb3a60200c056.tar.gz
54
-rw-r--r--new.arc8
-rw-r--r--new.arc.t6
2 files changed, 9 insertions, 5 deletions
diff --git a/new.arc b/new.arc
index 0f0b4b71..54b1ac2f 100644
--- a/new.arc
+++ b/new.arc
@@ -1,9 +1,11 @@
 ;; simple slab allocator. Intended only to carve out isolated memory for
 ;; different threads/routines as they request.
 
-(on-init
-  ((Root_allocator_pointer location) <- literal 1000)  ; 1-1000 reserved
-)
+(= Allocator_start 1000)  ; lower locations reserved
+
+(enq (fn ()
+       (run `(((Root_allocator_pointer location) <- literal ,Allocator_start))))
+     initialization-fns*)
 
 (init-fn new
   ((2 integer-address) <- copy (Root_allocator_pointer integer))
diff --git a/new.arc.t b/new.arc.t
index e256ea86..c10444de 100644
--- a/new.arc.t
+++ b/new.arc.t
@@ -5,7 +5,7 @@
 (add-fns
   '((main)))
 (run function*!main)
-(if (~iso memory* (obj Root_allocator_pointer 1000))
+(if (~iso memory*!Root_allocator_pointer Allocator_start)
   (prn "F - allocator initialized"))
 
 (reset)
@@ -15,5 +15,7 @@
       ((x integer-address deref) <- literal 34))))
 (run function*!main)
 ;? (prn memory*)
-(if (~iso memory*!Root_allocator_pointer 1001)
+(if (~iso memory*!Root_allocator_pointer (+ Allocator_start 1))
   (prn "F - 'new' increments allocator pointer"))
+(if (~iso memory*.Allocator_start 34)
+  (prn "F - 'new' returns old location"))