diff options
author | Ulrich Drepper <drepper@redhat.com> | 2000-04-14 17:42:46 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2000-04-14 17:42:46 +0000 |
commit | a204dbb2ec570cf20d4932dc5b17859a159d8708 (patch) | |
tree | ce8f10127633e481d9267751ee3e4119080e2b2f | |
parent | 12d3e5790003cee28a01c64c9d4d579dcbe68ed5 (diff) | |
download | glibc-a204dbb2ec570cf20d4932dc5b17859a159d8708.tar.gz glibc-a204dbb2ec570cf20d4932dc5b17859a159d8708.tar.xz glibc-a204dbb2ec570cf20d4932dc5b17859a159d8708.zip |
Implement posix_memalign for glibc.
-rw-r--r-- | malloc/malloc.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/malloc/malloc.c b/malloc/malloc.c index f674f4ebfe..7f33ebf252 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) |