diff --git a/.hgignore b/.hgignore index 51566e20..05828695 100644 --- a/.hgignore +++ b/.hgignore @@ -16,4 +16,4 @@ junk* gc gc6.8 chibi-scheme - +include/chibi/install.h diff --git a/Makefile b/Makefile index 4214d381..7606ca9f 100644 --- a/Makefile +++ b/Makefile @@ -37,12 +37,13 @@ endif ifdef USE_BOEHM GCLDFLAGS := -lgc +CPPFLAGS := $(CPPFLAGS) -Iinclude -DUSE_BOEHM=1 else GCLDFLAGS := +CPPFLAGS := $(CPPFLAGS) -Iinclude endif LDFLAGS := $(LDFLAGS) -lm -CPPFLAGS := $(CPPFLAGS) -Iinclude CFLAGS := $(CFLAGS) -Wall -O2 -g INCLUDES = include/chibi/sexp.h include/chibi/config.h include/chibi/install.h @@ -60,10 +61,10 @@ main.o: main.c $(INCLUDES) Makefile $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $< libchibi-scheme$(SO): eval.o sexp.o - $(CC) -dynamiclib -o $@ $^ + $(CC) $(CLIBFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS) chibi-scheme$(EXE): main.o libchibi-scheme$(SO) - $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< $(LDFLAGS) $(GCLDFLAGS) -L. -lchibi-scheme + $(CC) $(CPPFLAGS) $(CFLAGS) -o $@ $< -L. -lchibi-scheme chibi-scheme-static$(EXE): main.o eval.o sexp.o $(CC) $(CFLAGS) $(STATICFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS) diff --git a/gc.c b/gc.c index 37444e04..7144cbee 100644 --- a/gc.c +++ b/gc.c @@ -154,7 +154,7 @@ sexp_heap sexp_make_heap (size_t size) { sexp free, next; sexp_heap h = (sexp_heap) malloc(sizeof(struct sexp_heap) + size); if (! h) { - fprintf(stderr, "out of memory allocating %ld byte heap, aborting\n", size); + fprintf(stderr, "out of memory allocating %lu byte heap, aborting\n", size); exit(70); } h->size = size; @@ -222,7 +222,7 @@ void* sexp_alloc (sexp ctx, size_t size) { sexp_grow_heap(ctx, size); res = sexp_try_alloc(ctx, size); if (! res) { - fprintf(stderr, "out of memory allocating %ld bytes, aborting\n", size); + fprintf(stderr, "out of memory allocating %lu bytes, aborting\n", size); exit(70); } } diff --git a/include/chibi/sexp.h b/include/chibi/sexp.h index 348052d4..2bbc323c 100644 --- a/include/chibi/sexp.h +++ b/include/chibi/sexp.h @@ -215,7 +215,7 @@ struct sexp_struct { #define sexp_gc_preserve(ctx, x, y) #define sexp_gc_release(ctx, x, y) -#include "gc.h" +#include "gc/gc.h" #define sexp_alloc(ctx, size) GC_malloc(size) #define sexp_alloc_atomic(ctx, size) GC_malloc_atomic(size) #define sexp_realloc(ctx, x, size) GC_realloc(x, size) diff --git a/sexp.c b/sexp.c index 775f64c8..bd1a851b 100644 --- a/sexp.c +++ b/sexp.c @@ -629,7 +629,7 @@ sexp sexp_make_input_string_port (sexp ctx, sexp str) { sexp sexp_make_output_string_port (sexp ctx) { FILE *out; sexp buf = sexp_alloc_type(ctx, string, SEXP_STRING), res; - out = open_memstream(&sexp_string_data(buf), &sexp_string_length(buf)); + out = open_memstream((char**)&sexp_string_data(buf), (size_t*)&sexp_string_length(buf)); res = sexp_make_input_port(ctx, out, SEXP_FALSE); sexp_port_cookie(res) = buf; return res; @@ -638,7 +638,8 @@ sexp sexp_make_output_string_port (sexp ctx) { sexp sexp_get_output_string (sexp ctx, sexp port) { sexp cookie = sexp_port_cookie(port); fflush(sexp_port_stream(port)); - return sexp_substring(cookie, + return sexp_substring(ctx, + cookie, sexp_make_integer(0), sexp_make_integer(sexp_string_length(cookie))); }