diff options
| author | grischka <grischka> | 2009-12-19 22:22:43 +0100 |
|---|---|---|
| committer | grischka <grischka> | 2009-12-19 22:22:43 +0100 |
| commit | 7fa712e00c5221d9373e8f8fa073e9e6fa064da1 (patch) | |
| tree | 21c5acbfcb4ddaa6d61d30fe79cfaece3ff7b5d9 /lib/bcheck.c | |
| parent | 8bbde91f62291cb0383c2406ae6123be903c944b (diff) | |
| download | tinycc-7fa712e00c5221d9373e8f8fa073e9e6fa064da1.tar.gz tinycc-7fa712e00c5221d9373e8f8fa073e9e6fa064da1.tar.bz2 | |
win32: enable bounds checker & exception handler
exception handler borrowed from k1w1. Thanks.
Diffstat (limited to 'lib/bcheck.c')
| -rw-r--r-- | lib/bcheck.c | 43 |
1 files changed, 9 insertions, 34 deletions
diff --git a/lib/bcheck.c b/lib/bcheck.c index 90590f5..09f2a3a 100644 --- a/lib/bcheck.c +++ b/lib/bcheck.c @@ -33,12 +33,11 @@ /* use malloc hooks. Currently the code cannot be reliable if no hooks */ #define CONFIG_TCC_MALLOC_HOOKS - #define HAVE_MEMALIGN #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__dietlibc__) \ - || defined(__UCLIBC__) || defined(__OpenBSD__) -#warning Bound checking not fully supported in this environment. + || defined(__UCLIBC__) || defined(__OpenBSD__) || defined(_WIN32) +#warning Bound checking does not support malloc (etc.) in this environment. #undef CONFIG_TCC_MALLOC_HOOKS #undef HAVE_MEMALIGN #endif @@ -152,9 +151,6 @@ static void bound_alloc_error(void) bound_error("not enough memory for bound checking code"); } -/* currently, tcc cannot compile that because we use GNUC extensions */ -#if !defined(__TINYC__) - /* return '(p + offset)' for pointer arithmetic (a pointer can reach the end of a region in this case */ void * FASTCALL __bound_ptr_add(void *p, int offset) @@ -203,6 +199,13 @@ void * FASTCALL __bound_ptr_indir ## dsize (void *p, int offset) \ return p + offset; \ } +BOUND_PTR_INDIR(1) +BOUND_PTR_INDIR(2) +BOUND_PTR_INDIR(4) +BOUND_PTR_INDIR(8) +BOUND_PTR_INDIR(12) +BOUND_PTR_INDIR(16) + #ifdef __i386__ /* return the frame pointer of the caller */ #define GET_CALLER_FP(fp)\ @@ -246,34 +249,6 @@ void FASTCALL __bound_local_delete(void *p1) } } -#else - -void __bound_local_new(void *p) -{ -} -void __bound_local_delete(void *p) -{ -} - -void *__bound_ptr_add(void *p, int offset) -{ - return p + offset; -} - -#define BOUND_PTR_INDIR(dsize) \ -void *__bound_ptr_indir ## dsize (void *p, int offset) \ -{ \ - return p + offset; \ -} -#endif - -BOUND_PTR_INDIR(1) -BOUND_PTR_INDIR(2) -BOUND_PTR_INDIR(4) -BOUND_PTR_INDIR(8) -BOUND_PTR_INDIR(12) -BOUND_PTR_INDIR(16) - static BoundEntry *__bound_new_page(void) { BoundEntry *page; |
