Various fixes for alternate builds.

This commit is contained in:
Alex Shinn 2011-11-04 18:39:26 +09:00
parent 15ff2e69e6
commit 8146be0250
9 changed files with 140 additions and 57 deletions

8
eval.c
View file

@ -1174,14 +1174,14 @@ sexp sexp_register_optimization (sexp ctx sexp_api_params(self, n), sexp f, sexp
#if SEXP_USE_MATH
#if SEXP_USE_BIGNUMS
#define maybe_convert_bignum(z) \
#define maybe_convert_bignum(z) \
else if (sexp_bignump(z)) d = sexp_bignum_to_double(z);
#else
#define maybe_convert_bignum(z)
#endif
#if SEXP_USE_RATIOS
#define maybe_convert_ratio(z) \
#define maybe_convert_ratio(z) \
else if (sexp_ratiop(z)) d = sexp_ratio_to_double(z);
#else
#define maybe_convert_ratio(z)
@ -1224,7 +1224,9 @@ define_math_op(sexp_floor, floor, 0, sexp_complex_dummy)
define_math_op(sexp_ceiling, ceil, 0, sexp_complex_dummy)
sexp sexp_sqrt (sexp ctx sexp_api_params(self, n), sexp z) {
#if SEXP_USE_COMPLEX
int negativep = 0;
#endif
double d, r;
sexp_gc_var1(res);
if (sexp_flonump(z))
@ -1257,7 +1259,7 @@ sexp sexp_sqrt (sexp ctx sexp_api_params(self, n), sexp z) {
return res;
}
#endif
#endif /* SEXP_USE_MATH */
#if SEXP_USE_RATIOS
sexp sexp_generic_expt (sexp ctx, sexp x, sexp_sint_t e) {

31
gc.c
View file

@ -312,7 +312,8 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
}
size = sexp_heap_align(sexp_allocated_bytes(ctx, p));
#if SEXP_USE_DEBUG_GC
sexp_valid_object_p(ctx, p);
if (!sexp_valid_object_p(ctx, p))
fprintf(stderr, SEXP_BANNER("%p sweep: invalid object at %p"), ctx, p);
if ((char*)q + q->size > (char*)p)
fprintf(stderr, SEXP_BANNER("%p sweep: bad size at %p < %p + %lu"),
ctx, p, q, q->size);
@ -366,7 +367,7 @@ sexp sexp_sweep (sexp ctx, size_t *sum_freed_ptr) {
}
#if SEXP_USE_GLOBAL_SYMBOLS
void sexp_mark_global_symbols(ctx) {
void sexp_mark_global_symbols(sexp ctx) {
int i;
for (i=0; i<SEXP_SYMBOL_TABLE_SIZE; i++)
sexp_mark(ctx, sexp_symbol_table[i]);
@ -482,7 +483,10 @@ void* sexp_alloc (sexp ctx, size_t size) {
void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types, sexp flags) {
sexp_sint_t i, off, len, freep, loadp;
sexp_free_list q;
sexp p, t, end, name, *v;
sexp p, t, end, *v;
#if SEXP_USE_DL
sexp name;
#endif
freep = sexp_unbox_fixnum(flags) & sexp_unbox_fixnum(SEXP_COPY_FREEP);
loadp = sexp_unbox_fixnum(flags) & sexp_unbox_fixnum(SEXP_COPY_LOADP);
@ -518,7 +522,9 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
sexp_freep(p) = 0;
/* adjust context heaps, don't copy saved sexp_gc_vars */
if (sexp_contextp(p)) {
#if SEXP_USE_GREEN_THREADS
sexp_context_ip(p) += off;
#endif
sexp_context_last_fp(p) += off;
sexp_stack_top(sexp_context_stack(p)) = 0;
sexp_context_saves(p) = NULL;
@ -560,8 +566,10 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
sexp_port_stream(p) = 0;
sexp_port_openp(p) = 0;
sexp_freep(p) = 0;
#if SEXP_USE_DL
} else if (loadp && sexp_dlp(p)) {
sexp_dl_handle(p) = NULL;
#endif
}
p = (sexp) (((char*)p)+sexp_heap_align(sexp_type_size_of_object(t, p)));
}
@ -578,6 +586,7 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
if ((char*)q == (char*)p) { /* this is a free block, skip it */
p = (sexp) (((char*)p) + q->size);
} else {
#if SEXP_USE_DL
if (sexp_opcodep(p) && sexp_opcode_func(p)) {
name = (sexp_opcode_data2(p) && sexp_stringp(sexp_opcode_data2(p))) ? sexp_opcode_data2(p) : sexp_opcode_name(p);
if (sexp_dlp(sexp_opcode_dl(p))) {
@ -587,9 +596,19 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
} else {
sexp_opcode_func(p) = dlsym(SEXP_RTLD_DEFAULT, sexp_string_data(name));
}
} else if (sexp_typep(p)) {
if (sexp_type_finalize(p))
sexp_type_finalize(p) = sexp_type_tag(p) == SEXP_DL ? sexp_finalize_dl : SEXP_FINALIZE_PORT;
} else
#endif
if (sexp_typep(p)) {
if (sexp_type_finalize(p)) {
/* TODO: handle arbitrary finalizers in images */
#if SEXP_USE_DL
if (sexp_type_tag(p) == SEXP_DL)
sexp_type_finalize(p) = SEXP_FINALIZE_DL;
else
#endif
sexp_type_finalize(p) = SEXP_FINALIZE_PORT;
}
/* TODO: handle arbitrary printers in images */
if (sexp_type_print(p))
sexp_type_print(p) = sexp_write_simple_object;
}

View file

@ -366,23 +366,30 @@
#endif
#ifndef SEXP_USE_EXTENDED_FCALL
#define SEXP_USE_EXTENDED_FCALL ! SEXP_USE_NO_FEATURES
#define SEXP_USE_EXTENDED_FCALL (!SEXP_USE_NO_FEATURES)
#endif
#ifndef SEXP_USE_RATIOS
#define SEXP_USE_RATIOS ! SEXP_USE_NO_FEATURES
#define SEXP_USE_RATIOS (!SEXP_USE_NO_FEATURES)
#endif
#ifndef SEXP_USE_COMPLEX
#define SEXP_USE_COMPLEX ! SEXP_USE_NO_FEATURES
#define SEXP_USE_COMPLEX (!SEXP_USE_NO_FEATURES)
#endif
#ifndef SEXP_USE_BIGNUMS
#define SEXP_USE_BIGNUMS (SEXP_USE_RATIOS || SEXP_USE_COMPLEX)
#define SEXP_USE_BIGNUMS (!SEXP_USE_NO_FEATURES)
#endif
#ifndef SEXP_USE_FLONUMS
#define SEXP_USE_FLONUMS (SEXP_USE_COMPLEX || ! SEXP_USE_NO_FEATURES)
#define SEXP_USE_FLONUMS (!SEXP_USE_NO_FEATURES)
#endif
#if (SEXP_USE_RATIOS || SEXP_USE_COMPLEX)
#undef SEXP_USE_BIGNUMS
#define SEXP_USE_BIGNUMS 1
#undef SEXP_USE_FLONUMS
#define SEXP_USE_FLONUMS 1
#endif
#ifndef SEXP_USE_INFINITIES
@ -418,7 +425,7 @@
#endif
#ifndef SEXP_USE_OBJECT_BRACE_LITERALS
#define SEXP_USE_OBJECT_BRACE_LITERALS ! SEXP_USE_NO_FEATURES
#define SEXP_USE_OBJECT_BRACE_LITERALS (SEXP_USE_TYPE_DEFS && !SEXP_USE_NO_FEATURES)
#endif
#ifndef SEXP_USE_BYTEVECTOR_LITERALS
@ -527,7 +534,7 @@
#endif
#ifndef SEXP_USE_IMAGE_LOADING
#define SEXP_USE_IMAGE_LOADING SEXP_USE_DL && !SEXP_USE_BOEHM && !SEXP_USE_NO_FEATURES
#define SEXP_USE_IMAGE_LOADING SEXP_USE_DL && !SEXP_USE_GLOBAL_HEAP && !SEXP_USE_BOEHM && !SEXP_USE_NO_FEATURES
#endif
#if SEXP_USE_NATIVE_X86

View file

@ -693,9 +693,15 @@ SEXP_API sexp sexp_make_unsigned_integer(sexp ctx, sexp_luint_t x);
else if (sexp_fixnump(x)) \
x = sexp_fx_neg(x);
#if SEXP_USE_IMMEDIATE_FLONUMS
#define sexp_negate_flonum(x) (x) = sexp_make_flonum(NULL, -(sexp_flonum_value(x)))
#else
#define sexp_negate_flonum(x) sexp_flonum_value(x) = -(sexp_flonum_value(x))
#endif
#define sexp_negate(x) \
if (sexp_flonump(x)) \
sexp_flonum_value(x) = -sexp_flonum_value(x); \
sexp_negate_flonum(x); \
else \
sexp_negate_exact(x)

View file

@ -473,10 +473,10 @@ double sexp_ratio_to_double (sexp rat) {
sexp sexp_double_to_ratio (sexp ctx, double f) {
int sign, i;
sexp_gc_var4(res, whole, scale, tmp);
sexp_gc_var3(res, whole, scale);
if (f == trunc(f))
return sexp_double_to_bignum(ctx, f);
sexp_gc_preserve4(ctx, res, whole, scale, tmp);
sexp_gc_preserve3(ctx, res, whole, scale);
whole = sexp_double_to_bignum(ctx, trunc(f));
res = sexp_fixnum_to_bignum(ctx, SEXP_ZERO);
scale = SEXP_ONE;
@ -492,7 +492,7 @@ sexp sexp_double_to_ratio (sexp ctx, double f) {
res = sexp_make_ratio(ctx, res, scale);
res = sexp_ratio_normalize(ctx, res, SEXP_FALSE);
res = sexp_add(ctx, res, whole);
sexp_gc_release4(ctx);
sexp_gc_release3(ctx);
return res;
}
@ -605,8 +605,6 @@ sexp sexp_complex_div (sexp ctx, sexp a, sexp b) {
return sexp_complex_normalize(res);
}
#if SEXP_USE_MATH
static double sexp_to_double (sexp x) {
if (sexp_flonump(x))
return sexp_flonum_value(x);
@ -623,33 +621,24 @@ static double sexp_to_double (sexp x) {
}
static sexp sexp_to_complex (sexp ctx, sexp x) {
#if SEXP_USE_RATIOS
sexp_gc_var1(tmp);
#endif
if (sexp_flonump(x) || sexp_fixnump(x) || sexp_bignump(x)) {
return sexp_make_complex(ctx, x, SEXP_ZERO);
#if SEXP_USE_RATIOS
} else if (sexp_ratiop(x)) {
sexp_gc_preserve1(ctx, tmp);
tmp = sexp_make_complex(ctx, SEXP_ZERO, SEXP_ZERO);
sexp_complex_real(tmp) = sexp_make_flonum(ctx, sexp_to_double(x));
sexp_gc_release1(ctx);
return tmp;
#endif
} else {
return x;
}
}
sexp sexp_complex_sqrt (sexp ctx, sexp z) {
double x = sexp_to_double(sexp_complex_real(z)),
y = sexp_to_double(sexp_complex_imag(z)), r;
sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res);
r = sqrt(x*x + y*y);
res = sexp_make_complex(ctx, SEXP_ZERO, SEXP_ZERO);
sexp_complex_real(res) = sexp_make_flonum(ctx, sqrt((x+r)/2));
sexp_complex_imag(res) = sexp_make_flonum(ctx, (y<0?-1:1)*sqrt((-x+r)/2));
sexp_gc_release1(ctx);
return res;
}
sexp sexp_complex_exp (sexp ctx, sexp z) {
double x = sexp_to_double(sexp_complex_real(z)),
y = sexp_to_double(sexp_complex_imag(z));
@ -662,6 +651,18 @@ sexp sexp_complex_exp (sexp ctx, sexp z) {
return res;
}
sexp sexp_complex_log (sexp ctx, sexp z) {
double x = sexp_to_double(sexp_complex_real(z)),
y = sexp_to_double(sexp_complex_imag(z));
sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res);
res = sexp_make_complex(ctx, SEXP_ZERO, SEXP_ZERO);
sexp_complex_real(res) = sexp_make_flonum(ctx, log(sqrt(x*x + y*y)));
sexp_complex_imag(res) = sexp_make_flonum(ctx, atan2(y, x));
sexp_gc_release1(ctx);
return res;
}
sexp sexp_complex_expt (sexp ctx, sexp a, sexp b) {
sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res);
@ -673,14 +674,17 @@ sexp sexp_complex_expt (sexp ctx, sexp a, sexp b) {
return res;
}
sexp sexp_complex_log (sexp ctx, sexp z) {
#if SEXP_USE_MATH
sexp sexp_complex_sqrt (sexp ctx, sexp z) {
double x = sexp_to_double(sexp_complex_real(z)),
y = sexp_to_double(sexp_complex_imag(z));
y = sexp_to_double(sexp_complex_imag(z)), r;
sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res);
r = sqrt(x*x + y*y);
res = sexp_make_complex(ctx, SEXP_ZERO, SEXP_ZERO);
sexp_complex_real(res) = sexp_make_flonum(ctx, log(sqrt(x*x + y*y)));
sexp_complex_imag(res) = sexp_make_flonum(ctx, atan2(y, x));
sexp_complex_real(res) = sexp_make_flonum(ctx, sqrt((x+r)/2));
sexp_complex_imag(res) = sexp_make_flonum(ctx, (y<0?-1:1)*sqrt((-x+r)/2));
sexp_gc_release1(ctx);
return res;
}
@ -923,9 +927,11 @@ sexp sexp_add (sexp ctx, sexp a, sexp b) {
break;
#endif
#if SEXP_USE_COMPLEX
#if SEXP_USE_RATIOS
case SEXP_NUM_RAT_CPX:
a = tmp = sexp_make_flonum(ctx, sexp_ratio_to_double(a));
/* ... FALLTHROUGH ... */
#endif
case SEXP_NUM_FLO_CPX:
case SEXP_NUM_FIX_CPX:
case SEXP_NUM_BIG_CPX:
@ -1026,12 +1032,14 @@ sexp sexp_sub (sexp ctx, sexp a, sexp b) {
break;
#endif
#if SEXP_USE_COMPLEX
#if SEXP_USE_RATIOS
case SEXP_NUM_RAT_CPX:
a = tmp1 = sexp_make_flonum(ctx, sexp_ratio_to_double(a));
goto complex_sub;
case SEXP_NUM_CPX_RAT:
b = tmp1 = sexp_make_flonum(ctx, sexp_ratio_to_double(b));
/* ... FALLTHROUGH ... */
#endif
case SEXP_NUM_CPX_FLO:
case SEXP_NUM_CPX_FIX:
case SEXP_NUM_CPX_BIG:
@ -1044,7 +1052,9 @@ sexp sexp_sub (sexp ctx, sexp a, sexp b) {
a = tmp1 = sexp_make_complex(ctx, a, SEXP_ZERO);
/* ... FALLTHROUGH ... */
case SEXP_NUM_CPX_CPX:
#if SEXP_USE_RATIOS
complex_sub:
#endif
r = sexp_complex_sub(ctx, a, b);
if (negatep) {
if (sexp_complexp(r)) {
@ -1107,8 +1117,11 @@ sexp sexp_mul (sexp ctx, sexp a, sexp b) {
break;
#endif
#if SEXP_USE_COMPLEX
#if SEXP_USE_RATIOS
case SEXP_NUM_RAT_CPX:
a = tmp = sexp_make_flonum(ctx, sexp_ratio_to_double(a));
/* ... FALLTHROUGH ... */
#endif
case SEXP_NUM_FLO_CPX:
case SEXP_NUM_FIX_CPX:
case SEXP_NUM_BIG_CPX:
@ -1129,8 +1142,8 @@ sexp sexp_div (sexp ctx, sexp a, sexp b) {
double f;
#endif
sexp r=SEXP_VOID;
sexp_gc_var2(tmp, rem);
sexp_gc_preserve2(ctx, tmp, rem);
sexp_gc_var1(tmp);
sexp_gc_preserve1(ctx, tmp);
switch ((at * SEXP_NUM_NUMBER_TYPES) + bt) {
case SEXP_NUM_NOT_NOT: case SEXP_NUM_NOT_FIX:
case SEXP_NUM_NOT_FLO: case SEXP_NUM_NOT_BIG:
@ -1189,8 +1202,8 @@ sexp sexp_div (sexp ctx, sexp a, sexp b) {
tmp = sexp_make_ratio(ctx, a, b);
r = sexp_ratio_normalize(ctx, tmp, SEXP_FALSE);
#else
r = sexp_bignum_quot_rem(ctx, &rem, a, b);
if (sexp_bignum_normalize(rem) != SEXP_ZERO)
r = sexp_bignum_quot_rem(ctx, &tmp, a, b);
if (sexp_bignum_normalize(tmp) != SEXP_ZERO)
r = sexp_make_flonum(ctx, sexp_bignum_to_double(a)
/ sexp_bignum_to_double(b));
else
@ -1210,6 +1223,7 @@ sexp sexp_div (sexp ctx, sexp a, sexp b) {
case SEXP_NUM_RAT_FIX:
case SEXP_NUM_RAT_BIG:
b = tmp = sexp_make_ratio(ctx, b, SEXP_ONE);
/* ... FALLTHROUGH ... */
case SEXP_NUM_FIX_RAT:
case SEXP_NUM_BIG_RAT:
if (!sexp_ratiop(a))
@ -1220,15 +1234,22 @@ sexp sexp_div (sexp ctx, sexp a, sexp b) {
break;
#endif
#if SEXP_USE_COMPLEX
#if SEXP_USE_RATIOS
case SEXP_NUM_CPX_RAT:
b = tmp = sexp_make_flonum(ctx, sexp_ratio_to_double(b));
/* ... FALLTHROUGH ... */
#endif
case SEXP_NUM_CPX_FLO:
case SEXP_NUM_CPX_FIX:
case SEXP_NUM_CPX_BIG:
b = tmp = sexp_make_complex(ctx, b, SEXP_ZERO);
/* ... FALLTHROUGH ... */
#if SEXP_USE_RATIOS
case SEXP_NUM_RAT_CPX:
if (sexp_ratiop(a))
a = tmp = sexp_make_flonum(ctx, sexp_ratio_to_double(a));
/* ... FALLTHROUGH ... */
#endif
case SEXP_NUM_FLO_CPX:
case SEXP_NUM_FIX_CPX:
case SEXP_NUM_BIG_CPX:
@ -1240,7 +1261,7 @@ sexp sexp_div (sexp ctx, sexp a, sexp b) {
break;
#endif
}
sexp_gc_release2(ctx);
sexp_gc_release1(ctx);
return r;
}
@ -1264,7 +1285,10 @@ sexp sexp_quotient (sexp ctx, sexp a, sexp b) {
#endif
#if SEXP_USE_COMPLEX
case SEXP_NUM_FLO_CPX: case SEXP_NUM_CPX_FIX: case SEXP_NUM_CPX_FLO:
case SEXP_NUM_CPX_BIG: case SEXP_NUM_CPX_RAT: case SEXP_NUM_CPX_CPX:
case SEXP_NUM_CPX_BIG: case SEXP_NUM_CPX_CPX:
#if SEXP_USE_RATIOS
case SEXP_NUM_CPX_RAT:
#endif
#endif
r = sexp_type_exception(ctx, NULL, SEXP_FIXNUM, a);
break;
@ -1314,7 +1338,10 @@ sexp sexp_remainder (sexp ctx, sexp a, sexp b) {
#endif
#if SEXP_USE_COMPLEX
case SEXP_NUM_FLO_CPX: case SEXP_NUM_CPX_FIX: case SEXP_NUM_CPX_FLO:
case SEXP_NUM_CPX_BIG: case SEXP_NUM_CPX_RAT: case SEXP_NUM_CPX_CPX:
case SEXP_NUM_CPX_BIG: case SEXP_NUM_CPX_CPX:
#if SEXP_USE_RATIOS
case SEXP_NUM_CPX_RAT:
#endif
#endif
r = sexp_type_exception(ctx, NULL, SEXP_FIXNUM, a);
break;
@ -1358,8 +1385,11 @@ sexp sexp_compare (sexp ctx, sexp a, sexp b) {
case SEXP_NUM_NOT_NOT: case SEXP_NUM_NOT_FIX:
case SEXP_NUM_NOT_FLO: case SEXP_NUM_NOT_BIG:
#if SEXP_USE_COMPLEX
case SEXP_NUM_CPX_CPX: case SEXP_NUM_CPX_FIX: case SEXP_NUM_CPX_RAT:
case SEXP_NUM_CPX_CPX: case SEXP_NUM_CPX_FIX:
case SEXP_NUM_CPX_FLO: case SEXP_NUM_CPX_BIG:
#if SEXP_USE_RATIOS
case SEXP_NUM_CPX_RAT:
#endif
#endif
r = sexp_type_exception(ctx, NULL, SEXP_NUMBER, a);
break;

30
sexp.c
View file

@ -135,6 +135,9 @@ sexp sexp_finalize_dl (sexp ctx sexp_api_params(self, n), sexp dl) {
dlclose(sexp_dl_handle(dl));
return SEXP_VOID;
}
#define SEXP_FINALIZE_DL sexp_finalize_dl
#else
#define SEXP_FINALIZE_DL NULL
#endif
static struct sexp_type_struct _sexp_type_specs[] = {
@ -171,7 +174,7 @@ static struct sexp_type_struct _sexp_type_specs[] = {
{SEXP_BYTECODE, sexp_offsetof(bytecode, name), 3, 3, 0, 0, sexp_sizeof(bytecode), offsetof(struct sexp_struct, value.bytecode.length), 1, 0, 0, 0, 0, 0, 0, (sexp)"Bytecode", SEXP_FALSE, SEXP_FALSE, NULL, SEXP_FALSE, NULL, NULL},
{SEXP_CORE, sexp_offsetof(core, name), 1, 1, 0, 0, sexp_sizeof(core), 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Core-Form", SEXP_FALSE, SEXP_FALSE, NULL, SEXP_FALSE, NULL, NULL},
#if SEXP_USE_DL
{SEXP_DL, sexp_offsetof(dl, file), 1, 1, 0, 0, sexp_sizeof(dl), 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Dynamic-Library", SEXP_FALSE, SEXP_FALSE, NULL, SEXP_FALSE, sexp_finalize_dl, NULL},
{SEXP_DL, sexp_offsetof(dl, file), 1, 1, 0, 0, sexp_sizeof(dl), 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Dynamic-Library", SEXP_FALSE, SEXP_FALSE, NULL, SEXP_FALSE, SEXP_FINALIZE_DL, NULL},
#endif
{SEXP_OPCODE, sexp_offsetof(opcode, name), 8+SEXP_USE_DL, 8+SEXP_USE_DL, 0, 0, sexp_sizeof(opcode), 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Opcode", SEXP_FALSE, SEXP_FALSE, NULL, SEXP_FALSE, NULL, NULL},
{SEXP_LAMBDA, sexp_offsetof(lambda, name), 11, 11, 0, 0, sexp_sizeof(lambda), 0, 0, 0, 0, 0, 0, 0, 0, (sexp)"Lambda", SEXP_FALSE, SEXP_FALSE, NULL, SEXP_FALSE, NULL, (sexp_proc4)sexp_write_simple_object},
@ -243,7 +246,9 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
sexp_type_name(type) = name;
sexp_type_finalize(type) = f;
sexp_type_id(type) = SEXP_FALSE;
#if SEXP_USE_DL
if (f) sexp_type_dl(type) = sexp_context_dl(ctx);
#endif
sexp_type_print(type) = p;
if (sexp_typep(parent)) {
len = sexp_vectorp(sexp_type_cpl(parent)) ? sexp_vector_length(sexp_type_cpl(parent)) : 1;
@ -874,7 +879,11 @@ sexp sexp_string_index_to_offset (sexp ctx sexp_api_params(self, n), sexp str, s
sexp sexp_make_string_op (sexp ctx sexp_api_params(self, n), sexp len, sexp ch)
{
sexp i = (sexp_charp(ch) ? sexp_make_fixnum(sexp_unbox_character(ch)) : ch);
#if SEXP_USE_PACKED_STRINGS
sexp b;
#else
sexp_gc_var2(b, s);
#endif
#if SEXP_USE_UTF8_STRINGS
int j, clen;
if (sexp_charp(ch) && (sexp_unbox_character(ch) >= 0x80)) {
@ -989,18 +998,22 @@ static sexp_uint_t sexp_string_hash(const char *str, sexp_sint_t len,
sexp sexp_intern(sexp ctx, const char *str, sexp_sint_t len) {
#if SEXP_USE_HUFF_SYMS
struct sexp_huff_entry he;
sexp_uint_t space=3, newbits;
sexp_sint_t space, newbits;
char c;
#endif
sexp_uint_t res=FNV_OFFSET_BASIS, bucket, i=0;
const char *p=str;
sexp ls, tmp;
sexp_gc_var1(sym);
sexp_sint_t bucket=0;
#if (SEXP_USE_HASH_SYMS || SEXP_USE_HUFF_SYMS)
sexp_sint_t i=0, res=FNV_OFFSET_BASIS;
const char *p=str;
#endif
if (len < 0) len = strlen(str);
#if SEXP_USE_HUFF_SYMS
res = 0;
space = 3;
if (len == 0) goto normal_intern;
for ( ; i<len; i++, p++) {
c = *p;
@ -1019,8 +1032,6 @@ sexp sexp_intern(sexp ctx, const char *str, sexp_sint_t len) {
#endif
#if SEXP_USE_HASH_SYMS
bucket = (sexp_string_hash(p, len-i, res) % SEXP_SYMBOL_TABLE_SIZE);
#else
bucket = 0;
#endif
for (ls=sexp_context_symbols(ctx)[bucket]; sexp_pairp(ls); ls=sexp_cdr(ls))
if ((sexp_symbol_length(tmp=sexp_car(ls)) == len)
@ -1789,6 +1800,7 @@ sexp sexp_read_complex_tail (sexp ctx, sexp in, double real, int exactp) {
int c = sexp_read_char(ctx, in), c2;
sexp_gc_var1(res);
sexp_gc_preserve1(ctx, res);
res = SEXP_VOID;
if (c=='i' || c=='I') {
trailing_i:
c = sexp_read_char(ctx, in);
@ -1923,7 +1935,7 @@ sexp sexp_read_number (sexp ctx, sexp in, int base) {
}
#if SEXP_USE_COMPLEX
if (c == 'i' || c == 'I') whole = 1.0;
if (c == 'i' || c == 'I') val = 1;
#endif
for ( ; sexp_isxdigit(c); c=sexp_read_char(ctx, in)) {
@ -2209,8 +2221,10 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
if (sexp_flonump(res))
#if SEXP_USE_RATIOS
res = sexp_double_to_ratio(ctx, sexp_flonum_value(res));
#else
#elif SEXP_USE_BIGNUMS
res = sexp_bignum_normalize(sexp_double_to_bignum(ctx, sexp_flonum_value(res)));
#else
res = sexp_make_fixnum(sexp_flonum_value(res));
#endif
break;
case 'i': case 'I':

View file

@ -2,13 +2,15 @@ CPPFLAGS=-DSEXP_USE_MODULES=0
CPPFLAGS=-DSEXP_USE_DL=0
CPPFLAGS=-DSEXP_USE_SIMPLIFY=0
CPPFLAGS=-DSEXP_USE_TYPE_DEFS=0
SEXP_USE_BOEHM=1
SEXP_USE_BOEHM=1;CPPFLAGS=-I/opt/local/include;LDFLAGS=-L/opt/local/lib
CPPFLAGS=-DSEXP_USE_DEBUG_GC=1
CPPFLAGS=-DSEXP_USE_GLOBAL_HEAP=1
CPPFLAGS=-DSEXP_USE_GLOBAL_SYMBOLS=1
CPPFLAGS=-DSEXP_USE_FLONUMS=0
CPPFLAGS=-DSEXP_USE_IMMEDIATE_FLONUMS=1
CPPFLAGS=-DSEXP_USE_BIGNUMS=0
CPPFLAGS=-DSEXP_USE_COMPLEX=0
CPPFLAGS=-DSEXP_USE_RATIOS=0
CPPFLAGS=-DSEXP_USE_MATH=0
CPPFLAGS=-DSEXP_WARN_UNDEFS=0
CPPFLAGS=-DSEXP_USE_HUFF_SYMS=0

View file

@ -14,7 +14,8 @@ FAILURES=0
MAKE=${MAKE:-make}
i=0
for opts in `cat ${BUILDDIR}/build-opts.txt`; do
for opts in $(cat ${BUILDDIR}/build-opts.txt); do
opts=${opts//;/ }
$MAKE cleaner 2>&1 >/dev/null
if $MAKE $opts chibi-scheme 2>&1 >${BUILDDIR}/build${i}-make.out; then
if $MAKE test 2>&1 | tee ${BUILDDIR}/build${i}-test.out | grep -q -E 'FAIL|ERROR'; then

2
vm.c
View file

@ -2,6 +2,8 @@
/* Copyright (c) 2009-2011 Alex Shinn. All rights reserved. */
/* BSD-style license: http://synthcode.com/license.txt */
#include <errno.h>
#if SEXP_USE_DEBUG_VM > 1
static void sexp_print_stack (sexp ctx, sexp *stack, int top, int fp, sexp out) {
int i;