mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-20 22:29:16 +02:00
forgot to add time.c
This commit is contained in:
parent
7a15968bf5
commit
0bffb295b5
3 changed files with 22 additions and 2 deletions
3
Makefile
3
Makefile
|
@ -128,7 +128,8 @@ COMPILED_LIBS := lib/srfi/18/threads$(SO) lib/srfi/27/rand$(SO) \
|
||||||
lib/chibi/filesystem$(SO) lib/chibi/process$(SO) lib/chibi/time$(SO) \
|
lib/chibi/filesystem$(SO) lib/chibi/process$(SO) lib/chibi/time$(SO) \
|
||||||
lib/chibi/system$(SO) lib/chibi/io/io$(SO) lib/chibi/stty$(SO) \
|
lib/chibi/system$(SO) lib/chibi/io/io$(SO) lib/chibi/stty$(SO) \
|
||||||
lib/chibi/weak$(SO) lib/chibi/heap-stats$(SO) lib/chibi/disasm$(SO) \
|
lib/chibi/weak$(SO) lib/chibi/heap-stats$(SO) lib/chibi/disasm$(SO) \
|
||||||
lib/chibi/optimize/rest$(SO) lib/chibi/optimize/profile$(SO)
|
lib/chibi/optimize/rest$(SO) lib/chibi/optimize/profile$(SO) \
|
||||||
|
lib/scheme/time$(SO)
|
||||||
|
|
||||||
libs: $(COMPILED_LIBS)
|
libs: $(COMPILED_LIBS)
|
||||||
|
|
||||||
|
|
19
lib/scheme/time.c
Normal file
19
lib/scheme/time.c
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
/* time.c -- R7RS time routines */
|
||||||
|
/* Copyright (c) 2011 Alex Shinn. All rights reserved. */
|
||||||
|
/* BSD-style license: http://synthcode.com/license.txt */
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
#include <chibi/eval.h>
|
||||||
|
|
||||||
|
/* TODO: Check a leap second table file at appropriate intervals. */
|
||||||
|
static time_t leap_seconds_since_epoch = 34;
|
||||||
|
|
||||||
|
static sexp sexp_current_second (sexp ctx sexp_api_params(self, n)) {
|
||||||
|
time_t res = time(NULL);
|
||||||
|
return sexp_make_flonum(ctx, res + leap_seconds_since_epoch);
|
||||||
|
}
|
||||||
|
|
||||||
|
sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {
|
||||||
|
sexp_define_foreign(ctx, env, "current-second", 0, sexp_current_second);
|
||||||
|
return SEXP_VOID;
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
(define-library (scheme time)
|
(define-library (scheme time)
|
||||||
(import (scheme))
|
(import (scheme))
|
||||||
(export current-second current-jiffy jiffies-per-second)
|
(export current-second current-jiffy jiffies-per-second)
|
||||||
(include-shared "time.c")
|
(include-shared "time")
|
||||||
(begin
|
(begin
|
||||||
(define current-jiffy current-second)
|
(define current-jiffy current-second)
|
||||||
(define (jiffies-per-second) 1)))
|
(define (jiffies-per-second) 1)))
|
||||||
|
|
Loading…
Add table
Reference in a new issue