linux portability fixes

This commit is contained in:
Alex Shinn 2009-06-21 01:12:20 -04:00
parent 6f9e9c1321
commit b9f4668027
5 changed files with 11 additions and 9 deletions

View file

@ -16,4 +16,4 @@ junk*
gc
gc6.8
chibi-scheme
include/chibi/install.h

View file

@ -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)

4
gc.c
View file

@ -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);
}
}

View file

@ -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)

5
sexp.c
View file

@ -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)));
}