History

FreeBSD fixes

bellard committed 23 years ago

Commit a6c5e2f1 parent dc685c61 file · +20 −0Browse files

Unified · Split

bcheck.c+20−0
@@ -21,7 +21,9 @@ · 20 unmodified lines
2121 #include <stdio.h>
2222 #include <stdarg.h>
2323 #include <string.h>
24+#ifndef __FreeBSD__
2425 #include <malloc.h>
26+#endif
2527
2628 //#define BOUND_DEBUG
2729
@@ -32,6 +34,14 @@ · 4 unmodified lines
3234 /* use malloc hooks. Currently the code cannot be reliable if no hooks */
3335 #define CONFIG_TCC_MALLOC_HOOKS
3436
37+#define HAVE_MEMALIGN
38+
39+#ifdef __FreeBSD__
40+#warning Bound checking not fully supported on FreeBSD
41+#undef CONFIG_TCC_MALLOC_HOOKS
42+#undef HAVE_MEMALIGN
43+#endif
44+
3545 #define BOUND_T1_BITS 13
3646 #define BOUND_T2_BITS 11
3747 #define BOUND_T3_BITS (32 - BOUND_T1_BITS - BOUND_T2_BITS)
@@ -713,10 +723,20 @@ void *__bound_memalign(size_t size, size_t align, const void *caller) · 675 unmodified lines
713723
714724 restore_malloc_hooks();
715725
726+#ifndef HAVE_MEMALIGN
727+ if (align > 4) {
728+ /* XXX: handle it ? */
729+ ptr = NULL;
730+ } else {
731+ /* we suppose that malloc aligns to at least four bytes */
732+ ptr = malloc(size + 1);
733+ }
734+#else
716735 /* we allocate one more byte to ensure the regions will be
717736 separated by at least one byte. With the glibc malloc, it may
718737 be in fact not necessary */
719738 ptr = memalign(size + 1, align);
739+#endif
720740
721741 install_malloc_hooks();
722742

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t