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:
parent
eac66d76b3
commit
b8b61dc070
1 changed files with 16 additions and 0 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue