mirror of
https://github.com/justinethier/cyclone.git
synced 2025-05-19 13:49:16 +02:00
Build-out of time library
This commit is contained in:
parent
72be398671
commit
2f72b30f23
4 changed files with 17 additions and 20 deletions
2
Makefile
2
Makefile
|
@ -16,6 +16,7 @@ SMODULES = \
|
||||||
scheme/file \
|
scheme/file \
|
||||||
scheme/load \
|
scheme/load \
|
||||||
scheme/read \
|
scheme/read \
|
||||||
|
scheme/time \
|
||||||
scheme/write \
|
scheme/write \
|
||||||
scheme/cyclone/cgen \
|
scheme/cyclone/cgen \
|
||||||
scheme/cyclone/common \
|
scheme/cyclone/common \
|
||||||
|
@ -81,6 +82,7 @@ bootstrap: icyc
|
||||||
cp scheme/eval.c $(BOOTSTRAP_DIR)/scheme
|
cp scheme/eval.c $(BOOTSTRAP_DIR)/scheme
|
||||||
cp scheme/file.c $(BOOTSTRAP_DIR)/scheme
|
cp scheme/file.c $(BOOTSTRAP_DIR)/scheme
|
||||||
cp scheme/load.c $(BOOTSTRAP_DIR)/scheme
|
cp scheme/load.c $(BOOTSTRAP_DIR)/scheme
|
||||||
|
cp scheme/time.c $(BOOTSTRAP_DIR)/scheme
|
||||||
cp scheme/cyclone/common.c $(BOOTSTRAP_DIR)/scheme/cyclone
|
cp scheme/cyclone/common.c $(BOOTSTRAP_DIR)/scheme/cyclone
|
||||||
cp icyc.scm $(BOOTSTRAP_DIR)
|
cp icyc.scm $(BOOTSTRAP_DIR)
|
||||||
cp tests/unit-tests.scm $(BOOTSTRAP_DIR)
|
cp tests/unit-tests.scm $(BOOTSTRAP_DIR)
|
||||||
|
|
1
icyc.scm
1
icyc.scm
|
@ -10,6 +10,7 @@
|
||||||
(scheme load)
|
(scheme load)
|
||||||
(scheme read)
|
(scheme read)
|
||||||
(scheme write)
|
(scheme write)
|
||||||
|
(scheme time)
|
||||||
(scheme eval))
|
(scheme eval))
|
||||||
(cond-expand
|
(cond-expand
|
||||||
(cyclone
|
(cyclone
|
||||||
|
|
|
@ -172,13 +172,6 @@ typedef enum { STAGE_CLEAR_OR_MARKING
|
||||||
/* Define size of object tags */
|
/* Define size of object tags */
|
||||||
typedef long tag_type;
|
typedef long tag_type;
|
||||||
|
|
||||||
#ifndef CLOCKS_PER_SEC
|
|
||||||
/* gcc doesn't define this, even though ANSI requires it in <time.h>.. */
|
|
||||||
#define CLOCKS_PER_SEC 0
|
|
||||||
#define setjmp _setjmp
|
|
||||||
#define longjmp _longjmp
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Determine if stack has overflowed */
|
/* Determine if stack has overflowed */
|
||||||
#if STACK_GROWS_DOWNWARD
|
#if STACK_GROWS_DOWNWARD
|
||||||
#define check_overflow(x,y) ((x) < (y))
|
#define check_overflow(x,y) ((x) < (y))
|
||||||
|
|
|
@ -8,19 +8,20 @@
|
||||||
)
|
)
|
||||||
;; TODO: get an FFI syntax for including C header files, even if it is not needed for this library
|
;; TODO: get an FFI syntax for including C header files, even if it is not needed for this library
|
||||||
(begin
|
(begin
|
||||||
;; Experimenting with what an FFI could look like
|
(define-c current-second
|
||||||
;; TODO: also need a way to add #include's, and later on compiler options (may already have that, need to check)
|
"(void *data, int argc, closure _, object k)"
|
||||||
;;
|
" make_double(box, 0.0);
|
||||||
;; want the signature to be similar to this:
|
time_t t = time(NULL);
|
||||||
;; static void __lambda_0(void *data, int argc, closure _,object k_7322, object arg1_737, object arg2_736) {
|
double_value(&box) = t;
|
||||||
;; lambda portion is computed, so we can't include that.
|
return_closcall1(data, k, &box); ")
|
||||||
;; compiler would need to insert the "static void (lambda)" part
|
|
||||||
;; TODO: maybe break up into two args, one being the args list and the other being the function body??
|
|
||||||
(define-c current-jiffy
|
(define-c current-jiffy
|
||||||
"(void *data, int argc, closure _, object k)"
|
"(void *data, int argc, closure _, object k)"
|
||||||
;; TODO: actually get the current jiffy
|
" make_double(box, 0.0);
|
||||||
" make_int(temp, 0);
|
clock_t jiffy = clock();
|
||||||
return_closcall1(data, k, &temp); ")
|
double_value(&box) = jiffy;
|
||||||
(define jiffies-per-second 0) ;; TODO: just a placeholder at the moment
|
return_closcall1(data, k, &box); ")
|
||||||
(define current-second 0) ;; TODO: just a placeholder at the moment
|
(define-c jiffies-per-second
|
||||||
|
"(void *data, int argc, closure _, object k)"
|
||||||
|
" make_int(box, CLOCKS_PER_SEC);
|
||||||
|
return_closcall1(data, k, &box); ")
|
||||||
))
|
))
|
||||||
|
|
Loading…
Add table
Reference in a new issue