Build-out of time library

This commit is contained in:
Justin Ethier 2016-01-10 21:29:45 -05:00
parent 72be398671
commit 2f72b30f23
4 changed files with 17 additions and 20 deletions

View file

@ -16,6 +16,7 @@ SMODULES = \
scheme/file \
scheme/load \
scheme/read \
scheme/time \
scheme/write \
scheme/cyclone/cgen \
scheme/cyclone/common \
@ -81,6 +82,7 @@ bootstrap: icyc
cp scheme/eval.c $(BOOTSTRAP_DIR)/scheme
cp scheme/file.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 icyc.scm $(BOOTSTRAP_DIR)
cp tests/unit-tests.scm $(BOOTSTRAP_DIR)

View file

@ -10,6 +10,7 @@
(scheme load)
(scheme read)
(scheme write)
(scheme time)
(scheme eval))
(cond-expand
(cyclone

View file

@ -172,13 +172,6 @@ typedef enum { STAGE_CLEAR_OR_MARKING
/* Define size of object tags */
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 */
#if STACK_GROWS_DOWNWARD
#define check_overflow(x,y) ((x) < (y))

View file

@ -8,19 +8,20 @@
)
;; TODO: get an FFI syntax for including C header files, even if it is not needed for this library
(begin
;; Experimenting with what an FFI could look like
;; TODO: also need a way to add #include's, and later on compiler options (may already have that, need to check)
;;
;; want the signature to be similar to this:
;; static void __lambda_0(void *data, int argc, closure _,object k_7322, object arg1_737, object arg2_736) {
;; lambda portion is computed, so we can't include that.
;; 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-second
"(void *data, int argc, closure _, object k)"
" make_double(box, 0.0);
time_t t = time(NULL);
double_value(&box) = t;
return_closcall1(data, k, &box); ")
(define-c current-jiffy
"(void *data, int argc, closure _, object k)"
;; TODO: actually get the current jiffy
" make_int(temp, 0);
return_closcall1(data, k, &temp); ")
(define jiffies-per-second 0) ;; TODO: just a placeholder at the moment
(define current-second 0) ;; TODO: just a placeholder at the moment
" make_double(box, 0.0);
clock_t jiffy = clock();
double_value(&box) = jiffy;
return_closcall1(data, k, &box); ")
(define-c jiffies-per-second
"(void *data, int argc, closure _, object k)"
" make_int(box, CLOCKS_PER_SEC);
return_closcall1(data, k, &box); ")
))