Mercurial > hg > tinycc
changeset 209:69c9680f9fd1
[project @ 2002-12-08 14:34:30 by bellard]
FreeBSD fixes
author | bellard |
---|---|
date | Sun, 08 Dec 2002 14:34:30 +0000 |
parents | 2bbca7c2db60 |
children | d0952d266352 |
files | bcheck.c |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/bcheck.c Sun Dec 08 14:34:02 2002 +0000 +++ b/bcheck.c Sun Dec 08 14:34:30 2002 +0000 @@ -21,7 +21,9 @@ #include <stdio.h> #include <stdarg.h> #include <string.h> +#ifndef __FreeBSD__ #include <malloc.h> +#endif //#define BOUND_DEBUG @@ -32,6 +34,14 @@ /* use malloc hooks. Currently the code cannot be reliable if no hooks */ #define CONFIG_TCC_MALLOC_HOOKS +#define HAVE_MEMALIGN + +#ifdef __FreeBSD__ +#warning Bound checking not fully supported on FreeBSD +#undef CONFIG_TCC_MALLOC_HOOKS +#undef HAVE_MEMALIGN +#endif + #define BOUND_T1_BITS 13 #define BOUND_T2_BITS 11 #define BOUND_T3_BITS (32 - BOUND_T1_BITS - BOUND_T2_BITS) @@ -713,10 +723,20 @@ restore_malloc_hooks(); +#ifndef HAVE_MEMALIGN + if (align > 4) { + /* XXX: handle it ? */ + ptr = NULL; + } else { + /* we suppose that malloc aligns to at least four bytes */ + ptr = malloc(size + 1); + } +#else /* we allocate one more byte to ensure the regions will be separated by at least one byte. With the glibc malloc, it may be in fact not necessary */ ptr = memalign(size + 1, align); +#endif install_malloc_hooks();