$NetBSD: patch-src_alloc_c,v 1.1 2012/01/09 06:30:20 skrll Exp $ - use standard headers - add an empty asm() destroying memory that prevents gcc from optimizing out __malloc_hook and friends (which leads to SIGSEGV in temacs during build) --- src/alloc.c.orig 2008-08-12 18:35:44.000000000 +0000 +++ src/alloc.c 2012-01-05 08:36:58.000000000 +0000 @@ -84,6 +84,8 @@ #include "w32.h" #endif +#include + #ifdef DOUG_LEA_MALLOC #include @@ -1205,6 +1207,9 @@ #endif /* GC_MALLOC_CHECK */ __free_hook = old_free_hook; +#ifdef __GNUC__ + __asm __volatile("":::"memory"); +#endif free (ptr); /* If we released our reserve (due to running out of memory), @@ -1236,6 +1241,9 @@ BLOCK_INPUT_ALLOC; __malloc_hook = old_malloc_hook; +#ifdef __GNUC__ + __asm __volatile("":::"memory"); +#endif #ifdef DOUG_LEA_MALLOC mallopt (M_TOP_PAD, malloc_hysteresis * 4096); #else @@ -1285,6 +1293,9 @@ BLOCK_INPUT_ALLOC; __realloc_hook = old_realloc_hook; +#ifdef __GNUC__ + __asm __volatile("":::"memory"); +#endif #ifdef GC_MALLOC_CHECK if (ptr)