passing correctly adjusted size to munmap when using mmapped heaps

This commit is contained in:
Alex Shinn 2010-06-22 23:09:18 +09:00
parent 00e30bfcaa
commit 9a052ddb7c
10 changed files with 21 additions and 32 deletions

View file

@ -5,6 +5,7 @@ syntax: glob
*.o
*.so
*.dylib
*.class
*.dSYM
*.orig
.hg

View file

@ -16,7 +16,7 @@ Thanks to the following people for patches:
* John Samsa
* Lars J Aas
* Lorenzo Campedelli
* sladegen
* Michal Kowalski (sladegen)
If you would prefer not to be listed, or are one of the users listed
without a full name, please contact me. If you've made a contribution

View file

@ -213,3 +213,10 @@ dist: cleaner
for f in `hg manifest`; do mkdir -p chibi-scheme-`cat VERSION`/`dirname $$f`; ln -s `pwd`/$$f chibi-scheme-`cat VERSION`/$$f; done
tar cphzvf chibi-scheme-`cat VERSION`.tgz chibi-scheme-`cat VERSION`
rm -rf chibi-scheme-`cat VERSION`
mips-dist: cleaner
rm -f chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`.tgz
mkdir chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`
for f in `hg manifest`; do mkdir -p chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`/`dirname $$f`; ln -s `pwd`/$$f chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`/$$f; done
tar cphzvf chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`.tgz chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`
rm -rf chibi-scheme-`date +%Y%m%d`-`hg tags|head -1|sed -n 's/.* \([0-9]*\):.*/\1/p'`

8
gc.c
View file

@ -8,16 +8,8 @@
#include <sys/mman.h>
#endif
#if SEXP_64_BIT
#define sexp_heap_align(n) sexp_align(n, 5)
#else
#define sexp_heap_align(n) sexp_align(n, 4)
#endif
#define SEXP_MINIMUM_OBJECT_SIZE (sexp_heap_align(sexp_sizeof(pair)))
#define sexp_heap_pad_size(s) (sizeof(struct sexp_heap_t) + (s) + sexp_heap_align(1))
#if SEXP_USE_GLOBAL_HEAP
sexp_heap sexp_global_heap;
#endif

View file

@ -113,13 +113,18 @@ enum sexp_types {
typedef unsigned int sexp_tag_t;
typedef unsigned long sexp_uint_t;
typedef long sexp_sint_t;
#define sexp_heap_align(n) sexp_align(n, 5)
#else
typedef unsigned short sexp_tag_t;
typedef unsigned int sexp_uint_t;
typedef int sexp_sint_t;
#define sexp_heap_align(n) sexp_align(n, 4)
#endif
typedef struct sexp_struct *sexp;
#define sexp_heap_pad_size(s) (sizeof(struct sexp_heap_t) + (s) + sexp_heap_align(1))
#define __HALF_MAX_SIGNED(type) ((type)1 << (sizeof(type)*8-2))
#define __MAX_SIGNED(type) (__HALF_MAX_SIGNED(type) - 1 + __HALF_MAX_SIGNED(type))
#define __MIN_SIGNED(type) (-1 - __MAX_SIGNED(type))

View file

@ -115,6 +115,7 @@
(gap buffer-gap buffer-gap-set!)
(width buffer-width buffer-width-set!)
(string buffer-string buffer-string-set!)
(kill-ring buffer-kill-ring buffer-kill-ring-set!)
(history buffer-history buffer-history-set!))
(define default-buffer-size 256)

2
sexp.c
View file

@ -311,7 +311,7 @@ void sexp_destroy_context (sexp ctx) {
for ( ; heap; heap=tmp) {
tmp = heap->next;
#if SEXP_USE_MMAP_GC
munmap(heap, heap->size);
munmap(heap, sexp_heap_pad_size(heap->size));
#else
free(heap);
#endif

View file

@ -11,8 +11,8 @@
(set! *tests-run* (+ *tests-run* 1))
(let ((str (call-with-output-string
(lambda (out)
(write *tests-run*)
(display ". ")
(write *tests-run* out)
(display ". " out)
(display 'expr out))))
(res expr))
(display str)

View file

@ -216,24 +216,6 @@
(test 288 (lcm 32 -36))
;;;; these will fail when compiled either without flonums or trig funcs
;; (test #t (= -5 (floor -4.3)))
;; (test #t (= -4 (ceiling -4.3)))
;; (test #t (= -4 (truncate -4.3)))
;; (test #t (= -4 (round -4.3)))
;; (test #t (= 3 (floor 3.5)))
;; (test #t (= 4 (ceiling 3.5)))
;; (test #t (= 3 (truncate 3.5)))
;; (test #t (= 4 (round 3.5)))
(test 100 (string->number "100"))
(test 256 (string->number "100" 16))

View file

@ -73,6 +73,7 @@
;;
;; Port Types:
;; input-port output-port
;; port-or-fd - an fd-backed port or a fixnum
;;
;; Struct Types:
;;
@ -620,8 +621,8 @@
" return sexp_xtype_exception(ctx, self, \"not a list of "
(type-name type) "s\", " arg ");\n")))
((eq? base-type 'port-or-fd)
(cat "if (! (sexp_portp(" arg ") || sexp_fixnump(" arg ")))\n"
" return sexp_xtype_exception(ctx, self, \"not a port of file descriptor\"," arg ");\n"))
(cat " if (! (sexp_portp(" arg ") || sexp_fixnump(" arg ")))\n"
" return sexp_xtype_exception(ctx, self, \"not a port or file descriptor\"," arg ");\n"))
((or (int-type? base-type)
(float-type? base-type)
(string-type? base-type)