refactor: 不同C库的malloc适配归一

1. 不同C库的malloc实现归一化,由原先//kal/libc/musl、//kal/libc/newlib、
   //../../third_party/musl/porting/liteos_m_iccarm/kernel 各自实现,
   统一至//kal/posix/src/malloc.c实现,并实现对三种C库的兼容

2. Kconfig归一化的配套调整,删除Top->"Compat"->"Choose libc implementation"下
   malloc API的开关控制,统一归入"Top"->"Compat"->"Enable POSIX API"下
   "Enable POSIX MALLOC API"进行能力开关控制

BREAKING CHANGE:
Kconfig变更:
删除:
LOSCFG_LIBC_ICCARM_MALLOC
LOSCFG_LIBC_NEWLIB_MALLOC
新增:
LOSCFG_POSIX_MALLOC_API

close: I6AGOW

Signed-off-by: arvinzzz <zhaotianyu9@huawei.com>
Change-Id: I584e337cdb36184cf40c36c4f7c73ab780c31a42
This commit is contained in:
arvinzzz
2023-01-17 19:11:06 +08:00
parent 68b142cf78
commit d7f3aef326
12 changed files with 80 additions and 201 deletions

View File

@@ -555,7 +555,9 @@ int open(const char *path, int flags, ...)
int ret = VfsOpen(path, flags);
return MapToPosixRet(ret);
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(open, _open, (const char *path, int flags, ...), int);
#endif
int close(int fd)
{
@@ -581,7 +583,9 @@ int close(int fd)
}
return MapToPosixRet(ret);
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(close, _close, (int fd), int);
#endif
ssize_t read(int fd, void *buff, size_t bytes)
{
@@ -624,7 +628,9 @@ ssize_t read(int fd, void *buff, size_t bytes)
return MapToPosixRet(ret);
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(read, _read, (int fd, void *buff, size_t bytes), ssize_t);
#endif
ssize_t write(int fd, const void *buff, size_t bytes)
{
@@ -654,7 +660,9 @@ ssize_t write(int fd, const void *buff, size_t bytes)
return MapToPosixRet(ret);
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(write, _write, (int fd, const void *buff, size_t bytes), ssize_t);
#endif
off_t lseek(int fd, off_t off, int whence)
{
@@ -675,7 +683,9 @@ off_t lseek(int fd, off_t off, int whence)
VfsDetachFile(file);
return ret;
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(lseek, _lseek, (int fd, off_t off, int whence), off_t);
#endif
int stat(const char *path, struct stat *stat)
{
@@ -713,7 +723,9 @@ int stat(const char *path, struct stat *stat)
LOS_FsUnlock();
return MapToPosixRet(ret);
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(stat, _stat, (const char *path, struct stat *stat), int);
#endif
int statfs(const char *path, struct statfs *buf)
{
@@ -780,7 +792,9 @@ int unlink(const char *path)
LOS_FsUnlock();
return MapToPosixRet(ret);
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(unlink, _unlink, (const char *path), int);
#endif
int rename(const char *oldpath, const char *newpath)
{
@@ -1074,7 +1088,9 @@ int fstat(int fd, struct stat *buf)
VfsDetachFile(filep);
return ret;
}
#if (LOSCFG_LIBC_NEWLIB == 1)
FUNC_ALIAS(fstat, _fstat, (int fd, struct stat *buf), int);
#endif
int fcntl(int fd, int cmd, ...)
{