You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gentoo-overlay/sys-freebsd/freebsd-lib/files/freebsd-lib-9.1-aligned_all...

52 lines
1.3 KiB

Backport aligned_alloc for C++11 support.
http://lists.freebsd.org/pipermail/svn-src-stable-9/2012-November/003313.html
diff -uNr lib.old/libc/stdlib/Symbol.map lib/libc/stdlib/Symbol.map
--- lib.old/libc/stdlib/Symbol.map 2013-05-24 17:03:55.000000000 -0400
+++ lib/libc/stdlib/Symbol.map 2013-05-24 17:06:03.000000000 -0400
@@ -97,6 +97,7 @@
atoi_l;
atol_l;
atoll_l;
+ aligned_alloc;
at_quick_exit;
quick_exit;
strtod_l;
diff -uNr lib.old/libc/stdlib/malloc.c lib/libc/stdlib/malloc.c
--- lib.old/libc/stdlib/malloc.c 2013-05-24 17:03:55.000000000 -0400
+++ lib/libc/stdlib/malloc.c 2013-05-24 17:05:40.000000000 -0400
@@ -6046,6 +6046,21 @@
}
void *
+aligned_alloc(size_t alignment, size_t size)
+{
+ void *memptr;
+ int ret;
+
+ ret = posix_memalign(&memptr, alignment, size);
+ if (ret != 0) {
+ errno = ret;
+ return (NULL);
+ }
+ return (memptr);
+}
+
+
+void *
calloc(size_t num, size_t size)
{
void *ret;
diff -uNr includeold/stdlib.h include/stdlib.h
--- includeold/stdlib.h 2013-05-24 17:03:46.000000000 -0400
+++ include/stdlib.h 2013-05-24 17:04:46.000000000 -0400
@@ -155,6 +155,7 @@
* If we're in a mode greater than C99, expose C1x functions.
*/
#if __ISO_C_VISIBLE >= 2011 || __cplusplus >= 201103L
+void * aligned_alloc(size_t, size_t);
_Noreturn void
quick_exit(int);
int at_quick_exit(void (*)(void));