From a204dbb2ec570cf20d4932dc5b17859a159d8708 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Fri, 14 Apr 2000 17:42:46 +0000 Subject: Implement posix_memalign for glibc. --- malloc/malloc.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'malloc/malloc.c') diff --git a/malloc/malloc.c b/malloc/malloc.c index f674f4e..7f33ebf 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -4746,6 +4746,29 @@ free_atfork(mem, caller) Void_t* mem; const Void_t *caller; #ifdef _LIBC +/* We need a wrapper function for one of the additions of POSIX. */ +int +__posix_memalign (void **memptr, size_t alignment, size_t size) +{ + void *mem; + + /* Test whether the SIZE argument is valid. It must be a power of + two multiple of sizeof (void *). */ + if (size % sizeof (void *) != 0 || (size & (size - 1)) != 0) + return EINVAL; + + mem = __libc_memalign (alignment, size); + + if (mem != NULL) + { + *memptr = mem; + return 0; + } + + return ENOMEM; +} +weak_alias (__posix_memalign, posix_memalign) + weak_alias (__libc_calloc, __calloc) weak_alias (__libc_calloc, calloc) weak_alias (__libc_free, __cfree) weak_alias (__libc_free, cfree) weak_alias (__libc_free, __free) weak_alias (__libc_free, free) -- cgit v1.1