diff --git a/lib/chibi/heap-stats.c b/lib/chibi/heap-stats.c index 921cf401..0790fe51 100644 --- a/lib/chibi/heap-stats.c +++ b/lib/chibi/heap-stats.c @@ -9,7 +9,26 @@ #if ! SEXP_USE_BOEHM extern sexp sexp_gc (sexp ctx, size_t *sum_freed); + +#ifdef __cplusplus +sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x) { + sexp_uint_t res; + sexp t; + if (!sexp_pointerp(x) || (sexp_pointer_tag(x) >= sexp_context_num_types(ctx))) + return sexp_heap_align(1); + t = sexp_object_type(ctx, x); + res = sexp_type_size_of_object(t, x) + SEXP_GC_PAD; +#if SEXP_USE_DEBUG_GC + if (res == 0) { + fprintf(stderr, SEXP_BANNER("%p zero-size object: %p"), ctx, x); + return 1; + } +#endif + return res; +} +#else extern sexp_uint_t sexp_allocated_bytes (sexp ctx, sexp x); +#endif static void sexp_print_simple (sexp ctx, sexp x, sexp out, int depth) { int i; diff --git a/lib/srfi/95/qsort.c b/lib/srfi/95/qsort.c index 10ce14cf..b3fd7b32 100644 --- a/lib/srfi/95/qsort.c +++ b/lib/srfi/95/qsort.c @@ -4,6 +4,10 @@ #include "chibi/eval.h" +#ifdef __cplusplus +namespace { +#endif + #if SEXP_USE_HUFF_SYMS #if SEXP_USE_STATIC_LIBS #include "chibi/sexp-hufftabdefs.h" @@ -12,6 +16,10 @@ #endif #endif +#ifdef __cplusplus +} +#endif + #define swap(tmp_var, a, b) (tmp_var=a, a=b, b=tmp_var) static sexp sexp_vector_copy_to_list (sexp ctx, sexp vec, sexp seq) {