1
0
Fork 0
forked from nuttx/nuttx-update

lib/stdlib: Implement aligned_alloc and posix_memalign

https://linux.die.net/man/3/aligned_alloc

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Change-Id: I73db1c982e2c3eb73e5960e91c0d471ab967be51
This commit is contained in:
Xiang Xiao 2020-06-01 14:21:15 +08:00 committed by patacongo
parent eac66d76b3
commit b8b61dc070

View file

@ -29,6 +29,7 @@
#include <nuttx/compiler.h>
#include <sys/types.h>
#include <errno.h>
#include <stdint.h>
#include <limits.h>
@ -255,6 +256,21 @@ FAR void *memalign(size_t, size_t);
FAR void *zalloc(size_t);
FAR void *calloc(size_t, size_t);
#ifdef __cplusplus
inline FAR void *aligned_alloc(size_t a, size_t s)
{
return memalign(a, s);
}
inline int posix_memalign(FAR void **m, size_t a, size_t s)
{
return (*m = memalign(a, s)) ? OK : ENOMEM;
}
#else
#define aligned_alloc(a, s) memalign((a), (s))
#define posix_memalign(m, a, s) ((*(m) = memalign((a), (s))) ? OK : ENOMEM)
#endif
struct mallinfo mallinfo(void);
/* Pseudo-Terminals */