diff --git a/eval.c b/eval.c index 5bb1e465..ed4859c3 100644 --- a/eval.c +++ b/eval.c @@ -1073,11 +1073,15 @@ sexp sexp_close_port_op (sexp ctx, sexp self, sexp_sint_t n, sexp port) { } #if SEXP_USE_STATIC_LIBS +#ifndef PLAN9 #include "clibs.c" -static sexp_library_entry_t *sexp_find_static_library(const char *file) +#else +struct sexp_library_entry_t sexp_static_libraries[]; +#endif +static struct sexp_library_entry_t *sexp_find_static_library(const char *file) { size_t base_len; - sexp_library_entry_t *entry; + struct sexp_library_entry_t *entry; if (file[0] == '.' && file[1] == '/') file += 2; @@ -1090,7 +1094,7 @@ static sexp_library_entry_t *sexp_find_static_library(const char *file) return NULL; } static sexp sexp_load_dl (sexp ctx, sexp file, sexp env) { - sexp_library_entry_t *entry = sexp_find_static_library(sexp_string_data(file)); + struct sexp_library_entry_t *entry = sexp_find_static_library(sexp_string_data(file)); if (! entry) return sexp_compile_error(ctx, "couldn't find builtin library", file); return entry->init(ctx, NULL, 3, env, sexp_version, SEXP_ABI_IDENTIFIER); diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 929bab38..b10c5fcf 100755 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -255,6 +255,11 @@ struct sexp_gc_var_t { struct sexp_gc_var_t *next; }; +struct sexp_library_entry_t { /* for static builds */ + const char *name; + sexp_init_proc init; +}; + struct sexp_type_struct { sexp_tag_t tag; short field_base, field_eq_len_base, field_len_base, field_len_off; diff --git a/lib/chibi/time.stub b/lib/chibi/time.stub index 7746ee6c..1da56217 100644 --- a/lib/chibi/time.stub +++ b/lib/chibi/time.stub @@ -1,6 +1,9 @@ -(c-system-include "time.h") -(c-system-include "sys/time.h") +(cond-expand + (plan9) + (else + (c-system-include "time.h") + (c-system-include "sys/time.h"))) (define-c-struct tm predicate: tm? diff --git a/lib/scheme/time.c b/lib/scheme/time.c index d2e13db5..13e56145 100644 --- a/lib/scheme/time.c +++ b/lib/scheme/time.c @@ -2,9 +2,14 @@ /* Copyright (c) 2011-2012 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ -#include #include +#ifndef PLAN9 +#include +#else +typedef long time_t; +#endif + /* TODO: Check a leap second table file at appropriate intervals. */ static time_t leap_seconds_since_epoch = 24; diff --git a/lib/srfi/33/bit.c b/lib/srfi/33/bit.c index e69199ef..8b0e37b8 100644 --- a/lib/srfi/33/bit.c +++ b/lib/srfi/33/bit.c @@ -1,9 +1,14 @@ /* bit.c -- bitwise operators */ -/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */ +/* Copyright (c) 2009-2012 Alex Shinn. All rights reserved. */ /* BSD-style license: http://synthcode.com/license.txt */ #include + +#ifndef PLAN9 #include +#else +#define CHAR_BIT 8 +#endif #if SEXP_USE_BIGNUMS #include diff --git a/lib/srfi/98/env.c b/lib/srfi/98/env.c index 904006b4..29cfba25 100644 --- a/lib/srfi/98/env.c +++ b/lib/srfi/98/env.c @@ -1,13 +1,15 @@ -/* env.c -- SRFI-98 environment interface */ -/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */ -/* BSD-style license: http://synthcode.com/license.txt */ +/* env.c -- SRFI-98 environment interface */ +/* Copyright (c) 2009-2012 Alex Shinn. All rights reserved. */ +/* BSD-style license: http://synthcode.com/license.txt */ #ifdef __APPLE__ #include #define environ (*_NSGetEnviron()) #else +#ifndef PLAN9 extern char **environ; #endif +#endif #include @@ -25,6 +27,7 @@ sexp sexp_get_environment_variables (sexp ctx, sexp self, sexp_sint_t n) { sexp_gc_var3(res, name, val); sexp_gc_preserve3(ctx, res, name, val); res = SEXP_NULL; +#ifndef PLAN9 env = environ; for (i=0; env[i]; i++) { cname = env[i]; @@ -36,6 +39,7 @@ sexp sexp_get_environment_variables (sexp ctx, sexp self, sexp_sint_t n) { res = sexp_cons(ctx, val, res); } } +#endif sexp_gc_release3(ctx); return res; } diff --git a/mkfile b/mkfile index 1e3f77b8..0cabf51c 100644 --- a/mkfile +++ b/mkfile @@ -4,14 +4,52 @@ BIN=/$objtype/bin TARG=chibi-scheme MODDIR=/sys/lib/chibi-scheme -CPPFLAGS= -Iinclude -DPLAN9 -DSEXP_USE_STRING_STREAMS=0 -DSEXP_USE_GREEN_THREADS=0 -CFLAGS= -p $CPPFLAGS +CHIBI=./$O.out +GENSTATIC=./tools/chibi-genstatic -OFILES=sexp.$O eval.$O main.$O +CPPFLAGS= -Iinclude -DPLAN9 -DSEXP_USE_GREEN_THREADS=0 +CFLAGS= -p $CPPFLAGS +CFLAGS_STATIC=$CFLAGS -DSEXP_USE_STATIC_LIBS + +OFILES=sexp.$O eval.$O main.$O $STATIC HFILES=include/chibi/sexp.h include/chibi/eval.h include/chibi/features.h include/chibi/install.h +CLEANFILES=tests/basic/*.out tests/basic/*.err + +EXCLUDE=srfi.18 srfi.27 chibi.filesystem chibi.io \ + chibi.net chibi.process chibi.stty chibi.system \ + chibi.time + +CHIBI_LIBS = lib/chibi/filesystem.c lib/chibi/process.c \ + lib/chibi/time.c lib/chibi/system.c lib/chibi/stty.c \ + lib/chibi/weak.c lib/chibi/heap-stats.c lib/chibi/disasm.c \ + lib/chibi/net.c +CHIBI_IO_COMPILED_LIBS = lib/chibi/io/io.c +CHIBI_OPT_COMPILED_LIBS = lib/chibi/optimize/rest.c \ + lib/chibi/optimize/profile.c +COMPILED_LIBS = $CHIBI_COMPILED_LIBS $CHIBI_IO_COMPILED_LIBS \ + $CHIBI_OPT_COMPILED_LIBS \ + lib/srfi/33/bit.c lib/srfi/39/param.c \ + lib/srfi/69/hash.c lib/srfi/95/qsort.c lib/srfi/98/env.c \ + lib/scheme/time.c include/chibi/install.h echo '#define sexp_so_extension ".no-such-file"' >> include/chibi/install.h @@ -19,10 +57,21 @@ include/chibi/install.h: mkfile echo '#define sexp_version "'`{cat VERSION}'"' >> include/chibi/install.h echo '#define sexp_release_name "'`{cat RELEASE}'"' >> include/chibi/install.h +dist-clean: clean + rm -f include/chibi/install.h clibs.c + install:V: $BIN/$TARG test -d $MODDIR || mkdir -p $MODDIR {cd lib; tar c .} | {cd $MODDIR ; tar x } +clibs.c:V: $GENSTATIC $CHIBI $COMPILED_LIBS + du -a lib | sed 's/^[0-9]*[ ]*//' | grep '\.sld$' | \ + $CHIBI $GENSTATIC \ + -x srfi.27 -x srfi.18 -x chibi.filesystem -x chibi.io \ + -x chibi.net -x chibi.process -x chibi.stty -x chibi.system \ + -x chibi.time \ + > ,clibs.c && mv ,clibs.c clibs.c + test:V: ./$O.out -xscheme tests/r5rs-tests.scm diff --git a/tools/chibi-genstatic b/tools/chibi-genstatic index ef941126..434d7442 100755 --- a/tools/chibi-genstatic +++ b/tools/chibi-genstatic @@ -214,12 +214,12 @@ (newline) (for-each include-c-lib c-libs) (newline) - (display "typedef struct {\n") - (display " const char *name;\n") - (display " sexp_init_proc init;\n") - (display "} sexp_library_entry_t;\n") - (newline) - (display "static sexp_library_entry_t sexp_static_libraries[] = {\n") + ;; (display "typedef struct {\n") + ;; (display " const char *name;\n") + ;; (display " sexp_init_proc init;\n") + ;; (display "} sexp_library_entry_t;\n") + ;; (newline) + (display "struct sexp_library_entry_t sexp_static_libraries[] = {\n") (for-each init-c-lib c-libs) (display " { NULL, NULL }\n") (display "};\n\n")))