51f0aa
This patch adds a definition of max_align_t to the internal
51f0aa
<sys/cdefs.h> header, for use in support/ functionality and elsewhere.
51f0aa
51f0aa
The definition must support being compiled in C11 or C++11 mode and
51f0aa
must check both __STDC_VERSION__ and __cplusplus versions.
51f0aa
51f0aa
Upstream does not need this because all files are compiled in C11
51f0aa
mode, making available the GCC definition in <stddef.h>
51f0aa
51f0aa
Also change malloc/tst-malloc-thread-fail.c to use the new definition.
51f0aa
51f0aa
Index: glibc-2.17-c758a686/include/sys/cdefs.h
51f0aa
===================================================================
51f0aa
--- glibc-2.17-c758a686.orig/include/sys/cdefs.h
51f0aa
+++ glibc-2.17-c758a686/include/sys/cdefs.h
51f0aa
@@ -15,6 +15,18 @@ rtld_hidden_proto (__chk_fail)
51f0aa
 
51f0aa
 
51f0aa
 # define __attribute_alloc_size(...) __attribute__ ((alloc_size (__VA_ARGS__)))
51f0aa
+
51f0aa
+/* This mirrors the C11/C++11 max_align_t type provided by GCC, but it
51f0aa
+   is also available in C99 mode.  The aligned attributes are required
51f0aa
+   because some ABIs have reduced alignment requirements for struct and
51f0aa
+   union members.  */
51f0aa
+#if __STDC_VERSION__ < 201112L && __cplusplus < 201103L
51f0aa
+typedef struct {
51f0aa
+  long long ll __attribute__ ((__aligned__ (__alignof__ (long long))));
51f0aa
+  long double ld __attribute__ ((__aligned__ (__alignof__ (long double))));
51f0aa
+} max_align_t;
51f0aa
+#endif /* __STDC_VERSION__ < 201112 && __cplusplus < 201103L */
51f0aa
+
51f0aa
 #endif
51f0aa
 
51f0aa
 #endif
51f0aa
Index: glibc-2.17-c758a686/malloc/tst-malloc-thread-fail.c
51f0aa
===================================================================
51f0aa
--- glibc-2.17-c758a686.orig/malloc/tst-malloc-thread-fail.c
51f0aa
+++ glibc-2.17-c758a686/malloc/tst-malloc-thread-fail.c
51f0aa
@@ -30,16 +30,6 @@
51f0aa
 #include <sys/resource.h>
51f0aa
 #include <sys/wait.h>
51f0aa
 #include <unistd.h>
51f0aa
-#include <stddef.h>
51f0aa
-
51f0aa
-/* This mirrors the C11 max_align_t type provided by GCC, but it is
51f0aa
-   also available in C99 mode.  The aligned attributes are required
51f0aa
-   because some ABIs have reduced alignment requirements for struct
51f0aa
-   and union members.  */
51f0aa
-typedef struct {
51f0aa
-  long long ll __attribute__ ((__aligned__ (__alignof__ (long long))));
51f0aa
-  long double ld __attribute__ ((__aligned__ (__alignof__ (long double))));
51f0aa
-} libc_max_align_t;
51f0aa
 
51f0aa
 /* Wrapper for calloc with an optimization barrier.  */
51f0aa
 static void *
51f0aa
@@ -93,7 +83,7 @@ allocate_1 (void)
51f0aa
     {
51f0aa
     case with_malloc:
51f0aa
       return (struct allocate_result)
51f0aa
-        {malloc (allocation_size), __alignof__ (libc_max_align_t)};
51f0aa
+        {malloc (allocation_size), _Alignof (max_align_t)};
51f0aa
     case with_realloc:
51f0aa
       {
51f0aa
         void *p = realloc (NULL, 16);
51f0aa
@@ -106,7 +96,7 @@ allocate_1 (void)
51f0aa
             if (q == NULL)
51f0aa
               free (p);
51f0aa
           }
51f0aa
-        return (struct allocate_result) {q, __alignof__ (libc_max_align_t)};
51f0aa
+        return (struct allocate_result) {q, _Alignof (max_align_t)};
51f0aa
       }
51f0aa
     case with_aligned_alloc:
51f0aa
       {
51f0aa
@@ -155,7 +145,7 @@ allocate_1 (void)
51f0aa
                 printf ("error: non-zero byte at offset %zu\n", i);
51f0aa
                 abort ();
51f0aa
               }
51f0aa
-        return (struct allocate_result) {p, __alignof__ (libc_max_align_t)};
51f0aa
+        return (struct allocate_result) {p, _Alignof (max_align_t)};
51f0aa
       }
51f0aa
     }
51f0aa
   abort ();