Subject: Re: bug#22522: Commit b88e9cded7ae3756e3a2ec4a23e8df352a0239f9 breaks emacs dumping for me

From: Paul Eggert <[email-masked]>
Date: Wed, 3 Feb 2016 00:41:18 -0800

Ken Brown wrote:
>> I installed the attached patch into the Emacs master, to try to work
>> around this problem by putting GCC into C11 mode. Please give it a try.
>
> No, that didn't fix it.

Can you investigate why not?  The patch should cause 'configure' to put 
-stdc=gnu11 into CFLAGS. If you look at config.log, it should have something 
like this:

configure:5924: checking for gcc option to enable C11 features
...
configure:6146: result: -std=gnu11

If this isn't the result, what is the result and why?

> What about an ad hoc temporary solution that simply defines __ISO_C_VISIBLE to be 2011 on Cygwin prior to the inclusion of <stdlib.h>?

I'd rather not go that route, as __ISO_C_VISIBLE is supposed to be private. I 
installed the attached patch instead; please give it a try.
>From 0fed204ff1adab4636cad9c6492b3a96fabf1010 Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email-masked]>
Date: Wed, 3 Feb 2016 00:37:44 -0800
Subject: [PATCH] Port aligned_alloc decl to Cygwin.

Problem reported by Ken Brown (Bug#22522#38).
* configure.ac (aligned_alloc): Check for decl too.
* src/lisp.h (aligned_alloc): Declare if not already declared.
---
 configure.ac | 1 +
 src/lisp.h   | 5 ++---
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/configure.ac b/configure.ac
index d97d9e5..1e076c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3824,6 +3824,7 @@ if (test -z "$GMALLOC_OBJ" || test "$hybrid_malloc" = yes) \
   && test "$opsys" != darwin; then
   AC_CHECK_FUNCS([aligned_alloc posix_memalign], [break])
 fi
+AC_CHECK_DECLS([aligned_alloc], [], [], [[#include <stdlib.h>]])
 
 dnl Cannot use AC_CHECK_FUNCS
 AC_CACHE_CHECK([for __builtin_unwind_init],
diff --git a/src/lisp.h b/src/lisp.h
index 54bce0f..a99002b 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3774,10 +3774,9 @@ INLINE void (check_cons_list) (void) { lisp_h_check_cons_list (); }
 /* Defined in gmalloc.c.  */
 #if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC
 extern size_t __malloc_extra_blocks;
-extern void *aligned_alloc (size_t, size_t);
 #endif
-#if defined HYBRID_MALLOC && !defined HAVE_ALIGNED_ALLOC
-extern void *hybrid_aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2));
+#ifndef HAVE_DECL_ALIGNED_ALLOC
+extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2));
 #endif
 extern void malloc_enable_thread (void);
 
-- 
2.5.0