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