Implement posix_memalign for glibc.

This commit is contained in:
Ulrich Drepper 2000-04-14 17:42:46 +00:00
parent 12d3e57900
commit a204dbb2ec

View File

@ -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)