Define a new token to simplify checking whether fence_malloc() actually
can catch out-of-bounds access.
This will be used in the future to skip tests that rely on fence_malloc
checking functionality.
Changes in v2:
- #define FENCE_MALLOC_ACTIVE always, but change its value to help catch
use of it without including utils.h
Signed-off-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Ben Avison <bavison@riscosopen.org>
int n_bytes;
} info_t;
-#if defined(HAVE_MPROTECT) && defined(HAVE_GETPAGESIZE) && defined(HAVE_SYS_MMAN_H) && defined(HAVE_MMAP)
+#if FENCE_MALLOC_ACTIVE
/* This is apparently necessary on at least OS X */
#ifndef MAP_ANONYMOUS
munmap (info->addr, info->n_bytes);
}
-#else
+#else /* FENCE_MALLOC_ACTIVE */
void *
fence_malloc (int64_t len)
free (data);
}
-#endif
+#endif /* FENCE_MALLOC_ACTIVE */
uint8_t *
make_random_bytes (int n_bytes)
void
image_endian_swap (pixman_image_t *img);
+#if defined (HAVE_MPROTECT) && defined (HAVE_GETPAGESIZE) && \
+ defined (HAVE_SYS_MMAN_H) && defined (HAVE_MMAP)
+/* fence_malloc and friends have working fence implementation.
+ * Without this, fence_malloc still allocs but does not catch
+ * out-of-bounds accesses.
+ */
+#define FENCE_MALLOC_ACTIVE 1
+#else
+#define FENCE_MALLOC_ACTIVE 0
+#endif
+
/* Allocate memory that is bounded by protected pages,
* so that out-of-bounds access will cause segfaults
*/