mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
linux portability fixes
This commit is contained in:
parent
6f9e9c1321
commit
b9f4668027
5 changed files with 11 additions and 9 deletions
|
@ -16,4 +16,4 @@ junk*
|
||||||
gc
|
gc
|
||||||
gc6.8
|
gc6.8
|
||||||
chibi-scheme
|
chibi-scheme
|
||||||
|
include/chibi/install.h
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -37,12 +37,13 @@ endif
|
||||||
|
|
||||||
ifdef USE_BOEHM
|
ifdef USE_BOEHM
|
||||||
GCLDFLAGS := -lgc
|
GCLDFLAGS := -lgc
|
||||||
|
CPPFLAGS := $(CPPFLAGS) -Iinclude -DUSE_BOEHM=1
|
||||||
else
|
else
|
||||||
GCLDFLAGS :=
|
GCLDFLAGS :=
|
||||||
|
CPPFLAGS := $(CPPFLAGS) -Iinclude
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LDFLAGS := $(LDFLAGS) -lm
|
LDFLAGS := $(LDFLAGS) -lm
|
||||||
CPPFLAGS := $(CPPFLAGS) -Iinclude
|
|
||||||
CFLAGS := $(CFLAGS) -Wall -O2 -g
|
CFLAGS := $(CFLAGS) -Wall -O2 -g
|
||||||
|
|
||||||
INCLUDES = include/chibi/sexp.h include/chibi/config.h include/chibi/install.h
|
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 $@ $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
libchibi-scheme$(SO): eval.o sexp.o
|
libchibi-scheme$(SO): eval.o sexp.o
|
||||||
$(CC) -dynamiclib -o $@ $^
|
$(CC) $(CLIBFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS)
|
||||||
|
|
||||||
chibi-scheme$(EXE): main.o libchibi-scheme$(SO)
|
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
|
chibi-scheme-static$(EXE): main.o eval.o sexp.o
|
||||||
$(CC) $(CFLAGS) $(STATICFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS)
|
$(CC) $(CFLAGS) $(STATICFLAGS) -o $@ $^ $(LDFLAGS) $(GCLDFLAGS)
|
||||||
|
|
4
gc.c
4
gc.c
|
@ -154,7 +154,7 @@ sexp_heap sexp_make_heap (size_t size) {
|
||||||
sexp free, next;
|
sexp free, next;
|
||||||
sexp_heap h = (sexp_heap) malloc(sizeof(struct sexp_heap) + size);
|
sexp_heap h = (sexp_heap) malloc(sizeof(struct sexp_heap) + size);
|
||||||
if (! h) {
|
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);
|
exit(70);
|
||||||
}
|
}
|
||||||
h->size = size;
|
h->size = size;
|
||||||
|
@ -222,7 +222,7 @@ void* sexp_alloc (sexp ctx, size_t size) {
|
||||||
sexp_grow_heap(ctx, size);
|
sexp_grow_heap(ctx, size);
|
||||||
res = sexp_try_alloc(ctx, size);
|
res = sexp_try_alloc(ctx, size);
|
||||||
if (! res) {
|
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);
|
exit(70);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ struct sexp_struct {
|
||||||
#define sexp_gc_preserve(ctx, x, y)
|
#define sexp_gc_preserve(ctx, x, y)
|
||||||
#define sexp_gc_release(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(ctx, size) GC_malloc(size)
|
||||||
#define sexp_alloc_atomic(ctx, size) GC_malloc_atomic(size)
|
#define sexp_alloc_atomic(ctx, size) GC_malloc_atomic(size)
|
||||||
#define sexp_realloc(ctx, x, size) GC_realloc(x, size)
|
#define sexp_realloc(ctx, x, size) GC_realloc(x, size)
|
||||||
|
|
5
sexp.c
5
sexp.c
|
@ -629,7 +629,7 @@ sexp sexp_make_input_string_port (sexp ctx, sexp str) {
|
||||||
sexp sexp_make_output_string_port (sexp ctx) {
|
sexp sexp_make_output_string_port (sexp ctx) {
|
||||||
FILE *out;
|
FILE *out;
|
||||||
sexp buf = sexp_alloc_type(ctx, string, SEXP_STRING), res;
|
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);
|
res = sexp_make_input_port(ctx, out, SEXP_FALSE);
|
||||||
sexp_port_cookie(res) = buf;
|
sexp_port_cookie(res) = buf;
|
||||||
return res;
|
return res;
|
||||||
|
@ -638,7 +638,8 @@ sexp sexp_make_output_string_port (sexp ctx) {
|
||||||
sexp sexp_get_output_string (sexp ctx, sexp port) {
|
sexp sexp_get_output_string (sexp ctx, sexp port) {
|
||||||
sexp cookie = sexp_port_cookie(port);
|
sexp cookie = sexp_port_cookie(port);
|
||||||
fflush(sexp_port_stream(port));
|
fflush(sexp_port_stream(port));
|
||||||
return sexp_substring(cookie,
|
return sexp_substring(ctx,
|
||||||
|
cookie,
|
||||||
sexp_make_integer(0),
|
sexp_make_integer(0),
|
||||||
sexp_make_integer(sexp_string_length(cookie)));
|
sexp_make_integer(sexp_string_length(cookie)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue