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