mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-21 14:49:18 +02:00
adding time_t type handling to stubber, with 2010 "chibi" epoch
This commit is contained in:
parent
a3578d1ef8
commit
b49153dfdf
6 changed files with 37 additions and 8 deletions
8
TODO
8
TODO
|
@ -3,7 +3,7 @@
|
||||||
*+ precise gc rewrite
|
*+ precise gc rewrite
|
||||||
**+ fix heap growing
|
**+ fix heap growing
|
||||||
**+ separate gc heaps
|
**+ separate gc heaps
|
||||||
**- finalizers
|
**+ finalizers
|
||||||
**- weak references
|
**- weak references
|
||||||
*+ ast rewrite
|
*+ ast rewrite
|
||||||
*+ full r5rs
|
*+ full r5rs
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
*= ffi
|
*= ffi
|
||||||
**+ libdl interface
|
**+ libdl interface
|
||||||
**+ opcode generation interface
|
**+ opcode generation interface
|
||||||
**- stub generator
|
**= stub generator
|
||||||
*= cleanup
|
*= cleanup
|
||||||
*- user documentation
|
*- user documentation
|
||||||
*- unicode
|
*- unicode
|
||||||
|
@ -47,6 +47,6 @@
|
||||||
*- SRFI-0 cond-expand
|
*- SRFI-0 cond-expand
|
||||||
*+ SRFI-9 define-record-type
|
*+ SRFI-9 define-record-type
|
||||||
*+ SRFI-69 hash-tables
|
*+ SRFI-69 hash-tables
|
||||||
*- tcp interface
|
*= net interface
|
||||||
*- posix interface
|
*= posix interface
|
||||||
*- code repository with install tools
|
*- code repository with install tools
|
||||||
|
|
|
@ -101,6 +101,12 @@
|
||||||
/* apply to stdin/stdout/stderr. */
|
/* apply to stdin/stdout/stderr. */
|
||||||
/* #define USE_AUTOCLOSE_PORTS 0 */
|
/* #define USE_AUTOCLOSE_PORTS 0 */
|
||||||
|
|
||||||
|
/* uncomment this to use the normal 1970 unix epoch */
|
||||||
|
/* By default chibi uses an datetime epoch starting at */
|
||||||
|
/* 2010/01/01 00:00:00 in order to be able to represent */
|
||||||
|
/* more common times as fixnums. */
|
||||||
|
/* #define USE_2010_EPOCH 0 */
|
||||||
|
|
||||||
/* uncomment this to disable stack overflow checks */
|
/* uncomment this to disable stack overflow checks */
|
||||||
/* By default stacks are fairly small, so it's good to leave */
|
/* By default stacks are fairly small, so it's good to leave */
|
||||||
/* this enabled. */
|
/* this enabled. */
|
||||||
|
@ -235,6 +241,18 @@
|
||||||
#define USE_AUTOCLOSE_PORTS 1
|
#define USE_AUTOCLOSE_PORTS 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef USE_2010_EPOCH
|
||||||
|
#define USE_2010_EPOCH 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef SEXP_EPOCH_OFFSET
|
||||||
|
#if USE_2010_EPOCH
|
||||||
|
#define SEXP_EPOCH_OFFSET 1262271600
|
||||||
|
#else
|
||||||
|
#define SEXP_EPOCH_OFFSET 0
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef USE_CHECK_STACK
|
#ifndef USE_CHECK_STACK
|
||||||
#define USE_CHECK_STACK 1
|
#define USE_CHECK_STACK 1
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -483,6 +483,9 @@ SEXP_API sexp sexp_make_integer(sexp ctx, sexp_sint_t x);
|
||||||
#define sexp_sint_value(x) ((sexp_sint_t)sexp_unbox_fixnum(x))
|
#define sexp_sint_value(x) ((sexp_sint_t)sexp_unbox_fixnum(x))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define sexp_shift_epoch(x) ((x)-SEXP_EPOCH_OFFSET)
|
||||||
|
#define sexp_unshift_epoch(x) ((x)+SEXP_EPOCH_OFFSET)
|
||||||
|
|
||||||
/*************************** field accessors **************************/
|
/*************************** field accessors **************************/
|
||||||
|
|
||||||
#define sexp_vector_length(x) ((x)->value.vector.length)
|
#define sexp_vector_length(x) ((x)->value.vector.length)
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
(define-module (chibi posix)
|
(define-module (chibi posix)
|
||||||
(export open-input-fd open-output-fd
|
(export open-input-fd open-output-fd
|
||||||
delete-file link-file symbolic-link rename-file
|
delete-file link-file symbolic-link rename-file
|
||||||
create-directory delete-directory)
|
create-directory delete-directory
|
||||||
|
current-seconds)
|
||||||
(import (scheme))
|
(import (scheme))
|
||||||
(include-shared "posix"))
|
(include-shared "posix"))
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
|
|
||||||
(c-system-include "sys/types.h")
|
(c-system-include "sys/types.h")
|
||||||
|
(c-system-include "time.h")
|
||||||
(c-system-include "unistd.h")
|
(c-system-include "unistd.h")
|
||||||
|
|
||||||
(define-c input-port (open-input-fd fdopen) (int (value "r")))
|
(define-c input-port (open-input-fd fdopen) (int (value "r")))
|
||||||
|
@ -7,7 +8,7 @@
|
||||||
|
|
||||||
(define-c errno (delete-file unlink) (string))
|
(define-c errno (delete-file unlink) (string))
|
||||||
(define-c errno (link-file link) (string string))
|
(define-c errno (link-file link) (string string))
|
||||||
(define-c errno (symbolic-link symlink) (string string))
|
(define-c errno (symbolic-link-file symlink) (string string))
|
||||||
(define-c errno (rename-file rename) (string string))
|
(define-c errno (rename-file rename) (string string))
|
||||||
|
|
||||||
(define-c errno (create-directory mkdir) (string int))
|
(define-c errno (create-directory mkdir) (string int))
|
||||||
|
@ -16,3 +17,5 @@
|
||||||
(define-c int (duplicate-fd dup) (int))
|
(define-c int (duplicate-fd dup) (int))
|
||||||
;;(define-c errno pipe ((array int 2)))
|
;;(define-c errno pipe ((array int 2)))
|
||||||
|
|
||||||
|
(define-c time_t (current-seconds time) ((value NULL)))
|
||||||
|
|
||||||
|
|
|
@ -156,6 +156,8 @@
|
||||||
(cond
|
(cond
|
||||||
((memq type '(sexp errno))
|
((memq type '(sexp errno))
|
||||||
(cat val))
|
(cat val))
|
||||||
|
((eq? type 'time_t)
|
||||||
|
(cat "sexp_make_integer(ctx, sexp_shift_epoch(" val "))"))
|
||||||
((int-type? type)
|
((int-type? type)
|
||||||
(cat "sexp_make_integer(ctx, " val ")"))
|
(cat "sexp_make_integer(ctx, " val ")"))
|
||||||
((eq? 'string type)
|
((eq? 'string type)
|
||||||
|
@ -180,6 +182,8 @@
|
||||||
(cond
|
(cond
|
||||||
((eq? 'sexp type)
|
((eq? 'sexp type)
|
||||||
(cat val))
|
(cat val))
|
||||||
|
((eq? type 'time_t)
|
||||||
|
(cat "sexp_uint_value(sexp_unshift_epoch(" val "))"))
|
||||||
((signed-int-type? type)
|
((signed-int-type? type)
|
||||||
(cat "sexp_sint_value(" val ")"))
|
(cat "sexp_sint_value(" val ")"))
|
||||||
((unsigned-int-type? type)
|
((unsigned-int-type? type)
|
||||||
|
@ -293,10 +297,10 @@
|
||||||
(let ((ret-type (cadr func))
|
(let ((ret-type (cadr func))
|
||||||
(result (get-func-result func))
|
(result (get-func-result func))
|
||||||
(args (get-func-args func)))
|
(args (get-func-args func)))
|
||||||
(cat "static sexp " (car func) "(sexp ctx, ")
|
(cat "static sexp " (car func) "(sexp ctx")
|
||||||
(let lp ((ls args) (i 0))
|
(let lp ((ls args) (i 0))
|
||||||
(cond ((pair? ls)
|
(cond ((pair? ls)
|
||||||
(cat "sexp arg" i (if (pair? (cdr ls)) ", " ""))
|
(cat ", sexp arg" i)
|
||||||
(lp (cdr ls) (+ i 1)))))
|
(lp (cdr ls) (+ i 1)))))
|
||||||
(cat ") {\n sexp res;\n")
|
(cat ") {\n sexp res;\n")
|
||||||
(if (eq? 'errno ret-type) (cat " int err;\n"))
|
(if (eq? 'errno ret-type) (cat " int err;\n"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue