Compare commits
12 Commits
weekly_202
...
weekly_202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2f44d18618 | ||
|
|
fbc81cd821 | ||
|
|
a6e17fea9b | ||
|
|
18f7ab1380 | ||
|
|
d205cfa65a | ||
|
|
11b35fe795 | ||
|
|
b086195e97 | ||
|
|
b90531e366 | ||
|
|
a1a6286500 | ||
|
|
e1027b5902 | ||
|
|
b9a445ca44 | ||
|
|
338044cd9c |
1
BUILD.gn
1
BUILD.gn
@@ -75,7 +75,6 @@ generate_notice_file("kernel_notice_file") {
|
||||
"$LITEOSTHIRDPARTY/musl",
|
||||
"$LITEOSTHIRDPARTY/zlib",
|
||||
"$LITEOSTHIRDPARTY/FatFs",
|
||||
"$LITEOSTHIRDPARTY/Linux_Kernel",
|
||||
"$LITEOSTHIRDPARTY/lwip",
|
||||
"$LITEOSTHIRDPARTY/NuttX",
|
||||
"$LITEOSTHIRDPARTY/mtd-utils",
|
||||
|
||||
@@ -32,13 +32,15 @@
|
||||
#ifndef _SHELL_PRI_H
|
||||
#define _SHELL_PRI_H
|
||||
|
||||
#include "shell.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
extern void *ShellEntry(void *argv);
|
||||
extern void ShellEntry(ShellCB *shellCB);
|
||||
extern void *ShellTask(void *argv);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#ifndef _SHMSG_H
|
||||
#define _SHMSG_H
|
||||
|
||||
#include "shell_list.h"
|
||||
#include "shell.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -61,8 +62,7 @@ extern "C" {
|
||||
|
||||
typedef void (* OutputFunc)(const char *fmt, ...);
|
||||
extern int ShellTaskInit(ShellCB *shellCB);
|
||||
extern int ShellEntryInit(ShellCB *shellCB);
|
||||
extern void ChildExec(const char *cmdName, char *const paramArray[]);
|
||||
extern void ChildExec(const char *cmdName, char *const paramArray[], bool foreground);
|
||||
extern void ShellCmdLineParse(char c, OutputFunc outputFunc, ShellCB *shellCB);
|
||||
extern int ShellNotify(ShellCB *shellCB);
|
||||
|
||||
|
||||
@@ -31,13 +31,16 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/wait.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/syscall.h>
|
||||
#include "show.h"
|
||||
#include "shmsg.h"
|
||||
#include "shcmd.h"
|
||||
#include "shell_pri.h"
|
||||
#include "semaphore.h"
|
||||
#include "securec.h"
|
||||
#include "unistd.h"
|
||||
#include <sys/syscall.h>
|
||||
|
||||
ShellCB *g_shellCB = NULL;
|
||||
|
||||
@@ -77,13 +80,8 @@ static int OsShellCreateTask(ShellCB *shellCB)
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
ret = ShellEntryInit(shellCB);
|
||||
if (ret != SH_OK) {
|
||||
goto OUT;
|
||||
}
|
||||
|
||||
(void)pthread_join(shellCB->shellTaskHandle, NULL);
|
||||
(void)pthread_join(shellCB->shellEntryHandle, NULL);
|
||||
shellCB->shellEntryHandle = pthread_self();
|
||||
return 0;
|
||||
|
||||
OUT:
|
||||
ShellDeinit(shellCB);
|
||||
@@ -98,7 +96,7 @@ static int DoShellExec(char **argv)
|
||||
char *cmdLine = NULL;
|
||||
|
||||
if (strncmp(argv[0], SHELL_EXEC_COMMAND, SHELL_EXEC_COMMAND_BYTES) == 0) {
|
||||
ChildExec(argv[1], argv + 1);
|
||||
ChildExec(argv[1], argv + 1, FALSE);
|
||||
}
|
||||
for (i = 0; argv[i]; i++) {
|
||||
len += strlen(argv[i]);
|
||||
@@ -125,11 +123,22 @@ static int DoShellExec(char **argv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void ShellSigChildHook(int sig)
|
||||
{
|
||||
(void)sig;
|
||||
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
int ret = SH_NOK;
|
||||
ShellCB *shellCB = NULL;
|
||||
|
||||
(void)signal(SIGCHLD, ShellSigChildHook);
|
||||
|
||||
if (argc > 1) {
|
||||
ret = DoShellExec(argv + 1);
|
||||
return ret;
|
||||
@@ -165,7 +174,12 @@ int main(int argc, char **argv)
|
||||
sem_init(&shellCB->shellSem, 0, 0);
|
||||
|
||||
g_shellCB = shellCB;
|
||||
return OsShellCreateTask(shellCB);
|
||||
ret = OsShellCreateTask(shellCB);
|
||||
if (ret != SH_OK) {
|
||||
goto ERR_OUT3;
|
||||
}
|
||||
|
||||
ShellEntry(shellCB);
|
||||
|
||||
ERR_OUT3:
|
||||
(void)pthread_mutex_destroy(&shellCB->historyMutex);
|
||||
|
||||
@@ -351,7 +351,7 @@ char *GetCmdName(const char *cmdline, unsigned int len)
|
||||
return cmdName;
|
||||
}
|
||||
|
||||
void ChildExec(const char *cmdName, char *const paramArray[])
|
||||
void ChildExec(const char *cmdName, char *const paramArray[], bool foreground)
|
||||
{
|
||||
int ret;
|
||||
pid_t gid;
|
||||
@@ -367,10 +367,12 @@ void ChildExec(const char *cmdName, char *const paramArray[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(1);
|
||||
if (!foreground) {
|
||||
ret = tcsetpgrp(STDIN_FILENO, gid);
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
ret = execve(cmdName, paramArray, NULL);
|
||||
@@ -404,20 +406,30 @@ int CheckExit(const char *cmdName, const CmdParsed *cmdParsed)
|
||||
exit(ret);
|
||||
}
|
||||
|
||||
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, const CmdParsed *cmdParsed)
|
||||
static void DoCmdExec(const char *cmdName, const char *cmdline, unsigned int len, CmdParsed *cmdParsed)
|
||||
{
|
||||
bool foreground = FALSE;
|
||||
int ret;
|
||||
pid_t forkPid;
|
||||
|
||||
if (strncmp(cmdline, CMD_EXEC_COMMAND, CMD_EXEC_COMMAND_BYTES) == 0) {
|
||||
if ((cmdParsed->paramCnt > 1) && (strcmp(cmdParsed->paramArray[cmdParsed->paramCnt - 1], "&") == 0)) {
|
||||
free(cmdParsed->paramArray[cmdParsed->paramCnt - 1]);
|
||||
cmdParsed->paramArray[cmdParsed->paramCnt - 1] = NULL;
|
||||
cmdParsed->paramCnt--;
|
||||
foreground = TRUE;
|
||||
}
|
||||
|
||||
forkPid = fork();
|
||||
if (forkPid < 0) {
|
||||
printf("Faild to fork from shell\n");
|
||||
return;
|
||||
} else if (forkPid == 0) {
|
||||
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray);
|
||||
ChildExec(cmdParsed->paramArray[0], cmdParsed->paramArray, foreground);
|
||||
} else {
|
||||
waitpid(forkPid, 0, 0);
|
||||
if (!foreground) {
|
||||
(void)waitpid(forkPid, 0, 0);
|
||||
}
|
||||
ret = tcsetpgrp(STDIN_FILENO, getpid());
|
||||
if (ret != 0) {
|
||||
printf("tcsetpgrp failed, errno %d\n", errno);
|
||||
@@ -567,20 +579,10 @@ static void ExecCmdline(const char *cmdline)
|
||||
free(output);
|
||||
}
|
||||
|
||||
void RecycleZombieChild(void)
|
||||
{
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
static void ShellCmdProcess(ShellCB *shellCB)
|
||||
{
|
||||
char *buf = NULL;
|
||||
while (1) {
|
||||
/* recycle zombine child process */
|
||||
RecycleZombieChild();
|
||||
buf = GetCmdline(shellCB);
|
||||
char *buf = GetCmdline(shellCB);
|
||||
if (buf == NULL) {
|
||||
break;
|
||||
}
|
||||
@@ -654,25 +656,19 @@ static int ShellKernelReg(unsigned int shellHandle)
|
||||
return ioctl(STDIN_FILENO, CONSOLE_CONTROL_REG_USERTASK, shellHandle);
|
||||
}
|
||||
|
||||
void *ShellEntry(void *argv)
|
||||
void ShellEntry(ShellCB *shellCB)
|
||||
{
|
||||
char ch;
|
||||
int ret;
|
||||
int n;
|
||||
pid_t tid = syscall(__NR_gettid);
|
||||
ShellCB *shellCB = (ShellCB *)argv;
|
||||
|
||||
if (shellCB == NULL) {
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
(void)memset_s(shellCB->shellBuf, SHOW_MAX_LEN, 0, SHOW_MAX_LEN);
|
||||
|
||||
ret = prctl(PR_SET_NAME, "ShellEntry");
|
||||
if (ret != SH_OK) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ret = ShellKernelReg((int)tid);
|
||||
if (ret != 0) {
|
||||
printf("another shell is already running!\n");
|
||||
@@ -685,32 +681,5 @@ void *ShellEntry(void *argv)
|
||||
ShellCmdLineParse(ch, (OutputFunc)printf, shellCB);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
int ShellEntryInit(ShellCB *shellCB)
|
||||
{
|
||||
int ret;
|
||||
size_t stackSize = SHELL_ENTRY_STACKSIZE;
|
||||
void *arg = NULL;
|
||||
pthread_attr_t attr;
|
||||
|
||||
if (shellCB == NULL) {
|
||||
return SH_NOK;
|
||||
}
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
if (ret != SH_OK) {
|
||||
return SH_NOK;
|
||||
}
|
||||
|
||||
pthread_attr_setstacksize(&attr, stackSize);
|
||||
arg = (void *)shellCB;
|
||||
ret = pthread_create(&shellCB->shellEntryHandle, &attr, &ShellEntry, arg);
|
||||
if (ret != SH_OK) {
|
||||
return SH_NOK;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@
|
||||
"bounds_checking_function",
|
||||
"toybox",
|
||||
"NuttX",
|
||||
"Linux_Kernel",
|
||||
"FatFs",
|
||||
"mksh",
|
||||
"musl",
|
||||
@@ -63,4 +62,4 @@
|
||||
"test": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ group("fs") {
|
||||
deps = [
|
||||
"fat",
|
||||
"fat/virpart",
|
||||
"jffs2",
|
||||
"nfs",
|
||||
"patchfs",
|
||||
"proc",
|
||||
|
||||
@@ -4,7 +4,7 @@ source "fs/ramfs/Kconfig"
|
||||
source "fs/romfs/Kconfig"
|
||||
source "fs/nfs/Kconfig"
|
||||
source "fs/proc/Kconfig"
|
||||
source "fs/jffs2/Kconfig"
|
||||
#source "fs/jffs2/Kconfig"
|
||||
source "fs/rootfs/Kconfig"
|
||||
source "fs/patchfs/Kconfig"
|
||||
source "fs/zpfs/Kconfig"
|
||||
source "fs/zpfs/Kconfig"
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_a/liteos.gni")
|
||||
import("//third_party/Linux_Kernel/Linux_Kernel.gni")
|
||||
|
||||
module_switch = defined(LOSCFG_FS_JFFS)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
|
||||
@@ -32,11 +32,11 @@ include $(LITEOSTOPDIR)/config.mk
|
||||
MODULE_NAME := $(notdir $(shell pwd))
|
||||
|
||||
LOCAL_SRCS := $(wildcard src/*.c) \
|
||||
$(wildcard $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2/*.c)
|
||||
$(wildcard $(LITEOSTOPDIR)/../linux/linux-5.10/fs/jffs2/*.c)
|
||||
LOCAL_INCLUDE := \
|
||||
-I $(LITEOSTOPDIR)/fs/jffs2/include \
|
||||
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs/jffs2 \
|
||||
-I $(LITEOSTHIRDPARTY)/Linux_Kernel/fs
|
||||
-I $(LITEOSTOPDIR)/../linux/linux-5.10/fs/jffs2 \
|
||||
-I $(LITEOSTOPDIR)/../linux/linux-5.10/fs
|
||||
LOCAL_FLAGS := $(LOCAL_INCLUDE)
|
||||
|
||||
include $(MODULE)
|
||||
|
||||
@@ -995,7 +995,6 @@ LITE_OS_SEC_TEXT INT32 LOS_SetProcessPriority(INT32 pid, UINT16 prio)
|
||||
|
||||
LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
{
|
||||
INT32 prio;
|
||||
UINT32 intSave;
|
||||
SchedParam param = { 0 };
|
||||
(VOID)which;
|
||||
@@ -1011,14 +1010,13 @@ LITE_OS_SEC_TEXT INT32 OsGetProcessPriority(INT32 which, INT32 pid)
|
||||
LosProcessCB *processCB = OS_PCB_FROM_PID(pid);
|
||||
SCHEDULER_LOCK(intSave);
|
||||
if (OsProcessIsUnused(processCB)) {
|
||||
prio = -LOS_ESRCH;
|
||||
goto OUT;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return -LOS_ESRCH;
|
||||
}
|
||||
|
||||
LosTaskCB *taskCB = OS_TCB_FROM_TID(processCB->threadGroupID);
|
||||
taskCB->ops->schedParamGet(taskCB, ¶m);
|
||||
|
||||
OUT:
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
return param.basePrio;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,10 @@
|
||||
#define LITEIPC_TIMEOUT_MS 5000UL
|
||||
#define LITEIPC_TIMEOUT_NS 5000000000ULL
|
||||
|
||||
#define MAJOR_VERSION (2)
|
||||
#define MINOR_VERSION (0)
|
||||
#define DRIVER_VERSION (MAJOR_VERSION | MINOR_VERSION << 16)
|
||||
|
||||
typedef struct {
|
||||
LOS_DL_LIST list;
|
||||
VOID *ptr;
|
||||
@@ -479,6 +483,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 AddServiceAccess(UINT32 taskID, UINT32 serviceHan
|
||||
PRINT_ERR("Liteipc AddServiceAccess GetTid failed\n");
|
||||
return ret;
|
||||
}
|
||||
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID(serviceTid);
|
||||
UINT32 processID = OS_TCB_FROM_TID(taskID)->processID;
|
||||
LosProcessCB *pcb = OS_PCB_FROM_PID(processID);
|
||||
@@ -758,22 +763,45 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandlePtr(UINT32 processID, SpecialObj *obj, BOOL
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 HandleSvc(UINT32 dstTid, const SpecialObj *obj, BOOL isRollback)
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 HandleSvc(UINT32 dstTid, SpecialObj *obj, BOOL isRollback)
|
||||
{
|
||||
UINT32 taskID = 0;
|
||||
if (isRollback == FALSE) {
|
||||
if (obj->content.svc.handle == -1) {
|
||||
if (obj->content.svc.token != 1) {
|
||||
PRINT_ERR("Liteipc HandleSvc wrong svc token\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
UINT32 selfTid = LOS_CurTaskIDGet();
|
||||
LosTaskCB *tcb = OS_TCB_FROM_TID(selfTid);
|
||||
if (tcb->ipcTaskInfo == NULL) {
|
||||
tcb->ipcTaskInfo = LiteIpcTaskInit();
|
||||
}
|
||||
uint32_t serviceHandle = 0;
|
||||
UINT32 ret = GenerateServiceHandle(selfTid, HANDLE_REGISTED, &serviceHandle);
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("Liteipc GenerateServiceHandle failed.\n");
|
||||
return ret;
|
||||
}
|
||||
obj->content.svc.handle = serviceHandle;
|
||||
(VOID)LOS_MuxLock(&g_serviceHandleMapMux, LOS_WAIT_FOREVER);
|
||||
AddServiceAccess(dstTid, serviceHandle);
|
||||
(VOID)LOS_MuxUnlock(&g_serviceHandleMapMux);
|
||||
}
|
||||
if (IsTaskAlive(obj->content.svc.handle) == FALSE) {
|
||||
PRINT_ERR("Liteipc HandleSvc wrong svctid\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (HasServiceAccess(obj->content.svc.handle) == FALSE) {
|
||||
PRINT_ERR("Liteipc %s, %d\n", __FUNCTION__, __LINE__);
|
||||
PRINT_ERR("Liteipc %s, %d, svchandle:%d, tid:%d\n", __FUNCTION__, __LINE__, obj->content.svc.handle, LOS_CurTaskIDGet());
|
||||
return -EACCES;
|
||||
}
|
||||
LosTaskCB *taskCb = OS_TCB_FROM_TID(obj->content.svc.handle);
|
||||
if (taskCb->ipcTaskInfo == NULL) {
|
||||
taskCb->ipcTaskInfo = LiteIpcTaskInit();
|
||||
}
|
||||
if (GetTid(obj->content.svc.handle, &taskID) == 0) {
|
||||
if (taskID == OS_PCB_FROM_PID(OS_TCB_FROM_TID(taskID)->processID)->ipcInfo->ipcTaskID) {
|
||||
AddServiceAccess(dstTid, obj->content.svc.handle);
|
||||
}
|
||||
AddServiceAccess(dstTid, obj->content.svc.handle);
|
||||
}
|
||||
}
|
||||
return LOS_OK;
|
||||
@@ -791,7 +819,7 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleObj(UINT32 dstTid, SpecialObj *obj, BOOL is
|
||||
ret = HandlePtr(processID, obj, isRollback);
|
||||
break;
|
||||
case OBJ_SVC:
|
||||
ret = HandleSvc(dstTid, (const SpecialObj *)obj, isRollback);
|
||||
ret = HandleSvc(dstTid, (SpecialObj *)obj, isRollback);
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
@@ -1288,6 +1316,22 @@ LITE_OS_SEC_TEXT STATIC UINT32 HandleCmsCmd(CmsCmdContent *content)
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT STATIC UINT32 HandleGetVersion(IpcVersion *version)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
IpcVersion localIpcVersion;
|
||||
if (version == NULL) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
localIpcVersion.driverVersion = DRIVER_VERSION;
|
||||
ret = copy_to_user((void *)version, (const void *)(&localIpcVersion), sizeof(IpcVersion));
|
||||
if (ret != LOS_OK) {
|
||||
PRINT_ERR("%s, %d\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg)
|
||||
{
|
||||
UINT32 ret = LOS_OK;
|
||||
@@ -1309,6 +1353,8 @@ LITE_OS_SEC_TEXT int LiteIpcIoctl(struct file *filep, int cmd, unsigned long arg
|
||||
return (INT32)SetCms(arg);
|
||||
case IPC_CMS_CMD:
|
||||
return (INT32)HandleCmsCmd((CmsCmdContent *)(UINTPTR)arg);
|
||||
case IPC_GET_VERSION:
|
||||
return (INT32)HandleGetVersion((IpcVersion *)(UINTPTR)arg);
|
||||
case IPC_SET_IPC_THREAD:
|
||||
if (IsCmsSet() == FALSE) {
|
||||
PRINT_ERR("Liteipc ServiceManager not set!\n");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -114,12 +114,17 @@ typedef enum {
|
||||
MT_NUM
|
||||
} MsgType;
|
||||
|
||||
typedef struct {
|
||||
int32_t driverVersion;
|
||||
} IpcVersion;
|
||||
|
||||
/* lite ipc ioctl */
|
||||
#define IPC_IOC_MAGIC 'i'
|
||||
#define IPC_SET_CMS _IO(IPC_IOC_MAGIC, 1)
|
||||
#define IPC_CMS_CMD _IOWR(IPC_IOC_MAGIC, 2, CmsCmdContent)
|
||||
#define IPC_SET_IPC_THREAD _IO(IPC_IOC_MAGIC, 3)
|
||||
#define IPC_SEND_RECV_MSG _IOWR(IPC_IOC_MAGIC, 4, IpcContent)
|
||||
#define IPC_GET_VERSION _IOR(IPC_IOC_MAGIC, 5, IpcVersion)
|
||||
|
||||
typedef enum {
|
||||
CMS_GEN_HANDLE,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2021-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
@@ -31,6 +31,9 @@
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define SIZE_U64 (sizeof(uint64_t))
|
||||
#define SIZE_U32 (sizeof(uint32_t))
|
||||
|
||||
int memcmp(const void *str1, const void *str2, size_t n)
|
||||
{
|
||||
|
||||
@@ -38,26 +41,26 @@ int memcmp(const void *str1, const void *str2, size_t n)
|
||||
const unsigned char *s2 = str2;
|
||||
size_t num = n;
|
||||
|
||||
while (num >= 8) { /* 8, compare size, the number of chars of one uint64_t data */
|
||||
while (num >= SIZE_U64) {
|
||||
if (*(const uint64_t *)(s1) != *(const uint64_t *)(s2)) {
|
||||
goto L8_byte_diff;
|
||||
goto L4_byte_cmp;
|
||||
}
|
||||
s1 += 8; /* 8, compare size, the number of chars of one uint64_t data */
|
||||
s2 += 8; /* 8, compare size, the number of chars of one uint64_t data */
|
||||
num -= 8; /* 8, compare size, the number of chars of one uint64_t data */
|
||||
s1 += SIZE_U64;
|
||||
s2 += SIZE_U64;
|
||||
num -= SIZE_U64;
|
||||
}
|
||||
if (num == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* L4_byte_cmp */
|
||||
if (num >= 4) { /* 4, compare size, the number of chars of one uint32_t data */
|
||||
L4_byte_cmp:
|
||||
if (num >= SIZE_U32) {
|
||||
if (*(const uint32_t *)(s1) != *(const uint32_t *)(s2)) {
|
||||
goto L4_byte_diff;
|
||||
}
|
||||
s1 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
s2 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
num -= 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
s1 += SIZE_U32;
|
||||
s2 += SIZE_U32;
|
||||
num -= SIZE_U32;
|
||||
}
|
||||
if (num == 0) {
|
||||
return 0;
|
||||
@@ -66,13 +69,4 @@ L4_byte_diff:
|
||||
for (; num && (*s1 == *s2); num--, s1++, s2++) {
|
||||
}
|
||||
return num ? *s1 - *s2 : 0;
|
||||
|
||||
L8_byte_diff:
|
||||
if (*(const uint32_t *)(s1) != *(const uint32_t *)(s2)) {
|
||||
goto L4_byte_diff;
|
||||
}
|
||||
s1 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
s2 += 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
num -= 4; /* 4, compare size, the number of chars of one uint32_t data */
|
||||
goto L4_byte_diff;
|
||||
}
|
||||
@@ -306,8 +306,8 @@ endif
|
||||
|
||||
|
||||
ifeq ($(LOSCFG_FS_JFFS), y)
|
||||
LITEOS_BASELIB += -ljffs2
|
||||
LIB_SUBDIRS += fs/jffs2
|
||||
# LITEOS_BASELIB += -ljffs2
|
||||
# LIB_SUBDIRS += fs/jffs2
|
||||
endif
|
||||
|
||||
ifeq ($(LOSCFG_PLATFORM_ROOTFS), y)
|
||||
|
||||
Reference in New Issue
Block a user