Browse Source

add aligned_alloc required for latest gcc libstdc++

Waldemar Brodkorb 7 years ago
parent
commit
cee0b058fa
3 changed files with 8 additions and 0 deletions
  1. 6 0
      include/stdlib.h
  2. 1 0
      libc/stdlib/malloc-standard/memalign.c
  3. 1 0
      libc/stdlib/malloc/memalign.c

+ 6 - 0
include/stdlib.h

@@ -529,6 +529,12 @@ extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size)
      __THROW __nonnull ((1)) __wur;
 #endif
 
+#ifdef __USE_ISOC11
+/* ISO C variant of aligned allocation.  */
+extern void *aligned_alloc (size_t __alignment, size_t __size)
+     __THROW __attribute_malloc__ __attribute_alloc_size__ ((2)) __wur;
+#endif
+
 __BEGIN_NAMESPACE_STD
 /* Abort execution and generate a core-dump.  */
 extern void abort (void) __THROW __attribute__ ((__noreturn__));

+ 1 - 0
libc/stdlib/malloc-standard/memalign.c

@@ -127,4 +127,5 @@ void* memalign(size_t alignment, size_t bytes)
     __MALLOC_UNLOCK;
 	return retval;
 }
+weak_alias(memalign, aligned_alloc)
 libc_hidden_def(memalign)

+ 1 - 0
libc/stdlib/malloc/memalign.c

@@ -93,4 +93,5 @@ memalign (size_t alignment, size_t size)
 
   return MALLOC_SETUP (base, end_addr - (unsigned long)base);
 }
+weak_alias(memalign, aligned_alloc)
 libc_hidden_def(memalign)