From 91efc04852a9f575ad431347382ee12d45c34fbd Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 1 Nov 2009 17:17:06 +0900 Subject: [PATCH] fixes for 64-bit machines --- gc.c | 4 ++++ include/chibi/config.h | 8 ++++++++ sexp.c | 6 +++--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index ca6d0136..bb50dd39 100644 --- a/gc.c +++ b/gc.c @@ -9,7 +9,11 @@ #define SEXP_MINIMUM_OBJECT_SIZE (sexp_sizeof(pair)) #define SEXP_GROW_HEAP_RATIO 0.7 +#if SEXP_64_BIT +#define sexp_heap_align(n) sexp_align(n, 5) +#else #define sexp_heap_align(n) sexp_align(n, 4) +#endif typedef struct sexp_free_list *sexp_free_list; struct sexp_free_list { diff --git a/include/chibi/config.h b/include/chibi/config.h index 96d64a58..834c3ea2 100644 --- a/include/chibi/config.h +++ b/include/chibi/config.h @@ -48,6 +48,14 @@ /* DEFAULTS - DO NOT MODIFY ANYTHING BELOW THIS LINE */ /************************************************************************/ +#ifndef SEXP_64_BIT +#if defined(__amd64) || defined(__x86_64) +#define SEXP_64_BIT 1 +#else +#define SEXP_64_BIT 0 +#endif +#endif + #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__DragonFly__) || defined(__OpenBSD__) #define SEXP_BSD 1 #else diff --git a/sexp.c b/sexp.c index 3b057044..d0a4a3ae 100644 --- a/sexp.c +++ b/sexp.c @@ -71,9 +71,9 @@ static struct sexp_struct sexp_type_specs[] = { _DEF_TYPE(SEXP_PAIR, sexp_offsetof(pair, car), 3, 0, 0, sexp_sizeof(pair), 0, 0, "pair"), _DEF_TYPE(SEXP_SYMBOL, sexp_offsetof(symbol, string), 1, 0, 0, sexp_sizeof(symbol), 0, 0, "symbol"), _DEF_TYPE(SEXP_STRING, 0, 0, 0, 0, sexp_sizeof(string)+1, sexp_offsetof(string, length), 1, "string"), - _DEF_TYPE(SEXP_VECTOR, sexp_offsetof(vector, data), 0, sexp_offsetof(vector, length), 1, sexp_sizeof(vector), sexp_offsetof(vector, length), 4, "vector"), + _DEF_TYPE(SEXP_VECTOR, sexp_offsetof(vector, data), 0, sexp_offsetof(vector, length), 1, sexp_sizeof(vector), sexp_offsetof(vector, length), sizeof(sexp), "vector"), _DEF_TYPE(SEXP_FLONUM, 0, 0, 0, 0, sexp_sizeof(flonum), 0, 0, "flonum"), - _DEF_TYPE(SEXP_BIGNUM, 0, 0, 0, 0, sexp_sizeof(bignum), sexp_offsetof(bignum, length), 4, "bignum"), + _DEF_TYPE(SEXP_BIGNUM, 0, 0, 0, 0, sexp_sizeof(bignum), sexp_offsetof(bignum, length), sizeof(sexp), "bignum"), _DEF_TYPE(SEXP_CPOINTER, 0, 0, 0, 0, sexp_sizeof(cpointer), 0, 0, "cpointer"), _DEF_TYPE(SEXP_IPORT, sexp_offsetof(port, name), 2, 0, 0, sexp_sizeof(port), 0, 0, "input-port"), _DEF_TYPE(SEXP_OPORT, sexp_offsetof(port, name), 2, 0, 0, sexp_sizeof(port), 0, 0, "output-port"), @@ -91,7 +91,7 @@ static struct sexp_struct sexp_type_specs[] = { _DEF_TYPE(SEXP_SET, sexp_offsetof(set, var), 2, 0, 0, sexp_sizeof(set), 0, 0, "set!"), _DEF_TYPE(SEXP_SEQ, sexp_offsetof(seq, ls), 1, 0, 0, sexp_sizeof(seq), 0, 0, "sequence"), _DEF_TYPE(SEXP_LIT, sexp_offsetof(lit, value), 1, 0, 0, sexp_sizeof(lit), 0, 0, "literal"), - _DEF_TYPE(SEXP_STACK, sexp_offsetof(stack, data), 1, sexp_offsetof(stack, top), 1, sexp_sizeof(stack), offsetof(struct sexp_struct, value.stack.length), 4, "stack"), + _DEF_TYPE(SEXP_STACK, sexp_offsetof(stack, data), 1, sexp_offsetof(stack, top), 1, sexp_sizeof(stack), offsetof(struct sexp_struct, value.stack.length), sizeof(sexp), "stack"), _DEF_TYPE(SEXP_CONTEXT, sexp_offsetof(context, bc), 6, 0, 0, sexp_sizeof(context), 0, 0, "context"), };