Compare commits
16 Commits
OpenHarmon
...
monthly_20
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33d58bb320 | ||
|
|
75bb5ae446 | ||
|
|
589c6fe894 | ||
|
|
008d9cf1bc | ||
|
|
b746ddd9d6 | ||
|
|
236e316568 | ||
|
|
72d9e053d9 | ||
|
|
a25443b016 | ||
|
|
453790015e | ||
|
|
fd75add21d | ||
|
|
5717559488 | ||
|
|
62c0ba21ad | ||
|
|
a4c87a792c | ||
|
|
d04b407e92 | ||
|
|
a7e5d26b17 | ||
|
|
63d8e9d25c |
3
BUILD.gn
3
BUILD.gn
@@ -91,9 +91,8 @@ config("dialect_config") {
|
||||
}
|
||||
|
||||
config("misc_config") {
|
||||
defines = []
|
||||
if (!defined(LOSCFG_COMPILER_ICCARM)) {
|
||||
defines += [ "__LITEOS__" ]
|
||||
defines = [ "__LITEOS__" ]
|
||||
defines += [ "__LITEOS_M__" ]
|
||||
}
|
||||
if (!defined(LOSCFG_DEBUG_VERSION)) {
|
||||
|
||||
18
Kconfig
18
Kconfig
@@ -335,14 +335,6 @@ config KERNEL_PM
|
||||
Configuration item for low power frame tailoring.
|
||||
If you wish to build LiteOS with support for power management.
|
||||
|
||||
config KERNEL_PM_IDLE
|
||||
bool "Enable Power Management Idle"
|
||||
default n
|
||||
depends on KERNEL_PM
|
||||
help
|
||||
Configuration item for low power frame tailoring.
|
||||
If you wish to build LiteOS with support for power management idle.
|
||||
|
||||
config KERNEL_PM_TASK_PTIORITY
|
||||
int "Power Management Task Priority"
|
||||
default 1
|
||||
@@ -521,14 +513,6 @@ config DEBUG_QUEUE
|
||||
help
|
||||
Answer Y to enable debug queue.
|
||||
|
||||
config MUTEX_CREATE_TRACE
|
||||
bool "Enable Mutex Trace Debugging"
|
||||
default n
|
||||
depends on ARCH_ARM
|
||||
depends on DEBUG_KERNEL
|
||||
help
|
||||
Answer Y to enable debug mutex trace.
|
||||
|
||||
config DEBUG_DEADLOCK
|
||||
bool "Enable Mutex Deadlock Debugging"
|
||||
default n
|
||||
@@ -617,7 +601,7 @@ config VM_OVERLAP_CHECK
|
||||
depends on DEBUG_VERSION && MEM_DEBUG
|
||||
help
|
||||
Answer Y to enable vm overlap check.
|
||||
|
||||
|
||||
config TASK_MEM_USED
|
||||
bool "Enable show task mem used or not"
|
||||
default n
|
||||
|
||||
@@ -91,7 +91,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
{
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
UINT32 val = SysTick->VAL;
|
||||
*period = SysTick->LOAD;
|
||||
|
||||
@@ -51,7 +51,6 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -51,7 +51,6 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -91,7 +91,7 @@ STATIC UINT64 SysTickReload(UINT64 nextResponseTime)
|
||||
|
||||
STATIC UINT64 SysTickCycleGet(UINT32 *period)
|
||||
{
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 hwCycle = 0;
|
||||
UINT32 intSave = LOS_IntLock();
|
||||
UINT32 val = SysTick->VAL;
|
||||
*period = SysTick->LOAD;
|
||||
|
||||
@@ -51,7 +51,6 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -51,7 +51,6 @@ VOID HalSecureSVCHandler(UINT32 svcID, UINTPTR arg)
|
||||
HalSecureContextLoad(g_secureContext);
|
||||
break;
|
||||
case OS_SVC_FREE_SECURE_CONTEXT:
|
||||
LOS_ASSERT(g_secureContext != NULL);
|
||||
HalSecureContextFree(g_secureContext);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -612,7 +612,7 @@ LITE_OS_SEC_TEXT_INIT VOID HalHwiInit(VOID)
|
||||
HalHwiHandleReInit((UINT32)&g_hwiForm);
|
||||
|
||||
HalSetVbr((UINT32)&g_hwiForm);
|
||||
for (i = 0; i < BYTES_OF_128_INT; i++) {
|
||||
for (int i = 0; i < BYTES_OF_128_INT; i++) {
|
||||
VIC_REG->IABR[i] = 0x0;
|
||||
VIC_REG->ICPR[i] = MASK_32_BITS;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2023 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -62,14 +62,6 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
|
||||
__asm("mrs %0, msp" : "=r" (msp));
|
||||
return msp;
|
||||
}
|
||||
|
||||
#define ARCH_LR_GET() \
|
||||
({ \
|
||||
UINTPTR lr; \
|
||||
__asm("mov %0, lr" : "=r" (lr)); \
|
||||
(lr); \
|
||||
})
|
||||
#define ArchLRGet ARCH_LR_GET
|
||||
#elif defined(__CLANG_ARM) || defined(__GNUC__)
|
||||
STATIC INLINE UINTPTR ArchSpGet(VOID)
|
||||
{
|
||||
@@ -91,14 +83,6 @@ STATIC INLINE UINTPTR ArchMspGet(VOID)
|
||||
__asm volatile("mrs %0, msp" : "=r" (msp));
|
||||
return msp;
|
||||
}
|
||||
|
||||
#define ARCH_LR_GET() \
|
||||
({ \
|
||||
UINTPTR lr; \
|
||||
__asm volatile("mov %0, lr" : "=r" (lr)); \
|
||||
(lr); \
|
||||
})
|
||||
#define ArchLRGet ARCH_LR_GET
|
||||
#else
|
||||
/* Other platforms to be improved */
|
||||
#endif
|
||||
|
||||
@@ -58,9 +58,6 @@
|
||||
|
||||
#define OS_CPUP_RECORD_PERIOD (g_sysClock)
|
||||
|
||||
#define OS_SYS_CYCLE_TO_US(cycle) ((cycle) / (g_sysClock)) * OS_SYS_US_PER_SECOND + \
|
||||
((cycle) % (g_sysClock) * OS_SYS_US_PER_SECOND / (g_sysClock))
|
||||
|
||||
LITE_OS_SEC_BSS UINT16 g_cpupInitFlg = 0;
|
||||
LITE_OS_SEC_BSS OsCpupCB *g_cpup = NULL;
|
||||
LITE_OS_SEC_BSS UINT64 g_lastRecordTime;
|
||||
@@ -170,15 +167,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsCpupInit()
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/* The calculation time unit is changed to us to decouple the influence of
|
||||
* system frequency modulation on CPUP
|
||||
*/
|
||||
STATIC UINT64 CpupTimeUsGet(VOID)
|
||||
{
|
||||
UINT64 time = LOS_SysCycleGet();
|
||||
return OS_SYS_CYCLE_TO_US(time);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : OsTskCycleStart
|
||||
Description: start task to get cycles count in current task beginning
|
||||
@@ -195,11 +183,10 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleStart(VOID)
|
||||
|
||||
taskID = g_losTask.newTask->taskID;
|
||||
g_cpup[taskID].cpupID = taskID;
|
||||
g_cpup[taskID].startTime = CpupTimeUsGet();
|
||||
g_cpup[taskID].startTime = LOS_SysCycleGet();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : OsTskCycleEnd
|
||||
Description: quit task and get cycle count
|
||||
@@ -209,7 +196,7 @@ Return : None
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
|
||||
{
|
||||
UINT32 taskID;
|
||||
UINT64 cpuTime;
|
||||
UINT64 cpuCycle;
|
||||
|
||||
if (g_cpupInitFlg == 0) {
|
||||
return;
|
||||
@@ -221,17 +208,16 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEnd(VOID)
|
||||
return;
|
||||
}
|
||||
|
||||
cpuTime = CpupTimeUsGet();
|
||||
if (cpuTime < g_cpup[taskID].startTime) {
|
||||
cpuTime += OS_US_PER_TICK;
|
||||
cpuCycle = LOS_SysCycleGet();
|
||||
if (cpuCycle < g_cpup[taskID].startTime) {
|
||||
cpuCycle += g_cyclesPerTick;
|
||||
}
|
||||
|
||||
g_cpup[taskID].allTime += (cpuTime - g_cpup[taskID].startTime);
|
||||
g_cpup[taskID].allTime += (cpuCycle - g_cpup[taskID].startTime);
|
||||
g_cpup[taskID].startTime = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
Function : OsTskCycleEndStart
|
||||
Description: start task to get cycles count in current task ending
|
||||
@@ -241,7 +227,7 @@ Return : None
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
|
||||
{
|
||||
UINT32 taskID;
|
||||
UINT64 cpuTime;
|
||||
UINT64 cpuCycle;
|
||||
UINT16 loopNum;
|
||||
|
||||
if (g_cpupInitFlg == 0) {
|
||||
@@ -249,23 +235,23 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
|
||||
}
|
||||
|
||||
taskID = g_losTask.runTask->taskID;
|
||||
cpuTime = CpupTimeUsGet();
|
||||
cpuCycle = LOS_SysCycleGet();
|
||||
|
||||
if (g_cpup[taskID].startTime != 0) {
|
||||
if (cpuTime < g_cpup[taskID].startTime) {
|
||||
cpuTime += OS_US_PER_TICK;
|
||||
if (cpuCycle < g_cpup[taskID].startTime) {
|
||||
cpuCycle += g_cyclesPerTick;
|
||||
}
|
||||
|
||||
g_cpup[taskID].allTime += (cpuTime - g_cpup[taskID].startTime);
|
||||
g_cpup[taskID].allTime += (cpuCycle - g_cpup[taskID].startTime);
|
||||
g_cpup[taskID].startTime = 0;
|
||||
}
|
||||
|
||||
taskID = g_losTask.newTask->taskID;
|
||||
g_cpup[taskID].cpupID = taskID;
|
||||
g_cpup[taskID].startTime = cpuTime;
|
||||
g_cpup[taskID].startTime = cpuCycle;
|
||||
|
||||
if ((cpuTime - g_lastRecordTime) > OS_CPUP_RECORD_PERIOD) {
|
||||
g_lastRecordTime = cpuTime;
|
||||
if ((cpuCycle - g_lastRecordTime) > OS_CPUP_RECORD_PERIOD) {
|
||||
g_lastRecordTime = cpuCycle;
|
||||
|
||||
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
|
||||
g_cpup[loopNum].historyTime[g_hisPos] = g_cpup[loopNum].allTime;
|
||||
@@ -281,12 +267,12 @@ LITE_OS_SEC_TEXT_MINOR VOID OsTskCycleEndStart(VOID)
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR STATIC INLINE UINT16 OsGetPrePos(UINT16 curPos)
|
||||
LITE_OS_SEC_TEXT_MINOR static inline UINT16 OsGetPrePos(UINT16 curPos)
|
||||
{
|
||||
return (curPos == 0) ? (OS_CPUP_HISTORY_RECORD_NUM - 1) : (curPos - 1);
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr)
|
||||
LITE_OS_SEC_TEXT_MINOR static VOID OsGetPositions(UINT16 mode, UINT16* curPosAddr, UINT16* prePosAddr)
|
||||
{
|
||||
UINT16 curPos;
|
||||
UINT16 prePos = 0;
|
||||
@@ -312,7 +298,7 @@ Return : cpupRet:current CPU usage
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID)
|
||||
{
|
||||
UINT64 cpuTimeAll = 0;
|
||||
UINT64 cpuCycleAll = 0;
|
||||
UINT32 cpupRet = 0;
|
||||
UINT16 loopNum;
|
||||
UINT32 intSave;
|
||||
@@ -326,12 +312,12 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_SysCpuUsage(VOID)
|
||||
OsTskCycleEnd();
|
||||
|
||||
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
|
||||
cpuTimeAll += g_cpup[loopNum].allTime;
|
||||
cpuCycleAll += g_cpup[loopNum].allTime;
|
||||
}
|
||||
|
||||
if (cpuTimeAll) {
|
||||
if (cpuCycleAll) {
|
||||
cpupRet = LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION *
|
||||
g_cpup[g_idleTaskID].allTime) / cpuTimeAll);
|
||||
g_cpup[g_idleTaskID].allTime) / cpuCycleAll);
|
||||
}
|
||||
|
||||
OsTskCycleStart();
|
||||
@@ -348,7 +334,7 @@ Return : cpupRet:CPU usage history
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
|
||||
{
|
||||
UINT64 cpuTimeAll = 0;
|
||||
UINT64 cpuCycleAll = 0;
|
||||
UINT64 idleCycleAll = 0;
|
||||
UINT32 cpupRet = 0;
|
||||
UINT16 loopNum;
|
||||
@@ -368,9 +354,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
|
||||
|
||||
for (loopNum = 0; loopNum < g_taskMaxNum; loopNum++) {
|
||||
if (mode == CPUP_IN_1S) {
|
||||
cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
} else {
|
||||
cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,8 +367,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistorySysCpuUsage(UINT16 mode)
|
||||
idleCycleAll += g_cpup[g_idleTaskID].allTime - g_cpup[g_idleTaskID].historyTime[curPos];
|
||||
}
|
||||
|
||||
if (cpuTimeAll) {
|
||||
cpupRet = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuTimeAll));
|
||||
if (cpuCycleAll) {
|
||||
cpupRet = (LOS_CPUP_PRECISION - (UINT32)((LOS_CPUP_PRECISION * idleCycleAll) / cpuCycleAll));
|
||||
}
|
||||
|
||||
OsTskCycleStart();
|
||||
@@ -399,7 +385,7 @@ Return : cpupRet:CPU usage of certain task
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID)
|
||||
{
|
||||
UINT64 cpuTimeAll = 0;
|
||||
UINT64 cpuCycleAll = 0;
|
||||
UINT16 loopNum;
|
||||
UINT32 intSave;
|
||||
UINT32 cpupRet = 0;
|
||||
@@ -424,11 +410,11 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_TaskCpuUsage(UINT32 taskID)
|
||||
if ((g_cpup[loopNum].status & OS_TASK_STATUS_UNUSED) || (g_cpup[loopNum].status == 0)) {
|
||||
continue;
|
||||
}
|
||||
cpuTimeAll += g_cpup[loopNum].allTime;
|
||||
cpuCycleAll += g_cpup[loopNum].allTime;
|
||||
}
|
||||
|
||||
if (cpuTimeAll) {
|
||||
cpupRet = (UINT32)((LOS_CPUP_PRECISION * g_cpup[taskID].allTime) / cpuTimeAll);
|
||||
if (cpuCycleAll) {
|
||||
cpupRet = (UINT32)((LOS_CPUP_PRECISION * g_cpup[taskID].allTime) / cpuCycleAll);
|
||||
}
|
||||
|
||||
OsTskCycleStart();
|
||||
@@ -446,8 +432,8 @@ Return : cpupRet:CPU usage history of task
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode)
|
||||
{
|
||||
UINT64 cpuTimeAll = 0;
|
||||
UINT64 cpuTimeCurTsk = 0;
|
||||
UINT64 cpuCycleAll = 0;
|
||||
UINT64 cpuCycleCurTsk = 0;
|
||||
UINT16 loopNum, curPos;
|
||||
UINT16 prePos = 0;
|
||||
UINT32 intSave;
|
||||
@@ -477,19 +463,19 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_HistoryTaskCpuUsage(UINT32 taskID, UINT16 mode
|
||||
}
|
||||
|
||||
if (mode == CPUP_IN_1S) {
|
||||
cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
} else {
|
||||
cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == CPUP_IN_1S) {
|
||||
cpuTimeCurTsk += g_cpup[taskID].historyTime[curPos] - g_cpup[taskID].historyTime[prePos];
|
||||
cpuCycleCurTsk += g_cpup[taskID].historyTime[curPos] - g_cpup[taskID].historyTime[prePos];
|
||||
} else {
|
||||
cpuTimeCurTsk += g_cpup[taskID].allTime - g_cpup[taskID].historyTime[curPos];
|
||||
cpuCycleCurTsk += g_cpup[taskID].allTime - g_cpup[taskID].historyTime[curPos];
|
||||
}
|
||||
if (cpuTimeAll) {
|
||||
cpupRet = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurTsk) / cpuTimeAll);
|
||||
if (cpuCycleAll) {
|
||||
cpupRet = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTsk) / cpuCycleAll);
|
||||
}
|
||||
|
||||
OsTskCycleStart();
|
||||
@@ -504,8 +490,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
|
||||
UINT16 curPos;
|
||||
UINT16 prePos = 0;
|
||||
UINT32 intSave;
|
||||
UINT64 cpuTimeAll = 0;
|
||||
UINT64 cpuTimeCurTsk = 0;
|
||||
UINT64 cpuCycleAll = 0;
|
||||
UINT64 cpuCycleCurTsk = 0;
|
||||
|
||||
if (g_cpupInitFlg == 0) {
|
||||
return LOS_ERRNO_CPUP_NO_INIT;
|
||||
@@ -527,9 +513,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
|
||||
}
|
||||
|
||||
if (mode == CPUP_IN_1S) {
|
||||
cpuTimeAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
cpuCycleAll += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
} else {
|
||||
cpuTimeAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
cpuCycleAll += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,16 +526,16 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_AllTaskCpuUsage(CPUP_INFO_S *cpupInfo, UINT16
|
||||
}
|
||||
|
||||
if (mode == CPUP_IN_1S) {
|
||||
cpuTimeCurTsk += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
cpuCycleCurTsk += g_cpup[loopNum].historyTime[curPos] - g_cpup[loopNum].historyTime[prePos];
|
||||
} else {
|
||||
cpuTimeCurTsk += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
cpuCycleCurTsk += g_cpup[loopNum].allTime - g_cpup[loopNum].historyTime[curPos];
|
||||
}
|
||||
cpupInfo[loopNum].usStatus = g_cpup[loopNum].status;
|
||||
if (cpuTimeAll) {
|
||||
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurTsk) / cpuTimeAll);
|
||||
if (cpuCycleAll) {
|
||||
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurTsk) / cpuCycleAll);
|
||||
}
|
||||
|
||||
cpuTimeCurTsk = 0;
|
||||
cpuCycleCurTsk = 0;
|
||||
}
|
||||
|
||||
OsTskCycleStart();
|
||||
@@ -620,13 +606,13 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqStart(UINT32 intNum)
|
||||
return;
|
||||
}
|
||||
|
||||
g_irqCpup[intNum].startTime = CpupTimeUsGet();
|
||||
g_irqCpup[intNum].startTime = LOS_SysCycleGet();
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
|
||||
{
|
||||
UINT64 cpuTime;
|
||||
UINT64 cpuCycle;
|
||||
UINT64 usedTime;
|
||||
|
||||
if (g_irqCpupInitFlg == 0) {
|
||||
@@ -637,14 +623,14 @@ LITE_OS_SEC_TEXT_MINOR VOID OsCpupIrqEnd(UINT32 intNum)
|
||||
return;
|
||||
}
|
||||
|
||||
cpuTime = CpupTimeUsGet();
|
||||
if (cpuTime < g_irqCpup[intNum].startTime) {
|
||||
cpuTime += OS_US_PER_TICK;
|
||||
cpuCycle = LOS_SysCycleGet();
|
||||
if (cpuCycle < g_irqCpup[intNum].startTime) {
|
||||
cpuCycle += g_cyclesPerTick;
|
||||
}
|
||||
|
||||
g_irqCpup[intNum].cpupID = intNum;
|
||||
g_irqCpup[intNum].status = OS_CPUP_USED;
|
||||
usedTime = cpuTime - g_irqCpup[intNum].startTime;
|
||||
usedTime = cpuCycle - g_irqCpup[intNum].startTime;
|
||||
|
||||
if (g_irqCpup[intNum].count <= 1000) { /* 1000, Take 1000 samples */
|
||||
g_irqCpup[intNum].allTime += usedTime;
|
||||
@@ -686,12 +672,12 @@ LITE_OS_SEC_TEXT_MINOR STATIC VOID OsGetIrqPositions(UINT16 mode, UINT16* curPos
|
||||
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllTime(VOID)
|
||||
{
|
||||
INT32 i;
|
||||
UINT64 cpuTimeAll = 0;
|
||||
UINT64 cpuCycleAll = 0;
|
||||
for (i = 0; i < OS_CPUP_HISTORY_RECORD_NUM; i++) {
|
||||
cpuTimeAll += g_cpuHistoryTime[i];
|
||||
cpuCycleAll += g_cpuHistoryTime[i];
|
||||
}
|
||||
|
||||
return cpuTimeAll;
|
||||
return cpuCycleAll;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_MINOR STATIC UINT64 OsGetIrqAllHisTime(UINT32 num)
|
||||
@@ -711,8 +697,8 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
|
||||
UINT16 curPos;
|
||||
UINT16 prePos = 0;
|
||||
UINT32 intSave;
|
||||
UINT64 cpuTimeAll;
|
||||
UINT64 cpuTimeCurIrq;
|
||||
UINT64 cpuCycleAll;
|
||||
UINT64 cpuCycleCurIrq;
|
||||
|
||||
if (g_irqCpupInitFlg == 0) {
|
||||
return LOS_ERRNO_CPUP_NO_INIT;
|
||||
@@ -726,9 +712,9 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
|
||||
|
||||
OsGetIrqPositions(mode, &curPos, &prePos);
|
||||
if (mode == CPUP_IN_10S) {
|
||||
cpuTimeAll = OsGetIrqAllTime();
|
||||
cpuCycleAll = OsGetIrqAllTime();
|
||||
} else {
|
||||
cpuTimeAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos];
|
||||
cpuCycleAll = g_cpuHistoryTime[curPos] - g_cpuHistoryTime[prePos];
|
||||
}
|
||||
|
||||
for (loopNum = 0; loopNum < LOSCFG_PLATFORM_HWI_LIMIT; loopNum++) {
|
||||
@@ -739,13 +725,13 @@ LITE_OS_SEC_TEXT_MINOR UINT32 LOS_GetAllIrqCpuUsage(UINT16 mode, CPUP_INFO_S *cp
|
||||
cpupInfo[loopNum].usStatus = g_irqCpup[loopNum].status;
|
||||
|
||||
if (mode == CPUP_IN_10S) {
|
||||
cpuTimeCurIrq = OsGetIrqAllHisTime(loopNum);
|
||||
cpuCycleCurIrq = OsGetIrqAllHisTime(loopNum);
|
||||
} else {
|
||||
cpuTimeCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos];
|
||||
cpuCycleCurIrq = g_irqCpup[loopNum].historyTime[curPos] - g_irqCpup[loopNum].historyTime[prePos];
|
||||
}
|
||||
|
||||
if (cpuTimeAll != 0) {
|
||||
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuTimeCurIrq) / cpuTimeAll);
|
||||
if (cpuCycleAll != 0) {
|
||||
cpupInfo[loopNum].uwUsage = (UINT32)((LOS_CPUP_PRECISION * cpuCycleCurIrq) / cpuCycleAll);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ config FS_FAT
|
||||
default n
|
||||
depends on FS_VFS
|
||||
select SUPPORT_FATFS
|
||||
select KAL_CMSIS
|
||||
help
|
||||
Answer Y to enable LiteOS support fat filesystem.
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,82 +32,15 @@
|
||||
#define _GNU_SOURCE 1
|
||||
#include "lfs_adapter.h"
|
||||
#include "los_config.h"
|
||||
#include "los_fs.h"
|
||||
#include "vfs_files.h"
|
||||
#include "vfs_operations.h"
|
||||
#include "vfs_partition.h"
|
||||
#include "vfs_maps.h"
|
||||
#include "vfs_mount.h"
|
||||
#include "securec.h"
|
||||
#include "los_fs.h"
|
||||
|
||||
static struct PartitionCfg g_partitionCfg;
|
||||
static struct DeviceDesc *g_lfsDevice = NULL;
|
||||
|
||||
static uint32_t LfsGetStartAddr(int partition)
|
||||
{
|
||||
if (g_lfsDevice == NULL) {
|
||||
struct DeviceDesc *device = NULL;
|
||||
for (device = getDeviceList(); device != NULL; device = device->dNext) {
|
||||
if (strcmp(device->dFsType, "littlefs") == 0) {
|
||||
g_lfsDevice = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((g_lfsDevice == NULL) || (partition >= g_lfsDevice->dPartNum)) {
|
||||
return INVALID_DEVICE_ADDR;
|
||||
}
|
||||
|
||||
return (uint32_t)g_lfsDevice->dAddrArray[partition];
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_read(const struct lfs_config *c, lfs_block_t block,
|
||||
lfs_off_t off, void *dst, lfs_size_t size)
|
||||
{
|
||||
UINT32 addr = c->block_size * block + off;
|
||||
UINT32 startaddr = LfsGetStartAddr((int)c->context);
|
||||
if (startaddr == INVALID_DEVICE_ADDR) {
|
||||
return -1;
|
||||
}
|
||||
addr += startaddr;
|
||||
|
||||
return (g_partitionCfg.readFunc)((int)c->context, &addr, dst, size);
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_write(const struct lfs_config *c, lfs_block_t block,
|
||||
lfs_off_t off, const void *dst, lfs_size_t size)
|
||||
{
|
||||
UINT32 addr = c->block_size * block + off;
|
||||
UINT32 startaddr = LfsGetStartAddr((int)c->context);
|
||||
if (startaddr == INVALID_DEVICE_ADDR) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr += startaddr;
|
||||
|
||||
return (g_partitionCfg.writeFunc)((int)c->context, &addr, dst, size);
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_erase(const struct lfs_config *c, lfs_block_t block)
|
||||
{
|
||||
UINT32 addr = c->block_size * block;
|
||||
UINT32 startaddr = LfsGetStartAddr((int)c->context);
|
||||
if (startaddr == INVALID_DEVICE_ADDR) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
addr += startaddr;
|
||||
|
||||
return (g_partitionCfg.eraseFunc)((int)c->context, addr, c->block_size);
|
||||
}
|
||||
|
||||
WEAK int littlefs_block_sync(const struct lfs_config *c)
|
||||
{
|
||||
(void)c;
|
||||
return 0;
|
||||
}
|
||||
struct dirent g_nameValue;
|
||||
static pthread_mutex_t g_FslocalMutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
static int ConvertFlagToLfsOpenFlag (int oflags)
|
||||
{
|
||||
@@ -149,33 +82,10 @@ static int LittlefsErrno(int result)
|
||||
return (result < 0) ? -result : result;
|
||||
}
|
||||
|
||||
void LfsConfigAdapter(struct PartitionCfg *pCfg, struct lfs_config *lfsCfg)
|
||||
{
|
||||
lfsCfg->context = (void *)pCfg->partNo;
|
||||
|
||||
lfsCfg->read_size = pCfg->readSize;
|
||||
lfsCfg->prog_size = pCfg->writeSize;
|
||||
lfsCfg->cache_size = pCfg->cacheSize;
|
||||
lfsCfg->block_cycles = pCfg->blockCycles;
|
||||
lfsCfg->lookahead_size = pCfg->lookaheadSize;
|
||||
lfsCfg->block_size = pCfg->blockSize;
|
||||
lfsCfg->block_count = pCfg->blockCount;
|
||||
|
||||
lfsCfg->read = littlefs_block_read;
|
||||
lfsCfg->prog = littlefs_block_write;
|
||||
lfsCfg->erase = littlefs_block_erase;
|
||||
lfsCfg->sync = littlefs_block_sync;
|
||||
|
||||
g_partitionCfg.readFunc = pCfg->readFunc;
|
||||
g_partitionCfg.writeFunc = pCfg->writeFunc;
|
||||
g_partitionCfg.eraseFunc = pCfg->eraseFunc;
|
||||
}
|
||||
|
||||
int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
{
|
||||
int ret;
|
||||
lfs_t *mountHdl = NULL;
|
||||
struct lfs_config *cfg = NULL;
|
||||
|
||||
if ((mp == NULL) || (mp->mPath == NULL) || (data == NULL)) {
|
||||
errno = EFAULT;
|
||||
@@ -183,33 +93,25 @@ int LfsMount(struct MountPoint *mp, unsigned long mountflags, const void *data)
|
||||
goto errout;
|
||||
}
|
||||
|
||||
if (mountflags & MS_REMOUNT) {
|
||||
errno = ENOSYS;
|
||||
ret = (int)LOS_NOK;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mountHdl = (lfs_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
mountHdl = (lfs_t *)malloc(sizeof(lfs_t));
|
||||
if (mountHdl == NULL) {
|
||||
errno = ENODEV;
|
||||
ret = (int)LOS_NOK;
|
||||
goto errout;
|
||||
}
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t) + sizeof(struct lfs_config), 0, sizeof(lfs_t) + sizeof(struct lfs_config));
|
||||
(void)memset_s(mountHdl, sizeof(lfs_t), 0, sizeof(lfs_t));
|
||||
mp->mData = (void *)mountHdl;
|
||||
cfg = (void *)((UINTPTR)mountHdl + sizeof(lfs_t));
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)data, cfg);
|
||||
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, (struct lfs_config *)data);
|
||||
if (ret != 0) {
|
||||
ret = lfs_format((lfs_t *)mp->mData, cfg);
|
||||
ret = lfs_format((lfs_t *)mp->mData, (struct lfs_config*)data);
|
||||
if (ret == 0) {
|
||||
ret = lfs_mount((lfs_t *)mp->mData, cfg);
|
||||
ret = lfs_mount((lfs_t *)mp->mData, (struct lfs_config*)data);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret != 0) {
|
||||
LOSCFG_FS_FREE_HOOK(mountHdl);
|
||||
free(mountHdl);
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
@@ -238,7 +140,7 @@ int LfsUmount(struct MountPoint *mp)
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
|
||||
LOSCFG_FS_FREE_HOOK(mp->mData);
|
||||
free(mp->mData);
|
||||
mp->mData = NULL;
|
||||
return ret;
|
||||
}
|
||||
@@ -332,7 +234,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
|
||||
}
|
||||
|
||||
lfs_t *lfs = (lfs_t *)dir->dMp->mData;
|
||||
lfs_dir_t *dirInfo = (lfs_dir_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_dir_t));
|
||||
lfs_dir_t *dirInfo = (lfs_dir_t *)malloc(sizeof(lfs_dir_t));
|
||||
if (dirInfo == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (int)LOS_NOK;
|
||||
@@ -341,7 +243,7 @@ int LfsOpendir(struct Dir *dir, const char *dirName)
|
||||
(void)memset_s(dirInfo, sizeof(lfs_dir_t), 0, sizeof(lfs_dir_t));
|
||||
ret = lfs_dir_open(lfs, dirInfo, dirName);
|
||||
if (ret != 0) {
|
||||
LOSCFG_FS_FREE_HOOK(dirInfo);
|
||||
free(dirInfo);
|
||||
errno = LittlefsErrno(ret);
|
||||
goto errout;
|
||||
}
|
||||
@@ -376,6 +278,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||
|
||||
ret = lfs_dir_read(lfs, dirInfo, &lfsInfo);
|
||||
if (ret == TRUE) {
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
(void)strncpy_s(dent->d_name, sizeof(dent->d_name), lfsInfo.name, strlen(lfsInfo.name) + 1);
|
||||
if (lfsInfo.type == LFS_TYPE_DIR) {
|
||||
dent->d_type = DT_DIR;
|
||||
@@ -384,6 +287,7 @@ int LfsReaddir(struct Dir *dir, struct dirent *dent)
|
||||
}
|
||||
|
||||
dent->d_reclen = lfsInfo.size;
|
||||
pthread_mutex_unlock(&g_FslocalMutex);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
@@ -418,7 +322,7 @@ int LfsClosedir(struct Dir *dir)
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
|
||||
LOSCFG_FS_FREE_HOOK(dirInfo);
|
||||
free(dirInfo);
|
||||
dir->dData = NULL;
|
||||
|
||||
return ret;
|
||||
@@ -435,7 +339,7 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
lfsHandle = (lfs_file_t *)LOSCFG_FS_MALLOC_HOOK(sizeof(lfs_file_t));
|
||||
lfsHandle = (lfs_file_t *)malloc(sizeof(lfs_file_t));
|
||||
if (lfsHandle == NULL) {
|
||||
errno = ENOMEM;
|
||||
return (int)LOS_NOK;
|
||||
@@ -444,7 +348,7 @@ int LfsOpen(struct File *file, const char *pathName, int openFlag)
|
||||
int lfsOpenFlag = ConvertFlagToLfsOpenFlag(openFlag);
|
||||
ret = lfs_file_open((lfs_t *)file->fMp->mData, lfsHandle, pathName, lfsOpenFlag);
|
||||
if (ret != 0) {
|
||||
LOSCFG_FS_FREE_HOOK(lfsHandle);
|
||||
free(lfsHandle);
|
||||
errno = LittlefsErrno(ret);
|
||||
goto errout;
|
||||
}
|
||||
@@ -563,13 +467,16 @@ int LfsClose(struct File *file)
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&g_FslocalMutex);
|
||||
ret = lfs_file_close((lfs_t *)mp->mData, lfsHandle);
|
||||
pthread_mutex_unlock(&g_FslocalMutex);
|
||||
|
||||
if (ret != 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
|
||||
LOSCFG_FS_FREE_HOOK(file->fData);
|
||||
free(file->fData);
|
||||
file->fData = NULL;
|
||||
return ret;
|
||||
}
|
||||
@@ -652,24 +559,6 @@ int LfsSync(struct File *file)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int LfsFormat(const char *partName, void *privData)
|
||||
{
|
||||
int ret;
|
||||
lfs_t lfs = {0};
|
||||
struct lfs_config cfg = {0};
|
||||
|
||||
(void)partName;
|
||||
|
||||
LfsConfigAdapter((struct PartitionCfg *)privData, &cfg);
|
||||
|
||||
ret = lfs_format(&lfs, &cfg);
|
||||
if (ret != 0) {
|
||||
errno = LittlefsErrno(ret);
|
||||
ret = (int)LOS_NOK;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static struct MountOps g_lfsMnt = {
|
||||
.mount = LfsMount,
|
||||
.umount = LfsUmount,
|
||||
@@ -698,7 +587,7 @@ static struct FileOps g_lfsFops = {
|
||||
|
||||
static struct FsManagement g_lfsMgt = {
|
||||
.fdisk = NULL,
|
||||
.format = LfsFormat,
|
||||
.format = NULL,
|
||||
};
|
||||
|
||||
void LfsInit(void)
|
||||
|
||||
@@ -45,6 +45,6 @@
|
||||
#include "pthread.h"
|
||||
|
||||
#define INVALID_FD (-1)
|
||||
#define INVALID_DEVICE_ADDR ((uint32_t)-1)
|
||||
|
||||
void LfsInit(void);
|
||||
#endif /* _LFS_ADAPTER_H_ */
|
||||
|
||||
@@ -30,23 +30,6 @@
|
||||
config FS_VFS
|
||||
bool "Enable FS VFS"
|
||||
default y
|
||||
select POSIX_FS_API
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support VFS.
|
||||
|
||||
if FS_VFS
|
||||
config FS_LOCK_TIMEOUT
|
||||
int "Filesystem global lock timeout value in tick. -1 for waiting forever"
|
||||
default -1
|
||||
help
|
||||
The timeout value of getting filesystem lock in tick. -1 for waiting forever
|
||||
|
||||
config FS_SUPPORT_MOUNT_TARGET_RECURSIVE
|
||||
bool "Mount target can be recursive"
|
||||
default n
|
||||
depends on FS_VFS
|
||||
|
||||
help
|
||||
Answer Y to enable LiteOS support VFS mount recursively. For example, "/system/bin".
|
||||
endif
|
||||
|
||||
@@ -38,15 +38,12 @@
|
||||
#define _LOS_FS_H_
|
||||
|
||||
#include "los_config.h"
|
||||
#include "los_memory.h"
|
||||
#include "dirent.h"
|
||||
#include "sys/mount.h"
|
||||
#include "sys/statfs.h"
|
||||
#include "sys/stat.h"
|
||||
#include "sys/uio.h"
|
||||
#include "unistd.h"
|
||||
#include <stdarg.h>
|
||||
#include "vfs_maps.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
@@ -54,33 +51,37 @@ extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef LOSCFG_FS_MALLOC_HOOK
|
||||
#define LOSCFG_FS_MALLOC_HOOK(size) LOS_MemAlloc((VOID *)OS_SYS_MEM_ADDR, size)
|
||||
#endif
|
||||
|
||||
#ifndef LOSCFG_FS_FREE_HOOK
|
||||
#define LOSCFG_FS_FREE_HOOK(ptr) LOS_MemFree((VOID *)OS_SYS_MEM_ADDR, ptr)
|
||||
#endif
|
||||
|
||||
struct PartitionCfg {
|
||||
/* partition low-level read func */
|
||||
int (*readFunc)(int partition, UINT32 *offset, void *buf, UINT32 size);
|
||||
/* partition low-level write func */
|
||||
int (*writeFunc)(int partition, UINT32 *offset, const void *buf, UINT32 size);
|
||||
/* partition low-level erase func */
|
||||
int (*eraseFunc)(int partition, UINT32 offset, UINT32 size);
|
||||
|
||||
int readSize; /* size of a block read */
|
||||
int writeSize; /* size of a block write */
|
||||
int blockSize; /* size of an erasable block */
|
||||
int blockCount; /* number of partition blocks */
|
||||
int cacheSize; /* size of block caches */
|
||||
|
||||
int partNo; /* partition number */
|
||||
int lookaheadSize; /* lookahead size */
|
||||
int blockCycles; /* block cycles */
|
||||
};
|
||||
|
||||
int LOS_Open(const char *path, int flags, ...);
|
||||
int LOS_Close(int fd);
|
||||
ssize_t LOS_Read(int fd, void *buff, size_t bytes);
|
||||
ssize_t LOS_Write(int fd, const void *buff, size_t bytes);
|
||||
off_t LOS_Lseek(int fd, off_t off, int whence);
|
||||
int LOS_Stat(const char *path, struct stat *stat);
|
||||
int LOS_Statfs(const char *path, struct statfs *buf);
|
||||
int LOS_Unlink(const char *path);
|
||||
int LOS_Rename(const char *oldpath, const char *newpath);
|
||||
int LOS_Fsync(int fd);
|
||||
DIR *LOS_Opendir(const char *path);
|
||||
struct dirent *LOS_Readdir(DIR *dir);
|
||||
int LOS_Closedir(DIR *dir);
|
||||
int LOS_Mkdir(const char *path, mode_t mode);
|
||||
int LOS_Rmdir(const char *path);
|
||||
int LOS_Lstat(const char *path, struct stat *buffer);
|
||||
int LOS_Fstat(int fd, struct stat *buf);
|
||||
int LOS_Fcntl(int fd, int cmd, ...);
|
||||
int LOS_Ioctl(int fd, int req, ...);
|
||||
ssize_t LOS_Readv(int fd, const struct iovec *iovBuf, int iovcnt);
|
||||
ssize_t LOS_Writev(int fd, const struct iovec *iovBuf, int iovcnt);
|
||||
ssize_t LOS_Pread(int fd, void *buff, size_t bytes, off_t off);
|
||||
ssize_t LOS_Pwrite(int fd, const void *buff, size_t bytes, off_t off);
|
||||
int LOS_Isatty(int fd);
|
||||
int LOS_Access(const char *path, int amode);
|
||||
int LOS_Ftruncate(int fd, off_t length);
|
||||
int LOS_FsUmount(const char *target);
|
||||
int LOS_FsUmount2(const char *target, int flag);
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data);
|
||||
/*
|
||||
* @brief Divide the device into partitions.
|
||||
*
|
||||
@@ -92,7 +93,6 @@ struct PartitionCfg {
|
||||
* @param lengthArray List of partition size. For example:
|
||||
* [0x10000000, 0x2000000], 256M and 512M partitions will be created and
|
||||
* left all will not allocated.
|
||||
* @param addrArray List of partition start addr, partition num same as lengthArray
|
||||
* @param partNum Length of 'lengthArray'.
|
||||
*
|
||||
* @return Return LOS_NOK if error. Return LOS_OK if success.
|
||||
@@ -103,8 +103,8 @@ struct PartitionCfg {
|
||||
* The name is a combination of: 'deviceName'+'p'+'partitionId',
|
||||
* such as "emmc0p0", "emmc0p1", "emmc0p2"...
|
||||
*/
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||
int partNum);
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
|
||||
int partnum);
|
||||
|
||||
/*
|
||||
* @brief Format a partition.
|
||||
@@ -118,39 +118,6 @@ int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int
|
||||
*/
|
||||
int LOS_PartitionFormat(const char *partName, char *fsType, void *data);
|
||||
|
||||
/*
|
||||
* @brief new file system callbacks register.
|
||||
* These callback functions are the adaptation layer implemented by the developer,
|
||||
* used to interconnect the vfs with the new file system.
|
||||
*
|
||||
* LOS_FsRegister must be called after kernel initialization is complete.
|
||||
*
|
||||
* @param fsType file system type, don't register the same type fs more than once.
|
||||
* @param fsMops mount operation of the fs.
|
||||
* @param fsFops file operation of the fs.
|
||||
* @param fsMgt management operation of the fs.
|
||||
*
|
||||
* @return Return LOS_OK if success.
|
||||
* Return LOS_NOK if error.
|
||||
* errno EINVAL: input errors, such as null pointers.
|
||||
* errno ENOMEM: memory may malloc failed.
|
||||
*
|
||||
*/
|
||||
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
|
||||
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
|
||||
|
||||
/*
|
||||
* @brief Lock the whole filesystem to forbid filesystem access.
|
||||
*
|
||||
* @return Return LOS_NOK if error. Return LOS_OK if seccess.
|
||||
*/
|
||||
int LOS_FsLock(void);
|
||||
|
||||
/*
|
||||
* @brief Unlock the whole filesystem to allow filesystem access.
|
||||
*/
|
||||
void LOS_FsUnlock(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
|
||||
@@ -49,17 +49,21 @@
|
||||
|
||||
#ifdef LOSCFG_FS_FAT
|
||||
#include "fatfs_conf.h"
|
||||
#define __FAT_NFILE FAT_MAX_OPEN_FILES
|
||||
#else
|
||||
#define __FAT_NFILE 0
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_FS_LITTLEFS
|
||||
#include "lfs_conf.h"
|
||||
#define __LFS_NFILE LOSCFG_LFS_MAX_OPEN_FILES
|
||||
#else
|
||||
#define __LFS_NFILE 0
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NFILE_DESCRIPTORS
|
||||
#define CONFIG_NFILE_DESCRIPTORS 256
|
||||
#endif
|
||||
#define CONFIG_NFILE_DESCRIPTORS (__FAT_NFILE + __LFS_NFILE)
|
||||
|
||||
#define NR_OPEN_DEFAULT (CONFIG_NFILE_DESCRIPTORS - MIN_START_FD)
|
||||
#define NR_OPEN_DEFAULT CONFIG_NFILE_DESCRIPTORS
|
||||
|
||||
/* time configure */
|
||||
|
||||
@@ -84,9 +88,4 @@
|
||||
|
||||
#define MAX_DIRENT_NUM 14 // 14 means 4096 length buffer can store 14 dirent, see struct DIR
|
||||
|
||||
/* max number of open directories */
|
||||
#ifndef LOSCFG_MAX_OPEN_DIRS
|
||||
#define LOSCFG_MAX_OPEN_DIRS 10
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
|
||||
static struct File g_files[NR_OPEN_DEFAULT];
|
||||
|
||||
int FileToFd(const struct File *file)
|
||||
int FileToFd(struct File *file)
|
||||
{
|
||||
if (file == NULL) {
|
||||
return (int)LOS_NOK;
|
||||
|
||||
@@ -89,7 +89,7 @@ struct Dir {
|
||||
void *dData;
|
||||
};
|
||||
|
||||
int FileToFd(const struct File *file);
|
||||
int FileToFd(struct File *file);
|
||||
struct File *FdToFile(int fd);
|
||||
struct File *VfsFileGet(void);
|
||||
struct File *VfsFileGetSpec(int fd);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,6 @@
|
||||
#include "securec.h"
|
||||
#include "los_debug.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_fs.h"
|
||||
|
||||
struct FsMap *g_fsMap = NULL;
|
||||
|
||||
@@ -41,67 +40,49 @@ struct FsMap *VfsFsMapGet(const char *fsType)
|
||||
{
|
||||
struct FsMap *curr = g_fsMap;
|
||||
|
||||
(void)LOS_FsLock();
|
||||
(void)VfsLock();
|
||||
while (curr != NULL) {
|
||||
if ((curr->fsType != NULL) && (fsType != NULL) &&
|
||||
(strcmp(curr->fsType, fsType) == 0)) {
|
||||
LOS_FsUnlock();
|
||||
(void)VfsUnlock();
|
||||
return curr;
|
||||
}
|
||||
curr = curr->next;
|
||||
}
|
||||
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
|
||||
const struct FileOps *fsFops, const struct FsManagement *fsMgt)
|
||||
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
|
||||
struct FileOps *fsFops, struct FsManagement *fsMgt)
|
||||
{
|
||||
size_t len;
|
||||
if ((fsMops == NULL) || (fsFops == NULL)) {
|
||||
VFS_ERRNO_SET(EINVAL);
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
struct FsMap *newfs = (struct FsMap *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct FsMap));
|
||||
struct FsMap *newfs = (struct FsMap *)malloc(sizeof(struct FsMap));
|
||||
if (newfs == NULL) {
|
||||
PRINT_ERR("Fs register malloc failed, fsType %s.\n", fsType);
|
||||
VFS_ERRNO_SET(ENOMEM);
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
(void)memset_s(newfs, sizeof(struct FsMap), 0, sizeof(struct FsMap));
|
||||
|
||||
len = strlen(fsType) + 1;
|
||||
newfs->fsType = LOSCFG_FS_MALLOC_HOOK(len);
|
||||
newfs->fsType = strdup(fsType);
|
||||
if (newfs->fsType == NULL) {
|
||||
LOSCFG_FS_FREE_HOOK(newfs);
|
||||
VFS_ERRNO_SET(ENOMEM);
|
||||
free(newfs);
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
(void)strcpy_s((char *)newfs->fsType, len, fsType);
|
||||
|
||||
newfs->fsMops = fsMops;
|
||||
newfs->fsFops = fsFops;
|
||||
newfs->fsMgt = fsMgt;
|
||||
newfs->fsRefs = 0;
|
||||
|
||||
(void)LOS_FsLock();
|
||||
(void)VfsLock();
|
||||
newfs->next = g_fsMap;
|
||||
g_fsMap = newfs;
|
||||
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
int LOS_FsRegister(const char *fsType, const struct MountOps *fsMops,
|
||||
const struct FileOps *fsFops, const struct FsManagement *fsMgt)
|
||||
{
|
||||
if (VfsFsMapGet(fsType) != NULL) {
|
||||
PRINT_ERR("fsType has been registered or fsType error\n");
|
||||
VFS_ERRNO_SET(EINVAL);
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
return OsFsRegister(fsType, fsMops, fsFops, fsMgt);
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ struct FsMap {
|
||||
struct FsMap *next;
|
||||
};
|
||||
|
||||
int OsFsRegister(const char *fsType, const struct MountOps *fsMops,
|
||||
const struct FileOps *fsFops, const struct FsManagement *fsMgt);
|
||||
int OsFsRegister(const char *fsType, struct MountOps *fsMops,
|
||||
struct FileOps *fsFops, struct FsManagement *fsMgt);
|
||||
struct FsMap *VfsFsMapGet(const char *fsType);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -33,9 +33,6 @@
|
||||
#include "vfs_config.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "limits.h"
|
||||
#include "errno.h"
|
||||
#include "securec.h"
|
||||
#include "vfs_operations.h"
|
||||
#include "los_compiler.h"
|
||||
#include "los_debug.h"
|
||||
@@ -63,13 +60,14 @@ static void MpDeleteFromList(struct MountPoint *mp)
|
||||
}
|
||||
}
|
||||
|
||||
#if (LOSCFG_FS_SUPPORT_MOUNT_TARGET_RECURSIVE == 1)
|
||||
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||
{
|
||||
struct MountPoint *mp = g_mountPoints;
|
||||
struct MountPoint *bestMp = NULL;
|
||||
int bestMatches = 0;
|
||||
|
||||
if (path == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
if (pathInMp != NULL) {
|
||||
*pathInMp = NULL;
|
||||
}
|
||||
@@ -121,171 +119,53 @@ struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||
next:
|
||||
mp = mp->mNext;
|
||||
}
|
||||
|
||||
return bestMp;
|
||||
}
|
||||
#else
|
||||
struct MountPoint *VfsMpFind(const char *path, const char **pathInMp)
|
||||
{
|
||||
struct MountPoint *mp = g_mountPoints;
|
||||
const char *iPath = path;
|
||||
const char *mPath = NULL;
|
||||
const char *target = NULL;
|
||||
|
||||
if (pathInMp != NULL) {
|
||||
*pathInMp = NULL;
|
||||
}
|
||||
while (*iPath == '/') {
|
||||
++iPath;
|
||||
}
|
||||
|
||||
while ((mp != NULL) && (mp->mPath != NULL)) {
|
||||
mPath = mp->mPath;
|
||||
target = iPath;
|
||||
|
||||
while (*mPath == '/') {
|
||||
++mPath;
|
||||
}
|
||||
|
||||
while ((*mPath != '\0') && (*mPath != '/') &&
|
||||
(*target != '\0') && (*target != '/')) {
|
||||
if (*mPath != *target) {
|
||||
break;
|
||||
}
|
||||
++mPath;
|
||||
++target;
|
||||
}
|
||||
if (((*mPath == '\0') || (*mPath == '/')) &&
|
||||
((*target == '\0') || (*target == '/'))) {
|
||||
if (pathInMp != NULL) {
|
||||
*pathInMp = path;
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
mp = mp->mNext;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
STATIC struct MountPoint *VfsMountPointInit(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags)
|
||||
{
|
||||
struct MountPoint *mp = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
size_t ssize = 0;
|
||||
size_t tsize;
|
||||
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
errno = ENODEV;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (source != NULL) {
|
||||
ssize = strlen(source) + 1;
|
||||
}
|
||||
|
||||
tsize = strlen(target) + 1;
|
||||
|
||||
mp = (struct MountPoint *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct MountPoint) + ssize + tsize);
|
||||
if (mp == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
|
||||
if (source != NULL && strcpy_s((char *)mp + sizeof(struct MountPoint), ssize, source) != EOK) {
|
||||
LOSCFG_FS_FREE_HOOK(mp);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strcpy_s((char *)mp + sizeof(struct MountPoint) + ssize, tsize, target) != EOK) {
|
||||
LOSCFG_FS_FREE_HOOK(mp);
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
mp->mDev = source ? (char *)mp + sizeof(struct MountPoint) : NULL;
|
||||
mp->mPath = (char *)mp + sizeof(struct MountPoint) + ssize;
|
||||
|
||||
return mp;
|
||||
}
|
||||
|
||||
STATIC int VfsRemount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
(VOID)source;
|
||||
(VOID)fsType;
|
||||
struct MountPoint *mp;
|
||||
|
||||
mp = VfsMpFind(target, NULL);
|
||||
if (mp == NULL) {
|
||||
errno = EINVAL;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
LOS_ASSERT(mp->mFs != NULL);
|
||||
LOS_ASSERT(mp->mFs->fsMops != NULL);
|
||||
LOS_ASSERT(mp->mFs->fsMops->mount != NULL);
|
||||
|
||||
return mp->mFs->fsMops->mount(mp, mountflags, data);
|
||||
}
|
||||
|
||||
STATIC int VfsMountPathCheck(const char *target)
|
||||
{
|
||||
/* target must begin with '/', for example /system, /data, etc. */
|
||||
if ((target == NULL) || (target[0] != '/')) {
|
||||
errno = EINVAL;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
if (strlen(target) >= PATH_MAX) {
|
||||
errno = ENAMETOOLONG;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
int mount(const char *source, const char *target,
|
||||
int LOS_FsMount(const char *source, const char *target,
|
||||
const char *fsType, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
int ret;
|
||||
struct MountPoint *mp = NULL;
|
||||
struct FsMap *mFs = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
|
||||
if (VfsMountPathCheck(target) != LOS_OK) {
|
||||
/* target must begin with '/', for example /system, /data, etc. */
|
||||
if ((target == NULL) || (target[0] != '/')) {
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
(void)LOS_FsLock();
|
||||
|
||||
if (mountflags & MS_REMOUNT) {
|
||||
ret = VfsRemount(source, target, fsType, mountflags, data);
|
||||
LOS_FsUnlock();
|
||||
return ret;
|
||||
(void)VfsLock();
|
||||
/* find mp by target, to see if it was mounted */
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if (mp != NULL && pathInMp != NULL) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp = VfsMountPointInit(source, target, fsType, mountflags);
|
||||
/* Find fsMap coresponding to the fsType */
|
||||
mFs = VfsFsMapGet(fsType);
|
||||
if ((mFs == NULL) || (mFs->fsMops == NULL) || (mFs->fsMops->mount == NULL)) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp = (struct MountPoint *)malloc(sizeof(struct MountPoint));
|
||||
if (mp == NULL) {
|
||||
LOS_FsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp->mFs = mFs;
|
||||
mp->mDev = NULL;
|
||||
if (source != NULL) {
|
||||
mp->mDev = strdup(source);
|
||||
if (mp->mDev == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
}
|
||||
|
||||
mp->mPath = strdup(target);
|
||||
if (mp->mPath == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
ret = mp->mFs->fsMops->mount(mp, mountflags, data);
|
||||
@@ -294,29 +174,34 @@ int mount(const char *source, const char *target,
|
||||
PRINT_ERR("mount failed, target %s.\n", target);
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp->mRefs = 0;
|
||||
mp->mWriteEnable = (mountflags & MS_RDONLY) ? FALSE : TRUE;
|
||||
mp->mFs->fsRefs++;
|
||||
mp->mNext = g_mountPoints;
|
||||
g_mountPoints = mp;
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
|
||||
errout:
|
||||
LOSCFG_FS_FREE_HOOK(mp);
|
||||
LOS_FsUnlock();
|
||||
free((void *)mp->mPath);
|
||||
free((void *)mp->mDev);
|
||||
free(mp);
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
int umount(const char *target)
|
||||
int LOS_FsUmount(const char *target)
|
||||
{
|
||||
struct MountPoint *mp = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
int ret = (int)LOS_NOK;
|
||||
|
||||
(void)LOS_FsLock();
|
||||
if (VfsMountPathCheck(target) != LOS_OK) {
|
||||
(void)VfsLock();
|
||||
if (target == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp = VfsMpFind(target, NULL);
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if ((mp == NULL) || (mp->mRefs != 0)) {
|
||||
goto errout;
|
||||
}
|
||||
@@ -335,18 +220,20 @@ int umount(const char *target)
|
||||
/* delete mp from mount list */
|
||||
MpDeleteFromList(mp);
|
||||
mp->mFs->fsRefs--;
|
||||
LOSCFG_FS_FREE_HOOK(mp);
|
||||
free((void *)mp->mPath);
|
||||
free((void *)mp->mDev);
|
||||
free(mp);
|
||||
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
|
||||
errout:
|
||||
PRINT_ERR("umount2 failed, target %s.\n", target);
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
static void CloseFdsInMp(const struct MountPoint *mp)
|
||||
static void CloseFdsInMp(struct MountPoint *mp)
|
||||
{
|
||||
for (int fd = 0; fd < NR_OPEN_DEFAULT; fd++) {
|
||||
struct File *f = FdToFile(fd);
|
||||
@@ -361,17 +248,18 @@ static void CloseFdsInMp(const struct MountPoint *mp)
|
||||
}
|
||||
}
|
||||
|
||||
int umount2(const char *target, int flag)
|
||||
int LOS_FsUmount2(const char *target, int flag)
|
||||
{
|
||||
struct MountPoint *mp = NULL;
|
||||
const char *pathInMp = NULL;
|
||||
int ret = (int)LOS_NOK;
|
||||
|
||||
(void)LOS_FsLock();
|
||||
if (VfsMountPathCheck(target) != LOS_OK) {
|
||||
(void)VfsLock();
|
||||
if (target == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
|
||||
mp = VfsMpFind(target, NULL);
|
||||
mp = VfsMpFind(target, &pathInMp);
|
||||
if ((mp == NULL) || (mp->mRefs != 0) ||
|
||||
(mp->mFs == NULL) || (mp->mFs->fsMops == NULL) ||
|
||||
(mp->mFs->fsMops->umount2 == NULL)) {
|
||||
@@ -392,13 +280,15 @@ int umount2(const char *target, int flag)
|
||||
/* delete mp from mount list */
|
||||
MpDeleteFromList(mp);
|
||||
mp->mFs->fsRefs--;
|
||||
LOSCFG_FS_FREE_HOOK(mp);
|
||||
free((void *)mp->mPath);
|
||||
free((void *)mp->mDev);
|
||||
free(mp);
|
||||
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return LOS_OK;
|
||||
|
||||
errout:
|
||||
PRINT_ERR("umount2 failed, target %s.\n", target);
|
||||
LOS_FsUnlock();
|
||||
VfsUnlock();
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,8 @@ extern "C" {
|
||||
extern UINT32 g_fsMutex;
|
||||
|
||||
int OsVfsInit(void);
|
||||
int VfsLock(void);
|
||||
void VfsUnlock(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -37,8 +37,6 @@
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
|
||||
static struct DeviceDesc *g_deviceList = NULL;
|
||||
|
||||
int GetPartIdByPartName(const char *partName)
|
||||
{
|
||||
if (partName == NULL) {
|
||||
@@ -47,7 +45,7 @@ int GetPartIdByPartName(const char *partName)
|
||||
|
||||
/* the character next to p is the partId */
|
||||
char *p = strrchr(partName, 'p');
|
||||
if (p != NULL) {
|
||||
if (p + 1 != NULL) {
|
||||
return atoi(p + 1);
|
||||
}
|
||||
|
||||
@@ -69,89 +67,16 @@ int GetDevIdByDevName(const char *dev)
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
struct DeviceDesc *getDeviceList(VOID)
|
||||
{
|
||||
return g_deviceList;
|
||||
}
|
||||
|
||||
static int AddDevice(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||
int partNum)
|
||||
{
|
||||
size_t len;
|
||||
struct DeviceDesc *prev = NULL;
|
||||
for (prev = g_deviceList; prev != NULL; prev = prev->dNext) {
|
||||
if (strcmp(prev->dDev, dev) == 0) {
|
||||
errno = -EEXIST;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
}
|
||||
|
||||
if (addrArray == NULL) {
|
||||
errno = -EFAULT;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
prev = (struct DeviceDesc *)LOSCFG_FS_MALLOC_HOOK(sizeof(struct DeviceDesc));
|
||||
if (prev == NULL) {
|
||||
errno = -ENOMEM;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
len = strlen(dev) + 1;
|
||||
prev->dDev = LOSCFG_FS_MALLOC_HOOK(len);
|
||||
len = strlen(fsType) + 1;
|
||||
prev->dFsType = LOSCFG_FS_MALLOC_HOOK(len);
|
||||
prev->dAddrArray = (int *)LOSCFG_FS_MALLOC_HOOK(partNum * sizeof(int));
|
||||
if (prev->dDev == NULL || prev->dFsType == NULL || prev->dAddrArray == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
(void)strcpy_s((char *)prev->dDev, len, dev);
|
||||
(void)strcpy_s((char *)prev->dFsType, len, fsType);
|
||||
(void)memcpy_s(prev->dAddrArray, partNum * sizeof(int), addrArray, partNum * sizeof(int));
|
||||
|
||||
if (lengthArray != NULL) {
|
||||
prev->dLengthArray = (int *)LOSCFG_FS_MALLOC_HOOK(partNum * sizeof(int));
|
||||
if (prev->dLengthArray == NULL) {
|
||||
goto errout;
|
||||
}
|
||||
(void)memcpy_s(prev->dLengthArray, partNum * sizeof(int), lengthArray, partNum * sizeof(int));
|
||||
}
|
||||
|
||||
prev->dNext = g_deviceList;
|
||||
prev->dPartNum = partNum;
|
||||
g_deviceList = prev;
|
||||
return LOS_OK;
|
||||
errout:
|
||||
if (prev->dDev != NULL) {
|
||||
LOSCFG_FS_FREE_HOOK((void *)prev->dDev);
|
||||
}
|
||||
if (prev->dFsType != NULL) {
|
||||
LOSCFG_FS_FREE_HOOK((void *)prev->dFsType);
|
||||
}
|
||||
if (prev->dAddrArray != NULL) {
|
||||
LOSCFG_FS_FREE_HOOK((void *)prev->dAddrArray);
|
||||
}
|
||||
if (prev->dLengthArray != NULL) {
|
||||
LOSCFG_FS_FREE_HOOK((void *)prev->dLengthArray);
|
||||
}
|
||||
|
||||
LOSCFG_FS_FREE_HOOK(prev);
|
||||
errno = -ENOMEM;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
|
||||
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray, int *addrArray,
|
||||
int partNum)
|
||||
int LOS_DiskPartition(const char *dev, const char *fsType, int *lengthArray,
|
||||
int partnum)
|
||||
{
|
||||
int ret = (int)LOS_NOK;
|
||||
struct FsMap *fMap = VfsFsMapGet(fsType);
|
||||
if ((fMap != NULL) && (fMap->fsMgt != NULL) &&
|
||||
(fMap->fsMgt->fdisk != NULL)) {
|
||||
ret = fMap->fsMgt->fdisk(dev, lengthArray, partNum);
|
||||
return ret;
|
||||
ret = fMap->fsMgt->fdisk(dev, lengthArray, partnum);
|
||||
}
|
||||
|
||||
ret = AddDevice(dev, fsType, lengthArray, addrArray, partNum);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -163,7 +88,8 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
|
||||
format is not allowed when the device has been mounted. */
|
||||
struct MountPoint *iter = NULL;
|
||||
LOS_MP_FOR_EACH_ENTRY(iter) {
|
||||
if ((iter->mPath != NULL) && (strcmp(iter->mPath, partName) == 0)) {
|
||||
if ((iter->mFs != NULL) && (iter->mFs->fsType != NULL) &&
|
||||
strcmp(iter->mFs->fsType, fsType) == 0) {
|
||||
errno = EBUSY;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
@@ -174,6 +100,5 @@ int LOS_PartitionFormat(const char *partName, char *fsType, void *data)
|
||||
(fMap->fsMgt->format != NULL)) {
|
||||
ret = fMap->fsMgt->format(partName, data);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@
|
||||
#ifndef _VFS_PARTITION_H_
|
||||
#define _VFS_PARTITION_H_
|
||||
|
||||
#include "los_compiler.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -43,19 +41,6 @@ extern "C" {
|
||||
|
||||
int GetPartIdByPartName(const char *partName);
|
||||
int GetDevIdByDevName(const char *dev);
|
||||
struct DeviceDesc *getDeviceList(void);
|
||||
|
||||
struct DeviceDesc {
|
||||
struct FsMap *dFs; /* file system info */
|
||||
struct DeviceDesc *dNext; /* point to next mount point */
|
||||
const char *dPath; /* target path, /system, /usr, etc. */
|
||||
const char *dDev; /* device, "emmc0p0", "emmc0p1", etc. */
|
||||
void *dData; /* specific file system handle */
|
||||
const char *dFsType; /* file system type */
|
||||
int *dLengthArray; /* point to device partitions length array */
|
||||
int *dAddrArray; /* point to device partitions address array */
|
||||
int dPartNum; /* number of device partitions */
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -34,7 +34,7 @@ module_switch = defined(LOSCFG_NET_LWIP_SACK)
|
||||
module_name = "lwip"
|
||||
kernel_module(module_name) {
|
||||
sources = LWIP_PORTING_FILES + LWIPNOAPPSFILES - [ "$LWIPDIR/api/sockets.c" ]
|
||||
include_dirs = [ "//commonlibrary/utils_lite/include" ]
|
||||
include_dirs = [ "//utils/native/lite/include" ]
|
||||
}
|
||||
|
||||
config("public") {
|
||||
|
||||
@@ -125,7 +125,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
|
||||
int squash_pos = ipv6_blocks;
|
||||
int i;
|
||||
const unsigned char *sc = (const unsigned char *)cp;
|
||||
const unsigned char *ss = (const unsigned char *)(cp - 1);
|
||||
const char *ss = cp-1;
|
||||
|
||||
for (; ; sc++) {
|
||||
if (current_block_index >= ipv6_blocks) {
|
||||
@@ -142,7 +142,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
|
||||
break;
|
||||
} else if (*sc == ':') {
|
||||
if (sc - ss == 1) {
|
||||
if (sc != (const unsigned char *)cp || sc[1] != ':') {
|
||||
if (sc != cp || sc[1] != ':') {
|
||||
return 0; // address begins with a single ':' or contains ":::"
|
||||
} // else address begins with one valid "::"
|
||||
} else {
|
||||
@@ -163,7 +163,7 @@ int ip6addr_aton(const char *cp, ip6_addr_t *addr)
|
||||
#if LWIP_IPV4
|
||||
} else if (*sc == '.' && current_block_index < ipv6_blocks - 1) {
|
||||
ip4_addr_t ip4;
|
||||
int ret = ip4addr_aton((const char *)(ss + 1), &ip4);
|
||||
int ret = ip4addr_aton(ss+1, &ip4);
|
||||
if (!ret) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -240,7 +240,4 @@
|
||||
#define LWIP_SOCKET_OFFSET CONFIG_NFILE_DESCRIPTORS
|
||||
#endif
|
||||
|
||||
#define LWIP_SOCKET_IOCTL 0
|
||||
#define LWIP_SOCKET_FCNTL 0
|
||||
|
||||
#endif /* _LWIP_PORTING_LWIPOPTS_H_ */
|
||||
|
||||
@@ -373,9 +373,8 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
|
||||
while (!ping_kill && (forever || (i < cnt))) {
|
||||
iecho->seqno = htons((u16_t)i);
|
||||
iecho->chksum = 0;
|
||||
#if (CHECKSUM_GEN_ICMP > 0)
|
||||
iecho->chksum = inet_chksum((void *)iecho, iecho_len);
|
||||
#endif
|
||||
|
||||
ret = sendto(sfd, iecho, iecho_len, 0, (struct sockaddr *)&to, (socklen_t)sizeof(to));
|
||||
if (ret < 0) {
|
||||
perror("Ping: sending ICMP echo request failed\n");
|
||||
@@ -470,9 +469,8 @@ LWIP_STATIC int OsPingFunc(u32_t *parg)
|
||||
}
|
||||
intrvl -= 1000; /* 1000: 1000ms = 1s */
|
||||
sys_msleep(1000); /* 1000: 1000ms = 1s */
|
||||
if (ping_kill == 1) {
|
||||
if (ping_kill == 1)
|
||||
break;
|
||||
}
|
||||
} while (intrvl > 0);
|
||||
succ_cnt++;
|
||||
break;
|
||||
@@ -530,7 +528,7 @@ u32_t OsShellPing(int argc, const char **argv)
|
||||
{
|
||||
int ret;
|
||||
u32_t i = 0;
|
||||
u32_t count;
|
||||
u32_t count = 0;
|
||||
int count_set = 0;
|
||||
u32_t interval = 1000; /* default ping interval */
|
||||
u32_t data_len = 48; /* default data length */
|
||||
|
||||
@@ -211,7 +211,6 @@ int close(int fd)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_IOCTL
|
||||
#ifdef LWIP_SOCKET_IOCTL_FUNC
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
@@ -223,9 +222,7 @@ int ioctl(int fd, int req, ...)
|
||||
return lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_FCNTL
|
||||
#ifdef LWIP_SOCKET_FCNTL_FUNC
|
||||
int fcntl(int fd, int cmd, ...)
|
||||
{
|
||||
@@ -237,7 +234,6 @@ int fcntl(int fd, int cmd, ...)
|
||||
return lwip_fcntl(fd, cmd, val);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if LWIP_SOCKET_SELECT
|
||||
#ifdef LWIP_SOCKET_SELECT_FUNC
|
||||
|
||||
@@ -130,7 +130,7 @@ STATIC BOOL OsPmTickTimerStop(LosPmCB *pm)
|
||||
LosPmTickTimer *tickTimer = pm->tickTimer;
|
||||
|
||||
if ((tickTimer == NULL) || (tickTimer->tickLock == NULL) ||
|
||||
(pm->sysMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||
(pm->pmMode == LOS_SYS_NORMAL_SLEEP)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -264,7 +264,6 @@ STATIC UINT32 OsPmSuspendSleep(LosPmCB *pm)
|
||||
|
||||
if (pm->sysctrl->suspendCheck != NULL) {
|
||||
pm->sysctrl->suspendCheck(mode);
|
||||
pm->sysMode = pm->pmMode;
|
||||
}
|
||||
|
||||
tickTimerStop = OsPmTickTimerStop(pm);
|
||||
|
||||
@@ -67,7 +67,7 @@ int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long
|
||||
|
||||
int SysSchedSetScheduler(unsigned int tid, int policy, int priority)
|
||||
{
|
||||
if ((tid == 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ int *SysSchedGetArea(unsigned int tid)
|
||||
unsigned int intSave;
|
||||
int *area = NULL;
|
||||
|
||||
if ((tid == 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -82,6 +82,7 @@ LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdFree(INT32 argc, const CHAR *argv[])
|
||||
#if (LOSCFG_MEM_WATERLINE == 1)
|
||||
LITE_OS_SEC_TEXT_MINOR UINT32 OsShellCmdWaterLine(INT32 argc, const CHAR *argv[])
|
||||
{
|
||||
UINT32 ret;
|
||||
LOS_MEM_POOL_STATUS poolStatus;
|
||||
|
||||
if (argc > 1) {
|
||||
|
||||
@@ -181,7 +181,6 @@ VOID OsLs(const CHAR *pathname)
|
||||
d = opendir(path);
|
||||
if (d == NULL) {
|
||||
PRINT_ERR("No such directory = %s\n", path);
|
||||
free(path);
|
||||
} else {
|
||||
PRINTK("Directory %s:\n", path);
|
||||
do {
|
||||
@@ -545,6 +544,11 @@ STATIC INT32 OsShellCmdDoRmdir(const CHAR *pathname)
|
||||
}
|
||||
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
|
||||
size_t fullPathBufSize = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
|
||||
if (fullPathBufSize <= 0) {
|
||||
PRINTK("buffer size is invalid!\n");
|
||||
(VOID)closedir(d);
|
||||
return -1;
|
||||
}
|
||||
fullpath = (CHAR *)malloc(fullPathBufSize);
|
||||
if (fullpath == NULL) {
|
||||
PRINTK("malloc failure!\n");
|
||||
|
||||
@@ -86,6 +86,10 @@ optimize_config_cflags = []
|
||||
optimize_config_asmflags = []
|
||||
|
||||
if (defined(LOSCFG_COMPILE_DEBUG)) {
|
||||
optimize_config_cflags += [
|
||||
"-g",
|
||||
"-gdwarf-2",
|
||||
]
|
||||
optimize_config_cflags += [ "-On" ]
|
||||
} else {
|
||||
if (defined(LOSCFG_COMPILE_OPTIMIZE)) {
|
||||
@@ -114,14 +118,12 @@ kconfig_config_cflags += [
|
||||
warn_config_cflags = []
|
||||
warn_config_asmflags = []
|
||||
|
||||
if (!defined(LOSCFG_TEST)) {
|
||||
warn_config_cflags += [
|
||||
"--warnings_affect_exit_code",
|
||||
"--warnings_are_errors",
|
||||
"--warn_about_c_style_casts",
|
||||
"--warn_about_incomplete_constructors",
|
||||
]
|
||||
}
|
||||
warn_config_cflags += [
|
||||
"--warnings_affect_exit_code",
|
||||
"--warnings_are_errors",
|
||||
"--warn_about_c_style_casts",
|
||||
"--warn_about_incomplete_constructors",
|
||||
]
|
||||
|
||||
#
|
||||
# dialect_config
|
||||
|
||||
@@ -42,9 +42,6 @@
|
||||
#include "los_task.h"
|
||||
#include "los_timer.h"
|
||||
#include "los_debug.h"
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
#include "los_arch.h"
|
||||
#endif
|
||||
|
||||
#include "string.h"
|
||||
#include "securec.h"
|
||||
@@ -981,17 +978,21 @@ osStatus_t osEventFlagsDelete(osEventFlagsId_t ef_id)
|
||||
{
|
||||
PEVENT_CB_S pstEventCB = (PEVENT_CB_S)ef_id;
|
||||
UINT32 intSave;
|
||||
osStatus_t ret = osOK;
|
||||
osStatus_t ret;
|
||||
if (OS_INT_ACTIVE) {
|
||||
return osErrorISR;
|
||||
}
|
||||
intSave = LOS_IntLock();
|
||||
if (LOS_EventDestroy(pstEventCB) != LOS_OK) {
|
||||
if (LOS_EventDestroy(pstEventCB) == LOS_OK) {
|
||||
ret = osOK;
|
||||
} else {
|
||||
ret = osErrorParameter;
|
||||
}
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
if (LOS_MemFree(m_aucSysMem0, (void *)pstEventCB) != LOS_OK) {
|
||||
if (LOS_MemFree(m_aucSysMem0, (void *)pstEventCB) == LOS_OK) {
|
||||
ret = osOK;
|
||||
} else {
|
||||
ret = osErrorParameter;
|
||||
}
|
||||
|
||||
@@ -1005,10 +1006,6 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||
UINT32 ret;
|
||||
UINT32 muxId;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
UNUSED(attr);
|
||||
|
||||
if (OS_INT_ACTIVE) {
|
||||
@@ -1017,9 +1014,6 @@ osMutexId_t osMutexNew(const osMutexAttr_t *attr)
|
||||
|
||||
ret = LOS_MuxCreate(&muxId);
|
||||
if (ret == LOS_OK) {
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(muxId), regLR);
|
||||
#endif
|
||||
return (osMutexId_t)(GET_MUX(muxId));
|
||||
} else {
|
||||
return (osMutexId_t)NULL;
|
||||
|
||||
@@ -35,6 +35,7 @@ choice
|
||||
|
||||
config LIBC_MUSL
|
||||
bool "musl libc"
|
||||
rsource "musl/Kconfig"
|
||||
|
||||
config LIBC_NEWLIB
|
||||
bool "newlibc"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 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:
|
||||
@@ -33,7 +33,10 @@ import("//third_party/musl/porting/liteos_m/kernel/musl.gni")
|
||||
module_switch = defined(LOSCFG_LIBC_MUSL)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [ "malloc.c" ]
|
||||
sources = [
|
||||
"fs.c",
|
||||
"malloc.c",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
|
||||
deps = [ "//third_party/musl/porting/liteos_m/kernel" ]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 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:
|
||||
@@ -27,21 +27,13 @@
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import("//kernel/liteos_m/liteos.gni")
|
||||
if LIBC_MUSL
|
||||
|
||||
module_name = "arch"
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"los_context.c",
|
||||
"los_dispatch.S",
|
||||
"los_exc.S",
|
||||
"los_interrupt.c",
|
||||
"los_mpu.c",
|
||||
"los_timer.c",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
}
|
||||
config LIBC_MUSL_FS
|
||||
bool "Enable POSIX file system API support"
|
||||
default y
|
||||
depends on FS_VFS
|
||||
help
|
||||
This enables POSIX style file system related APIs.
|
||||
|
||||
config("public") {
|
||||
include_dirs = [ "." ]
|
||||
}
|
||||
endif # LIBC_MUSL
|
||||
298
kal/libc/musl/fs.c
Normal file
298
kal/libc/musl/fs.c
Normal file
@@ -0,0 +1,298 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "los_config.h"
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/statfs.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef LOSCFG_LIBC_MUSL_FS
|
||||
#include "los_fs.h"
|
||||
|
||||
int mount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
return LOS_FsMount(source, target, filesystemtype, mountflags, data);
|
||||
}
|
||||
|
||||
int umount(const char *target)
|
||||
{
|
||||
return LOS_FsUmount(target);
|
||||
}
|
||||
|
||||
int umount2(const char *target, int flag)
|
||||
{
|
||||
return LOS_FsUmount2(target, flag);
|
||||
}
|
||||
|
||||
int open(const char *path, int oflag, ...)
|
||||
{
|
||||
va_list vaList;
|
||||
va_start(vaList, oflag);
|
||||
int ret;
|
||||
ret = LOS_Open(path, oflag, vaList);
|
||||
va_end(vaList);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int close(int fd)
|
||||
{
|
||||
return LOS_Close(fd);
|
||||
}
|
||||
|
||||
ssize_t read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
return LOS_Read(fd, buf, nbyte);
|
||||
}
|
||||
|
||||
ssize_t write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
return LOS_Write(fd, buf, nbyte);
|
||||
}
|
||||
|
||||
off_t lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
return LOS_Lseek(fd, offset, whence);
|
||||
}
|
||||
|
||||
int unlink(const char *path)
|
||||
{
|
||||
return LOS_Unlink(path);
|
||||
}
|
||||
|
||||
int fstat(int fd, struct stat *buf)
|
||||
{
|
||||
return LOS_Fstat(fd, buf);
|
||||
}
|
||||
|
||||
int stat(const char *path, struct stat *buf)
|
||||
{
|
||||
return LOS_Stat(path, buf);
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
{
|
||||
return LOS_Fsync(fd);
|
||||
}
|
||||
|
||||
int mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
return LOS_Mkdir(path, mode);
|
||||
}
|
||||
|
||||
DIR *opendir(const char *dirName)
|
||||
{
|
||||
return LOS_Opendir(dirName);
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dir)
|
||||
{
|
||||
return LOS_Readdir(dir);
|
||||
}
|
||||
|
||||
int closedir(DIR *dir)
|
||||
{
|
||||
return LOS_Closedir(dir);
|
||||
}
|
||||
|
||||
int rmdir(const char *path)
|
||||
{
|
||||
return LOS_Unlink(path);
|
||||
}
|
||||
|
||||
int rename(const char *oldName, const char *newName)
|
||||
{
|
||||
return LOS_Rename(oldName, newName);
|
||||
}
|
||||
|
||||
int statfs(const char *path, struct statfs *buf)
|
||||
{
|
||||
return LOS_Statfs(path, buf);
|
||||
}
|
||||
|
||||
int ftruncate(int fd, off_t length)
|
||||
{
|
||||
return LOS_Ftruncate(fd, length);
|
||||
}
|
||||
|
||||
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pread(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pwrite(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
int access(const char *path, int mode)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if ((st.st_mode & S_IFDIR) || (st.st_mode & S_IFREG)) {
|
||||
return 0;
|
||||
}
|
||||
if ((mode & W_OK) && !(st.st_mode & S_IWRITE)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* #ifdef LOSCFG_FS_VFS */
|
||||
|
||||
int mount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int umount(const char *target)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int umount2(const char *target, int flag)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int open(const char *path, int oflag, ...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int close(int fd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
off_t lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int unlink(const char *path)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fstat(int fd, struct stat *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int stat(const char *path, struct stat *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
DIR *opendir(const char *dirName)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dir)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int closedir(DIR *dir)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rmdir(const char *path)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int rename(const char *oldName, const char *newName)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int statfs(const char *path, struct statfs *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int ftruncate(int fd, off_t length)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int access(const char *path, int mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -34,6 +34,7 @@
|
||||
#include "los_config.h"
|
||||
#include "los_memory.h"
|
||||
|
||||
|
||||
void *calloc(size_t nitems, size_t size)
|
||||
{
|
||||
size_t real_size;
|
||||
@@ -106,3 +107,4 @@ void *realloc(void *ptr, size_t size)
|
||||
|
||||
return LOS_MemRealloc(OS_SYS_MEM_ADDR, ptr, size);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
# Copyright (c) 2020-2021 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:
|
||||
@@ -33,6 +33,7 @@ module_switch = defined(LOSCFG_LIBC_NEWLIB)
|
||||
module_name = get_path_info(rebase_path("."), "name")
|
||||
kernel_module(module_name) {
|
||||
sources = [
|
||||
"porting/src/fs.c",
|
||||
"porting/src/malloc.c",
|
||||
"porting/src/network/htonl.c",
|
||||
"porting/src/network/htons.c",
|
||||
@@ -43,7 +44,7 @@ kernel_module(module_name) {
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
|
||||
if (defined(LOSCFG_FS_VFS)) {
|
||||
if (defined(LOSCFG_LIBC_NEWLIB_FS)) {
|
||||
sources +=
|
||||
[ "//third_party/musl/porting/liteos_m/kernel/src/misc/realpath.c" ]
|
||||
}
|
||||
|
||||
250
kal/libc/newlib/porting/src/fs.c
Normal file
250
kal/libc/newlib/porting/src/fs.c
Normal file
@@ -0,0 +1,250 @@
|
||||
/*
|
||||
* Copyright (c) 2021-2021 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include "los_config.h"
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef LOSCFG_LIBC_NEWLIB_FS
|
||||
#include "los_fs.h"
|
||||
#endif
|
||||
|
||||
#ifdef LOSCFG_LIBC_NEWLIB_FS
|
||||
int mount(const char *source, const char *target,
|
||||
const char *filesystemtype, unsigned long mountflags,
|
||||
const void *data)
|
||||
{
|
||||
return LOS_FsMount(source, target, filesystemtype, mountflags, data);
|
||||
}
|
||||
|
||||
int umount(const char *target)
|
||||
{
|
||||
return LOS_FsUmount(target);
|
||||
}
|
||||
|
||||
int umount2(const char *target, int flag)
|
||||
{
|
||||
return LOS_FsUmount2(target, flag);
|
||||
}
|
||||
|
||||
int _open(const char *path, int oflag, ...)
|
||||
{
|
||||
va_list vaList;
|
||||
va_start(vaList, oflag);
|
||||
int ret;
|
||||
ret = LOS_Open(path, oflag);
|
||||
va_end(vaList);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int _close(int fd)
|
||||
{
|
||||
return LOS_Close(fd);
|
||||
}
|
||||
|
||||
ssize_t _read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
return LOS_Read(fd, buf, nbyte);
|
||||
}
|
||||
|
||||
ssize_t _write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
return LOS_Write(fd, buf, nbyte);
|
||||
}
|
||||
|
||||
off_t _lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
return LOS_Lseek(fd, offset, whence);
|
||||
}
|
||||
|
||||
int _unlink(const char *path)
|
||||
{
|
||||
return LOS_Unlink(path);
|
||||
}
|
||||
|
||||
int _fstat(int fd, struct stat *buf)
|
||||
{
|
||||
return LOS_Fstat(fd, buf);
|
||||
}
|
||||
|
||||
int _stat(const char *path, struct stat *buf)
|
||||
{
|
||||
return LOS_Stat(path, buf);
|
||||
}
|
||||
|
||||
int fsync(int fd)
|
||||
{
|
||||
return LOS_Fsync(fd);
|
||||
}
|
||||
|
||||
int mkdir(const char *path, mode_t mode)
|
||||
{
|
||||
return LOS_Mkdir(path, mode);
|
||||
}
|
||||
|
||||
DIR *opendir(const char *dirName)
|
||||
{
|
||||
return LOS_Opendir(dirName);
|
||||
}
|
||||
|
||||
struct dirent *readdir(DIR *dir)
|
||||
{
|
||||
return LOS_Readdir(dir);
|
||||
}
|
||||
|
||||
int closedir(DIR *dir)
|
||||
{
|
||||
return LOS_Closedir(dir);
|
||||
}
|
||||
|
||||
int rmdir(const char *path)
|
||||
{
|
||||
return LOS_Unlink(path);
|
||||
}
|
||||
|
||||
int rename(const char *oldName, const char *newName)
|
||||
{
|
||||
return LOS_Rename(oldName, newName);
|
||||
}
|
||||
|
||||
int statfs(const char *path, struct statfs *buf)
|
||||
{
|
||||
return LOS_Statfs(path, buf);
|
||||
}
|
||||
|
||||
int ftruncate(int fd, off_t length)
|
||||
{
|
||||
return LOS_Ftruncate(fd, length);
|
||||
}
|
||||
|
||||
int ioctl(int fd, int req, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, req);
|
||||
int ret;
|
||||
ret = LOS_Ioctl(fd, req, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ssize_t pread(int fd, void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pread(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
ssize_t pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
|
||||
{
|
||||
return LOS_Pwrite(fd, buf, nbyte, offset);
|
||||
}
|
||||
|
||||
int access(const char *path, int mode)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat(path, &st) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if ((st.st_mode & S_IFDIR) || (st.st_mode & S_IFREG)) {
|
||||
return 0;
|
||||
}
|
||||
if ((mode & W_OK) && !(st.st_mode & S_IWRITE)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int remove(const char *filename)
|
||||
{
|
||||
int ret = unlink(filename);
|
||||
if (ret == -EISDIR) {
|
||||
ret = rmdir(filename);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* #ifdef LOSCFG_FS_VFS */
|
||||
|
||||
int _open(const char *path, int oflag, ...)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _close(int fd)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t _read(int fd, void *buf, size_t nbyte)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ssize_t _write(int fd, const void *buf, size_t nbyte)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
off_t _lseek(int fd, off_t offset, int whence)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _unlink(const char *path)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _fstat(int fd, struct stat *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int _stat(const char *path, struct stat *buf)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int access(const char *path, int mode)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
int remove(const char *filename)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -57,3 +57,4 @@ void _exit(int status)
|
||||
while (1) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,6 @@ kernel_module(module_name) {
|
||||
sources = [
|
||||
"src/errno.c",
|
||||
"src/libc.c",
|
||||
"src/map_error.c",
|
||||
]
|
||||
configs += [ "$LITEOSTOPDIR:warn_config" ]
|
||||
|
||||
|
||||
@@ -73,11 +73,4 @@ config POSIX_SIGNAL_API
|
||||
help
|
||||
Answer Y to enable LiteOS support POSIX Signal API.
|
||||
|
||||
config POSIX_FS_API
|
||||
bool "Enable POSIX FS API"
|
||||
default y
|
||||
depends on FS_VFS
|
||||
help
|
||||
Answer Y to enable LiteOS support POSIX FS API.
|
||||
|
||||
endif # POSIX_API
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "los_mux.h"
|
||||
#include "los_queue.h"
|
||||
#include "los_sem.h"
|
||||
#include "los_task.h"
|
||||
#include <errno.h>
|
||||
|
||||
INT32 map_errno(UINT32 err)
|
||||
{
|
||||
if (err == LOS_OK) {
|
||||
return 0;
|
||||
}
|
||||
switch (err) {
|
||||
case LOS_ERRNO_QUEUE_INVALID:
|
||||
case LOS_ERRNO_QUEUE_WRITE_PTR_NULL:
|
||||
case LOS_ERRNO_QUEUE_WRITESIZE_ISZERO:
|
||||
case LOS_ERRNO_QUEUE_SIZE_TOO_BIG:
|
||||
case LOS_ERRNO_QUEUE_CREAT_PTR_NULL:
|
||||
case LOS_ERRNO_QUEUE_PARA_ISZERO:
|
||||
case LOS_ERRNO_QUEUE_WRITE_SIZE_TOO_BIG:
|
||||
case LOS_ERRNO_TSK_ID_INVALID:
|
||||
case LOS_ERRNO_TSK_PTR_NULL:
|
||||
case LOS_ERRNO_TSK_NAME_EMPTY:
|
||||
case LOS_ERRNO_TSK_ENTRY_NULL:
|
||||
case LOS_ERRNO_TSK_PRIOR_ERROR:
|
||||
case LOS_ERRNO_TSK_STKSZ_TOO_LARGE:
|
||||
case LOS_ERRNO_TSK_STKSZ_TOO_SMALL:
|
||||
case LOS_ERRNO_TSK_NOT_CREATED:
|
||||
case OS_ERROR:
|
||||
case LOS_ERRNO_SEM_INVALID:
|
||||
case LOS_ERRNO_SEM_UNAVAILABLE:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
case LOS_ERRNO_QUEUE_ISFULL:
|
||||
case LOS_ERRNO_QUEUE_ISEMPTY:
|
||||
errno = EAGAIN;
|
||||
break;
|
||||
case LOS_ERRNO_QUEUE_CREATE_NO_MEMORY:
|
||||
case LOS_ERRNO_TSK_TCB_UNAVAILABLE:
|
||||
case LOS_ERRNO_SEM_ALL_BUSY:
|
||||
errno = ENOSPC;
|
||||
break;
|
||||
case LOS_ERRNO_QUEUE_TIMEOUT:
|
||||
case LOS_ERRNO_SEM_TIMEOUT:
|
||||
errno = ETIMEDOUT;
|
||||
break;
|
||||
case LOS_ERRNO_QUEUE_CB_UNAVAILABLE:
|
||||
errno = ENFILE;
|
||||
break;
|
||||
case LOS_ERRNO_QUEUE_READ_IN_INTERRUPT:
|
||||
case LOS_ERRNO_QUEUE_WRITE_IN_INTERRUPT:
|
||||
case LOS_ERRNO_SEM_PEND_INTERR:
|
||||
errno = EINTR;
|
||||
break;
|
||||
case LOS_ERRNO_TSK_NO_MEMORY:
|
||||
case LOS_ERRNO_SEM_OVERFLOW:
|
||||
errno = ENOMEM;
|
||||
break;
|
||||
case LOS_ERRNO_SEM_PENDED:
|
||||
errno = EBUSY;
|
||||
break;
|
||||
case LOS_ERRNO_SEM_PEND_IN_LOCK:
|
||||
errno = EPERM;
|
||||
break;
|
||||
default:
|
||||
errno = EINVAL;
|
||||
break;
|
||||
}
|
||||
return errno;
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2023 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _POSIX_MAP_ERROR_H
|
||||
#define _POSIX_MAP_ERROR_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
INT32 map_errno(UINT32 err);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
@@ -175,7 +175,7 @@ STATIC INLINE INT32 PollTimedWait(struct pollfd *fds, nfds_t nfds, struct PollTa
|
||||
}
|
||||
} else if (left <= 0) {
|
||||
break;
|
||||
} else {
|
||||
} else if (left > 0) {
|
||||
clock_gettime(CLOCK_REALTIME, &curTime);
|
||||
last = (INT32)((curTime.tv_sec - startTime.tv_sec) * OS_SYS_MS_PER_SECOND +
|
||||
(curTime.tv_nsec - startTime.tv_nsec) / (OS_SYS_NS_PER_SECOND / OS_SYS_MS_PER_SECOND));
|
||||
|
||||
@@ -40,7 +40,6 @@
|
||||
#include "los_config.h"
|
||||
#include "los_task.h"
|
||||
#include "los_debug.h"
|
||||
#include "map_error.h"
|
||||
|
||||
#define PTHREAD_DEFAULT_NAME "pthread"
|
||||
#define PTHREAD_DEFAULT_NAME_LEN 8
|
||||
@@ -208,10 +207,9 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = LOS_TaskCreateOnly(&taskID, &taskInitParam);
|
||||
if (ret != LOS_OK) {
|
||||
if (LOS_TaskCreateOnly(&taskID, &taskInitParam) != LOS_OK) {
|
||||
free((VOID *)(UINTPTR)taskInitParam.uwArg);
|
||||
return map_errno(ret);
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
PthreadData *pthreadData = (PthreadData *)taskInitParam.uwArg;
|
||||
@@ -223,10 +221,10 @@ int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
|
||||
LOS_ListAdd(&g_pthreadListHead, &pthreadData->threadList);
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
*thread = (pthread_t)taskID;
|
||||
|
||||
(void)LOS_TaskResume(taskID);
|
||||
|
||||
*thread = (pthread_t)taskID;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
#include "los_event.h"
|
||||
#include "los_mux.h"
|
||||
|
||||
typedef struct {
|
||||
volatile INT32 *realValue;
|
||||
INT32 value;
|
||||
UINT32 clearEvent;
|
||||
} EventCond;
|
||||
|
||||
#define INLINE inline
|
||||
|
||||
#define BROADCAST_EVENT 1
|
||||
@@ -303,6 +309,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
PRINT_ERR("%s: %d failed\n", __FUNCTION__, __LINE__);
|
||||
}
|
||||
|
||||
(VOID)LOS_EventClear(&(cond->event), 0);
|
||||
ret = (INT32)LOS_EventRead(&(cond->event), 0x0f, LOS_WAITMODE_OR | LOS_WAITMODE_CLR, (UINT32)absTicks);
|
||||
|
||||
if (pthread_mutex_lock(mutex) != 0) {
|
||||
|
||||
@@ -38,9 +38,6 @@
|
||||
#include "los_debug.h"
|
||||
#include "los_hook.h"
|
||||
#include "los_sched.h"
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
#include "los_arch.h"
|
||||
#endif
|
||||
|
||||
#define MUTEXATTR_TYPE_MASK 0x0FU
|
||||
#define OS_SYS_NS_PER_MSECOND 1000000
|
||||
@@ -133,10 +130,6 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||
UINT32 muxHandle;
|
||||
UINT32 ret;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
if (mutex == NULL) {
|
||||
return EINVAL;
|
||||
}
|
||||
@@ -155,9 +148,6 @@ int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *mutexA
|
||||
mutex->stAttr = useAttr;
|
||||
mutex->magic = _MUX_MAGIC;
|
||||
mutex->handle = muxHandle;
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -334,10 +324,6 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
struct timespec curTime = {0};
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
@@ -351,9 +337,6 @@ int pthread_mutex_timedlock(pthread_mutex_t *mutex, const struct timespec *absTi
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
@@ -381,11 +364,6 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
{
|
||||
UINT32 ret;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
LosTaskCB *runTask = OS_TCB_FROM_TID(LOS_CurTaskIDGet());
|
||||
|
||||
ret = MuxPreCheck(mutex, runTask);
|
||||
@@ -398,9 +376,6 @@ int pthread_mutex_lock(pthread_mutex_t *mutex)
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type == PTHREAD_MUTEX_ERRORCHECK) &&
|
||||
@@ -419,10 +394,6 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||
UINT32 ret;
|
||||
LosMuxCB *muxPended = NULL;
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR regLR = ArchLRGet();
|
||||
#endif
|
||||
|
||||
ret = MuxPreCheck(mutex, OS_TCB_FROM_TID(LOS_CurTaskIDGet()));
|
||||
if (ret != 0) {
|
||||
return (INT32)ret;
|
||||
@@ -433,9 +404,6 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex)
|
||||
if (ret != LOS_OK) {
|
||||
return MapError(ret);
|
||||
}
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
OsSetMutexCreateInfo(GET_MUX(mutex->handle), regLR);
|
||||
#endif
|
||||
} else {
|
||||
muxPended = GET_MUX(mutex->handle);
|
||||
if ((mutex->stAttr.type != PTHREAD_MUTEX_RECURSIVE) && (muxPended->muxCount != 0)) {
|
||||
|
||||
@@ -501,7 +501,7 @@ time_t time(time_t *timer)
|
||||
{
|
||||
UINT64 usec = 0;
|
||||
time_t sec;
|
||||
INT32 rtcRet;
|
||||
INT32 rtcRet = 0;
|
||||
|
||||
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
|
||||
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
|
||||
@@ -617,22 +617,11 @@ struct tm *gmtime(const time_t *timer)
|
||||
|
||||
struct tm *localtime_r(const time_t *timep, struct tm *result)
|
||||
{
|
||||
INT32 ret;
|
||||
|
||||
if ((timep == NULL) || (result == NULL)) {
|
||||
errno = EFAULT;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
|
||||
INT32 tempTimezone = 0;
|
||||
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
|
||||
ret = ConvertSecs2Utc(*timep, -tempTimezone, result);
|
||||
} else {
|
||||
ret = ConvertSecs2Utc(*timep, -g_timezone, result);
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
if (!ConvertSecs2Utc(*timep, -g_timezone, result)) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
@@ -675,14 +664,7 @@ static time_t ConvertUtc2Secs(struct tm *tm)
|
||||
seconds += (tm->tm_mday - 1) * SECS_PER_DAY;
|
||||
seconds += tm->tm_hour * SECS_PER_HOUR + tm->tm_min * SECS_PER_MIN + tm->tm_sec;
|
||||
|
||||
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
|
||||
INT32 tempTimezone = 0;
|
||||
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
|
||||
seconds += tempTimezone;
|
||||
} else {
|
||||
seconds += g_timezone;
|
||||
}
|
||||
|
||||
seconds -= tm->__tm_gmtoff; // sub time zone to get UTC time
|
||||
return seconds;
|
||||
}
|
||||
|
||||
@@ -708,14 +690,7 @@ time_t mktime(struct tm *tmptr)
|
||||
}
|
||||
timeInSeconds = ConvertUtc2Secs(tmptr);
|
||||
/* normalize tm_wday and tm_yday */
|
||||
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
|
||||
INT32 tempTimezone = 0;
|
||||
g_rtcTimeFunc.RtcGetTimezoneHook(&tempTimezone);
|
||||
ConvertSecs2Utc(timeInSeconds, -tempTimezone, tmptr);
|
||||
} else {
|
||||
ConvertSecs2Utc(timeInSeconds, -g_timezone, tmptr);
|
||||
}
|
||||
|
||||
ConvertSecs2Utc(timeInSeconds, tmptr->__tm_gmtoff, tmptr);
|
||||
return timeInSeconds;
|
||||
}
|
||||
|
||||
@@ -747,7 +722,7 @@ int gettimeofday(struct timeval *tv, void *ptz)
|
||||
tv->tv_usec = ts.tv_nsec / OS_SYS_NS_PER_US;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tz != NULL) {
|
||||
INT32 timeZone = 0;
|
||||
if (g_rtcTimeFunc.RtcGetTimezoneHook != NULL) {
|
||||
@@ -767,12 +742,12 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||
{
|
||||
struct timespec ts;
|
||||
|
||||
if ((tv == NULL) && (tz == NULL)) {
|
||||
if (tv == NULL) {
|
||||
errno = EFAULT;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((tv != NULL) && (tv->tv_usec >= OS_SYS_US_PER_SECOND)) {
|
||||
if (tv->tv_usec >= OS_SYS_US_PER_SECOND) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
@@ -791,20 +766,18 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
|
||||
}
|
||||
}
|
||||
|
||||
if (tv != NULL) {
|
||||
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
|
||||
UINT64 usec;
|
||||
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
|
||||
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
|
||||
if (g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec) < 0) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
ts.tv_sec = tv->tv_sec;
|
||||
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
|
||||
if (clock_settime(CLOCK_REALTIME, &ts) < 0) {
|
||||
return -1;
|
||||
}
|
||||
if (g_rtcTimeFunc.RtcSetTimeHook != NULL) {
|
||||
UINT64 usec;
|
||||
g_rtcTimeBase = tv->tv_sec * OS_SYS_MS_PER_SECOND + tv->tv_usec / OS_SYS_MS_PER_SECOND;
|
||||
usec = tv->tv_sec * OS_SYS_US_PER_SECOND + tv->tv_usec;
|
||||
if (-1 == g_rtcTimeFunc.RtcSetTimeHook(g_rtcTimeBase, &usec)) {
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
ts.tv_sec = tv->tv_sec;
|
||||
ts.tv_nsec = tv->tv_usec * OS_SYS_NS_PER_US;
|
||||
if (-1 == clock_settime(CLOCK_REALTIME, &ts)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -490,72 +490,6 @@ extern UINT32 LOS_MemIntegrityCheck(const VOID *pool);
|
||||
* </ul>
|
||||
* @see None.
|
||||
*/
|
||||
|
||||
/* Supposing a Second Level Index: SLI = 3. */
|
||||
#define OS_MEM_SLI 3
|
||||
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
|
||||
#define OS_MEM_SMALL_BUCKET_COUNT 31
|
||||
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
|
||||
/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
|
||||
#define OS_MEM_LARGE_BUCKET_COUNT 24
|
||||
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
|
||||
#define OS_MEM_LARGE_START_BUCKET 7
|
||||
|
||||
/* The count of free list. */
|
||||
#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
|
||||
/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
|
||||
#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
|
||||
|
||||
struct OsMemNodeHead {
|
||||
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
|
||||
UINT32 magic;
|
||||
#endif
|
||||
#if (LOSCFG_MEM_LEAKCHECK == 1)
|
||||
UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
|
||||
#endif
|
||||
union {
|
||||
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
|
||||
struct OsMemNodeHead *next; /* The next is used for sentinel node points to the expand node */
|
||||
} ptr;
|
||||
#if (LOSCFG_TASK_MEM_USED == 1)
|
||||
UINT32 taskID;
|
||||
UINT32 sizeAndFlag;
|
||||
#elif (LOSCFG_MEM_FREE_BY_TASKID == 1)
|
||||
UINT32 taskID : 6;
|
||||
UINT32 sizeAndFlag : 26;
|
||||
#else
|
||||
UINT32 sizeAndFlag;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct OsMemFreeNodeHead {
|
||||
struct OsMemNodeHead header;
|
||||
struct OsMemFreeNodeHead *prev;
|
||||
struct OsMemFreeNodeHead *next;
|
||||
};
|
||||
|
||||
struct OsMemPoolInfo {
|
||||
VOID *pool;
|
||||
UINT32 totalSize;
|
||||
UINT32 attr;
|
||||
#if (LOSCFG_MEM_WATERLINE == 1)
|
||||
UINT32 waterLine; /* Maximum usage size in a memory pool */
|
||||
UINT32 curUsedSize; /* Current usage size in a memory pool */
|
||||
#endif
|
||||
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||
UINT32 totalGapSize;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct OsMemPoolHead {
|
||||
struct OsMemPoolInfo info;
|
||||
UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
|
||||
struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
|
||||
#if (LOSCFG_MEM_MUL_POOL == 1)
|
||||
VOID *nextPool;
|
||||
#endif
|
||||
};
|
||||
|
||||
extern VOID LOS_MemUnlockEnable(VOID *pool);
|
||||
|
||||
extern UINT32 OsMemSystemInit(VOID);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "los_task.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
extern "C" {
|
||||
@@ -301,9 +302,6 @@ typedef struct {
|
||||
UINT32 muxID; /**< Handle ID */
|
||||
LOS_DL_LIST muxList; /**< Mutex linked list */
|
||||
LosTaskCB *owner; /**< The current thread that is locking a mutex */
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
UINTPTR createInfo; /**< Return address of the caller */
|
||||
#endif
|
||||
UINT16 priority; /**< Priority of the thread that is locking a mutex */
|
||||
} LosMuxCB;
|
||||
|
||||
@@ -353,13 +351,6 @@ extern UINT32 OsMuxInit(VOID);
|
||||
*/
|
||||
#define GET_MUX_LIST(ptr) LOS_DL_LIST_ENTRY(ptr, LosMuxCB, muxList)
|
||||
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
STATIC INLINE VOID OsSetMutexCreateInfo(LosMuxCB *mux, UINTPTR val)
|
||||
{
|
||||
mux->createInfo = val;
|
||||
}
|
||||
#endif /* LOSCFG_MUTEX_CREATE_TRACE == 1 */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
}
|
||||
|
||||
@@ -96,11 +96,6 @@ STATIC INLINE UINT64 OsGetCurrSchedTimeCycle(VOID)
|
||||
return LOS_SysCycleGet();
|
||||
}
|
||||
|
||||
STATIC INLINE BOOL OsCheckKernelRunning(VOID)
|
||||
{
|
||||
return (g_taskScheduled && LOS_CHECK_SCHEDULE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup los_sched
|
||||
* @brief Get the time, in nanoseconds, remaining before the next tick interrupt response.
|
||||
|
||||
@@ -114,13 +114,27 @@ LITE_OS_SEC_TEXT_INIT VOID LOS_Panic(const CHAR *fmt, ...)
|
||||
va_start(ap, fmt);
|
||||
PRINT_ERR(fmt, ap);
|
||||
va_end(ap);
|
||||
OsDoExcHook(EXC_PANIC);
|
||||
#if (LOSCFG_BACKTRACE_TYPE != 0)
|
||||
LOS_BackTrace();
|
||||
#endif
|
||||
ArchSysExit();
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
Function : OsRegister
|
||||
Description : Configuring the maximum number of tasks
|
||||
Input : None
|
||||
Output : None
|
||||
Return : None
|
||||
*****************************************************************************/
|
||||
LITE_OS_SEC_TEXT_INIT static VOID OsRegister(VOID)
|
||||
{
|
||||
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
LITE_OS_SEC_TEXT_INIT UINT32 LOS_Start(VOID)
|
||||
{
|
||||
return ArchStartSchedule();
|
||||
@@ -142,6 +156,8 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_KernelInit(VOID)
|
||||
OsBackTraceInit();
|
||||
#endif
|
||||
|
||||
OsRegister();
|
||||
|
||||
#ifdef LOSCFG_KERNEL_LMS
|
||||
OsLmsInit();
|
||||
#endif
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "los_memory.h"
|
||||
#include "los_sched.h"
|
||||
|
||||
|
||||
#if (LOSCFG_BASE_IPC_MUX == 1)
|
||||
|
||||
LITE_OS_SEC_BSS LosMuxCB* g_allMux = NULL;
|
||||
@@ -70,9 +71,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsMuxInit(VOID)
|
||||
muxNode->muxID = index;
|
||||
muxNode->owner = (LosTaskCB *)NULL;
|
||||
muxNode->muxStat = OS_MUX_UNUSED;
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
muxNode->createInfo = 0;
|
||||
#endif
|
||||
LOS_ListTailInsert(&g_unusedMuxList, &muxNode->muxList);
|
||||
}
|
||||
return LOS_OK;
|
||||
@@ -151,9 +149,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_MuxDelete(UINT32 muxHandle)
|
||||
|
||||
LOS_ListAdd(&g_unusedMuxList, &muxDeleted->muxList);
|
||||
muxDeleted->muxStat = OS_MUX_UNUSED;
|
||||
#if (LOSCFG_MUTEX_CREATE_TRACE == 1)
|
||||
muxDeleted->createInfo = 0;
|
||||
#endif
|
||||
|
||||
LOS_IntRestore(intSave);
|
||||
|
||||
OsHookCall(LOS_HOOK_TYPE_MUX_DELETE, muxDeleted);
|
||||
@@ -324,5 +320,5 @@ LITE_OS_SEC_TEXT UINT32 LOS_MuxPost(UINT32 muxHandle)
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
#endif /* (LOSCFG_BASE_IPC_MUX == 1) */
|
||||
|
||||
|
||||
@@ -618,7 +618,7 @@ VOID LOS_SchedTickHandler(VOID)
|
||||
|
||||
VOID LOS_Schedule(VOID)
|
||||
{
|
||||
if (OsCheckKernelRunning()) {
|
||||
if (g_taskScheduled && LOS_CHECK_SCHEDULE) {
|
||||
ArchTaskSchedule();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
* @ingroup los_task
|
||||
* @brief check task id's validation
|
||||
*/
|
||||
#define OS_TASK_ID_CHECK(taskID) (OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
|
||||
#define OS_TASK_ID_CHECK(taskID) LOS_ASSERT_COND(OS_TSK_GET_INDEX(taskID) < g_taskMaxNum)
|
||||
|
||||
/**
|
||||
* @ingroup los_task
|
||||
@@ -409,7 +409,6 @@ LITE_OS_SEC_TEXT_INIT UINT32 OsTaskInit(VOID)
|
||||
UINT32 size;
|
||||
UINT32 index;
|
||||
|
||||
g_taskMaxNum = LOSCFG_BASE_CORE_TSK_LIMIT + 1; /* Reserved 1 for IDLE */
|
||||
size = (g_taskMaxNum + 1) * sizeof(LosTaskCB);
|
||||
g_taskCBArray = (LosTaskCB *)LOS_MemAlloc(m_aucSysMem0, size);
|
||||
if (g_taskCBArray == NULL) {
|
||||
@@ -857,7 +856,7 @@ LITE_OS_SEC_TEXT_INIT UINT32 LOS_TaskResume(UINT32 taskID)
|
||||
UINT32 retErr = OS_ERROR;
|
||||
BOOL needSched = FALSE;
|
||||
|
||||
if (!OS_TASK_ID_CHECK(taskID)) {
|
||||
if (taskID > LOSCFG_BASE_CORE_TSK_LIMIT) {
|
||||
return LOS_ERRNO_TSK_ID_INVALID;
|
||||
}
|
||||
|
||||
|
||||
@@ -59,6 +59,21 @@ VOID *g_poolHead = NULL;
|
||||
|
||||
/* The following is the macro definition and interface implementation related to the TLSF. */
|
||||
|
||||
/* Supposing a Second Level Index: SLI = 3. */
|
||||
#define OS_MEM_SLI 3
|
||||
/* Giving 1 free list for each small bucket: 4, 8, 12, up to 124. */
|
||||
#define OS_MEM_SMALL_BUCKET_COUNT 31
|
||||
#define OS_MEM_SMALL_BUCKET_MAX_SIZE 128
|
||||
/* Giving 2^OS_MEM_SLI free lists for each large bucket. */
|
||||
#define OS_MEM_LARGE_BUCKET_COUNT 24
|
||||
/* OS_MEM_SMALL_BUCKET_MAX_SIZE to the power of 2 is 7. */
|
||||
#define OS_MEM_LARGE_START_BUCKET 7
|
||||
|
||||
/* The count of free list. */
|
||||
#define OS_MEM_FREE_LIST_COUNT (OS_MEM_SMALL_BUCKET_COUNT + (OS_MEM_LARGE_BUCKET_COUNT << OS_MEM_SLI))
|
||||
/* The bitmap is used to indicate whether the free list is empty, 1: not empty, 0: empty. */
|
||||
#define OS_MEM_BITMAP_WORDS ((OS_MEM_FREE_LIST_COUNT >> 5) + 1)
|
||||
|
||||
#define OS_MEM_BITMAP_MASK 0x1FU
|
||||
|
||||
/* Used to find the first bit of 1 in bitmap. */
|
||||
@@ -105,10 +120,60 @@ STATIC INLINE UINT32 OsMemSlGet(UINT32 size, UINT32 fl)
|
||||
#error "When enter here, LOSCFG_BASE_CORE_TSK_LIMIT larger than 63 is not support"
|
||||
#endif
|
||||
|
||||
struct OsMemNodeHead {
|
||||
#if (LOSCFG_BASE_MEM_NODE_INTEGRITY_CHECK == 1)
|
||||
UINT32 magic;
|
||||
#endif
|
||||
#if (LOSCFG_MEM_LEAKCHECK == 1)
|
||||
UINTPTR linkReg[LOSCFG_MEM_RECORD_LR_CNT];
|
||||
#endif
|
||||
union {
|
||||
struct OsMemNodeHead *prev; /* The prev is used for current node points to the previous node */
|
||||
struct OsMemNodeHead *next; /* The next is used for sentinel node points to the expand node */
|
||||
} ptr;
|
||||
#if (LOSCFG_TASK_MEM_USED == 1)
|
||||
UINT32 taskID;
|
||||
UINT32 sizeAndFlag;
|
||||
#elif (LOSCFG_MEM_FREE_BY_TASKID == 1)
|
||||
UINT32 taskID : 6;
|
||||
UINT32 sizeAndFlag : 26;
|
||||
#else
|
||||
UINT32 sizeAndFlag;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct OsMemUsedNodeHead {
|
||||
struct OsMemNodeHead header;
|
||||
};
|
||||
|
||||
struct OsMemFreeNodeHead {
|
||||
struct OsMemNodeHead header;
|
||||
struct OsMemFreeNodeHead *prev;
|
||||
struct OsMemFreeNodeHead *next;
|
||||
};
|
||||
|
||||
struct OsMemPoolInfo {
|
||||
VOID *pool;
|
||||
UINT32 totalSize;
|
||||
UINT32 attr;
|
||||
#if (LOSCFG_MEM_WATERLINE == 1)
|
||||
UINT32 waterLine; /* Maximum usage size in a memory pool */
|
||||
UINT32 curUsedSize; /* Current usage size in a memory pool */
|
||||
#endif
|
||||
#if (LOSCFG_MEM_MUL_REGIONS == 1)
|
||||
UINT32 totalGapSize;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct OsMemPoolHead {
|
||||
struct OsMemPoolInfo info;
|
||||
UINT32 freeListBitmap[OS_MEM_BITMAP_WORDS];
|
||||
struct OsMemFreeNodeHead *freeList[OS_MEM_FREE_LIST_COUNT];
|
||||
#if (LOSCFG_MEM_MUL_POOL == 1)
|
||||
VOID *nextPool;
|
||||
#endif
|
||||
};
|
||||
|
||||
/* The memory pool support expand. */
|
||||
#define OS_MEM_POOL_EXPAND_ENABLE 0x01
|
||||
/* The memory pool support no lock. */
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -340,7 +340,6 @@ typedef struct tagHwiHandleForm {
|
||||
#define TEST_HwiCreate(ID, prio, mode, Func, irqParam) LOS_HwiCreate(ID, prio, mode, Func, irqParam)
|
||||
#define uart_printf_func printf
|
||||
|
||||
extern VOID ItSuiteLosAtomic(void);
|
||||
extern VOID ItSuiteLosTask(void);
|
||||
extern VOID ItSuiteLosQueue(void);
|
||||
extern VOID ItSuiteLosMux(void);
|
||||
|
||||
@@ -101,14 +101,14 @@ LITE_TEST_CASE(CmsisFuncTestSuite, TestCmsis007, Function | MediumTest | Level1)
|
||||
msgQueueId = osMessageQueueNew(1, strlen(strbuff), &attr);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(msgQueueId, NULL, msgQueueId);
|
||||
|
||||
name = (CHAR *)osMessageQueueGetName(msgQueueId);
|
||||
name = osMessageQueueGetName(msgQueueId);
|
||||
ret = strcmp(name, "q1");
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = osMessageQueueDelete(msgQueueId);
|
||||
ICUNIT_ASSERT_EQUAL(ret, osOK, ret);
|
||||
|
||||
name = (CHAR *)osMessageQueueGetName(msgQueueId);
|
||||
name = osMessageQueueGetName(msgQueueId);
|
||||
ICUNIT_ASSERT_EQUAL(name, NULL, name);
|
||||
|
||||
#if (LOSCFG_BASE_IPC_QUEUE_STATIC == 1)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -56,8 +56,6 @@ extern VOID ItLosAtomic006(VOID);
|
||||
extern VOID ItLosAtomic007(VOID);
|
||||
extern VOID ItLosAtomic008(VOID);
|
||||
extern VOID ItLosAtomic009(VOID);
|
||||
extern VOID ItLosAtomic010(VOID);
|
||||
extern VOID ItLosAtomic011(VOID);
|
||||
|
||||
#ifdef __cplusplus
|
||||
#if __cplusplus
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -55,7 +55,7 @@ static VOID TaskF01(VOID)
|
||||
atomicRet = LOS_AtomicAdd(&atomicTestCounter, 0x77777777);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(atomicRet, 0x22222221, atomicRet);
|
||||
readCounter = LOS_AtomicRead(&atomicTestCounter);
|
||||
ICUNIT_ASSERT_EQUAL_VOID(readCounter, 0x22222221, readCounter);
|
||||
ICUNIT_ASSERT_EQUAL(readCounter, 0x22222221, readCounter);
|
||||
|
||||
LOS_AtomicSet(&atomicTestCounter, 0xdddddddd);
|
||||
atomicRet = LOS_AtomicSub(&atomicTestCounter, 0x99999999);
|
||||
|
||||
@@ -99,7 +99,7 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
g_testCount++;
|
||||
|
||||
LOS_TaskDelay(2); // 2, set delay time.
|
||||
LOS_TaskDelay(2);// 2, set delay time.
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 7, g_testCount, EXIT1); // 7, Here, assert that g_testCount is equal to 7.
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
g_testCount++;
|
||||
@@ -111,6 +111,7 @@ static UINT32 Testcase(VOID)
|
||||
EXIT1:
|
||||
LOS_TaskDelete(g_testTaskID02);
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
@@ -88,7 +88,7 @@ static UINT32 Testcase(VOID)
|
||||
LOS_EventInit(&g_pevent);
|
||||
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task1);
|
||||
ICUNIT_ASSERT_EQUAL(ret, LOS_OK, ret);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_ASSERT_EQUAL(g_testCount, 1, g_testCount);
|
||||
g_testCount++;
|
||||
@@ -106,6 +106,7 @@ static UINT32 Testcase(VOID)
|
||||
EXIT1:
|
||||
LOS_TaskDelete(g_testTaskID02);
|
||||
|
||||
EXIT:
|
||||
LOS_TaskDelete(g_testTaskID01);
|
||||
|
||||
return LOS_OK;
|
||||
|
||||
@@ -37,7 +37,7 @@ static VOID TaskF01(VOID)
|
||||
{
|
||||
}
|
||||
|
||||
static VOID ItHwiM3B001F001(VOID)
|
||||
VOID ItHwiM3B001F001()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
|
||||
ret = LOS_TaskCreate(&g_testTaskID01, &task);
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
LOS_TaskDelay(100); // 100, set delay time.
|
||||
LOS_TaskDelay(100);// 100, set delay time.
|
||||
|
||||
ICUNIT_GOTO_NOT_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
ICUNIT_TRACK_EQUAL(g_testCount, 1, g_testCount);
|
||||
|
||||
@@ -55,7 +55,7 @@ static VOID TaskF01(void)
|
||||
|
||||
g_testCount++;
|
||||
|
||||
LOS_TaskDelay(100); // 100, set delay time.
|
||||
LOS_TaskDelay(100);// 100, set delay time.
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
@@ -76,7 +76,7 @@ static UINT32 Testcase(VOID)
|
||||
ICUNIT_GOTO_EQUAL(ret, LOS_OK, ret, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
LOS_TaskDelay(1000); // 1000, set delay time.
|
||||
LOS_TaskDelay(1000);// 1000, set delay time.
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, Here, assert that g_testCount is equal to 2.
|
||||
|
||||
|
||||
@@ -69,7 +69,7 @@ static UINT32 g_uwsTick2;
|
||||
static UINT32 g_uwsTick3;
|
||||
|
||||
extern VOID LOS_GetCpuTick(UINT32 *puwCntHi, UINT32 *puwCntLo);
|
||||
extern VOID ItSuiteLosSwtmr(VOID);
|
||||
extern VOID ItSuiteLosSwtmr();
|
||||
extern VOID ItLosSwtmr001(VOID);
|
||||
extern VOID ItLosSwtmr002(VOID);
|
||||
extern VOID ItLosSwtmr003(VOID);
|
||||
|
||||
@@ -39,7 +39,7 @@ static VOID Case1(UINT32 arg)
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
static VOID Case2(VOID)
|
||||
static VOID Case2()
|
||||
{
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
@@ -44,12 +44,12 @@ static VOID Case1(UINT32 arg)
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
static VOID Case2(VOID)
|
||||
static VOID Case2()
|
||||
{
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
static VOID Case3(VOID)
|
||||
static VOID Case3()
|
||||
{
|
||||
g_testCount++;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
|
||||
|
||||
g_testCount1 = 0;
|
||||
// 1, Timeout interval of a periodic software timer.
|
||||
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)Case2, &g_swtmrId1, (UINT32)&irqParam
|
||||
ret = LOS_SwtmrCreate(1, LOS_SWTMR_MODE_ONCE, (SWTMR_PROC_FUNC)Case2, &g_swtmrId1, &irqParam
|
||||
#if (LOSCFG_BASE_CORE_SWTMR_ALIGN == 1)
|
||||
, OS_SWTMR_ROUSES_ALLOW, OS_SWTMR_ALIGN_INSENSITIVE
|
||||
#endif
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
static UINT32 g_testCount1 = 0;
|
||||
static VOID Case1(VOID)
|
||||
static VOID Case1()
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
static UINT32 g_testCount1 = 0;
|
||||
|
||||
static VOID Case1(VOID)
|
||||
static VOID Case1()
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ static VOID Case1(UINT32 arg)
|
||||
return;
|
||||
}
|
||||
|
||||
static VOID Case2(VOID)
|
||||
static VOID Case2()
|
||||
{
|
||||
UINT32 ret;
|
||||
UINT32 tick;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2022 Huawei Device Co., Ltd. All rights reserved.
|
||||
* Copyright (c) 2020-2021 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:
|
||||
@@ -71,7 +71,7 @@ static VOID TaskF01(VOID)
|
||||
#ifdef __RISC_V__
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 0);
|
||||
#else
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, (HwiIrqParam *)1);
|
||||
ret = LOS_HwiCreate(HWI_NUM_TEST, 1, 0, HwiF01, 1);
|
||||
#endif
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, LOS_OK, ret);
|
||||
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
static VOID TaskF02(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
ICUNIT_ASSERT_EQUAL_VOID(ret, 0, ret);
|
||||
g_testCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -32,6 +32,9 @@
|
||||
#include "osTest.h"
|
||||
#include "It_los_task.h"
|
||||
|
||||
static UINT32 g_freeMem1 = 0;
|
||||
static UINT32 g_freeMem2 = 0;
|
||||
|
||||
static UINT32 GetfreeMemSize(void *pool)
|
||||
{
|
||||
return LOS_MemPoolSizeGet(pool) - LOS_MemTotalUsedGet(pool);
|
||||
|
||||
@@ -27,35 +27,7 @@
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
static_library("test_posix") {
|
||||
sources = [
|
||||
"pthread/It_posix_pthread.c",
|
||||
"pthread/It_posix_pthread_001.c",
|
||||
"pthread/It_posix_pthread_002.c",
|
||||
"pthread/It_posix_pthread_003.c",
|
||||
"pthread/It_posix_pthread_004.c",
|
||||
"pthread/It_posix_pthread_005.c",
|
||||
"pthread/It_posix_pthread_006.c",
|
||||
"pthread/It_posix_pthread_007.c",
|
||||
"pthread/It_posix_pthread_008.c",
|
||||
"pthread/It_posix_pthread_009.c",
|
||||
"pthread/It_posix_pthread_010.c",
|
||||
"pthread/It_posix_pthread_011.c",
|
||||
"pthread/It_posix_pthread_012.c",
|
||||
"pthread/It_posix_pthread_013.c",
|
||||
"pthread/It_posix_pthread_014.c",
|
||||
"pthread/It_posix_pthread_015.c",
|
||||
"pthread/It_posix_pthread_016.c",
|
||||
"pthread/It_posix_pthread_017.c",
|
||||
"pthread/It_posix_pthread_018.c",
|
||||
"pthread/It_posix_pthread_019.c",
|
||||
"pthread/It_posix_pthread_020.c",
|
||||
"pthread/It_posix_pthread_021.c",
|
||||
"pthread/It_posix_pthread_022.c",
|
||||
"pthread/It_posix_pthread_023.c",
|
||||
"pthread/It_posix_pthread_024.c",
|
||||
"pthread/It_posix_pthread_025.c",
|
||||
"pthread_func_test.c",
|
||||
]
|
||||
sources = [ "pthread_func_test.c" ]
|
||||
|
||||
configs += [ "//kernel/liteos_m/testsuites:include" ]
|
||||
}
|
||||
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
/*
|
||||
* return value of pthread_self() is 0 when
|
||||
* pthread create from LOS_TaskCreate()
|
||||
*/
|
||||
pthread_t TestPthreadSelf(void)
|
||||
{
|
||||
pthread_t tid = pthread_self();
|
||||
if (tid == 0) {
|
||||
tid = ((LosTaskCB *)(OsCurrTaskGet()))->taskID;
|
||||
}
|
||||
return tid;
|
||||
}
|
||||
|
||||
void ItSuitePosixPthread(void)
|
||||
{
|
||||
printf("************** begin SAMPLE POSIX pthread test *************\n");
|
||||
ItPosixPthread001();
|
||||
ItPosixPthread002();
|
||||
ItPosixPthread003();
|
||||
ItPosixPthread004();
|
||||
ItPosixPthread005();
|
||||
ItPosixPthread006();
|
||||
ItPosixPthread007();
|
||||
ItPosixPthread008();
|
||||
ItPosixPthread009();
|
||||
ItPosixPthread010();
|
||||
ItPosixPthread011();
|
||||
ItPosixPthread012();
|
||||
ItPosixPthread013();
|
||||
ItPosixPthread014();
|
||||
ItPosixPthread015();
|
||||
ItPosixPthread016();
|
||||
ItPosixPthread017();
|
||||
ItPosixPthread018();
|
||||
ItPosixPthread019();
|
||||
ItPosixPthread020();
|
||||
ItPosixPthread021();
|
||||
ItPosixPthread022();
|
||||
ItPosixPthread023();
|
||||
ItPosixPthread024();
|
||||
ItPosixPthread025();
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef IT_POSIX_PTHREAD_H
|
||||
#define IT_POSIX_PTHREAD_H
|
||||
|
||||
#include "sched.h"
|
||||
#include "signal.h"
|
||||
#include "semaphore.h"
|
||||
#include "sched.h"
|
||||
#include "osTest.h"
|
||||
#include "pthread.h"
|
||||
#include "limits.h"
|
||||
#include "unistd.h"
|
||||
#include "mqueue.h"
|
||||
#include "signal.h"
|
||||
|
||||
/* Some routines are part of the XSI Extensions */
|
||||
#ifndef WITHOUT_XOPEN
|
||||
#define _XOPEN_SOURCE 600
|
||||
#endif
|
||||
|
||||
#define PTHREAD_IS_ERROR (-1)
|
||||
#define PTHREAD_PRIORITY_TEST 20
|
||||
#define PTHREAD_DEFAULT_STACK_SIZE (LOSCFG_BASE_CORE_TSK_DEFAULT_STACK_SIZE)
|
||||
#define PTHREAD_KEY_NUM 10
|
||||
#define THREAD_NUM 3
|
||||
#define PTHREAD_TIMEOUT (THREAD_NUM * 2)
|
||||
#define PTHREAD_INTHREAD_TEST 0 /* Control going to or is already for Thread */
|
||||
#define PTHREAD_INMAIN_TEST 1 /* Control going to or is already for Main */
|
||||
#define INVALID_PSHARED_VALUE (-100)
|
||||
#define NUM_OF_CONDATTR 10
|
||||
#define RUNTIME 5
|
||||
#define PTHREAD_THREADS_NUM 3
|
||||
#define TCOUNT 5 // Number of single-threaded polling
|
||||
#define COUNT_LIMIT 7 // The number of times the signal is sent
|
||||
#define HIGH_PRIORITY 5
|
||||
#define LOW_PRIORITY 10
|
||||
#define PTHREAD_EXIT_VALUE ((void *)100) /* The return code of the thread when using pthread_exit(). */
|
||||
|
||||
#define PTHREAD_EXISTED_NUM TASK_EXISTED_NUM
|
||||
#define PTHREAD_EXISTED_SEM_NUM SEM_EXISTED_NUM
|
||||
|
||||
/* We are testing conformance to IEEE Std 1003.1, 2003 Edition */
|
||||
#define _POSIX_C_SOURCE 200112L
|
||||
|
||||
#define PTHREAD_MUTEX_RECURSIVE 0
|
||||
#define PTHREAD_MUTEX_ERRORCHECK 0
|
||||
|
||||
#define PRIORITY_OTHER (-1)
|
||||
#define PRIORITY_FIFO 20
|
||||
#define PRIORITY_RR 20
|
||||
|
||||
#ifdef LOSCFG_AARCH64
|
||||
#define PTHREAD_STACK_MIN_TEST (PTHREAD_STACK_MIN * 3)
|
||||
#else
|
||||
#define PTHREAD_STACK_MIN_TEST PTHREAD_STACK_MIN
|
||||
#endif
|
||||
|
||||
pthread_t TestPthreadSelf(void);
|
||||
|
||||
VOID ItPosixPthread001(VOID);
|
||||
VOID ItPosixPthread002(VOID);
|
||||
VOID ItPosixPthread003(VOID);
|
||||
VOID ItPosixPthread004(VOID);
|
||||
VOID ItPosixPthread005(VOID);
|
||||
VOID ItPosixPthread006(VOID);
|
||||
VOID ItPosixPthread007(VOID);
|
||||
VOID ItPosixPthread008(VOID);
|
||||
VOID ItPosixPthread009(VOID);
|
||||
VOID ItPosixPthread010(VOID);
|
||||
VOID ItPosixPthread011(VOID);
|
||||
VOID ItPosixPthread012(VOID);
|
||||
VOID ItPosixPthread013(VOID);
|
||||
VOID ItPosixPthread014(VOID);
|
||||
VOID ItPosixPthread015(VOID);
|
||||
VOID ItPosixPthread016(VOID);
|
||||
VOID ItPosixPthread017(VOID);
|
||||
VOID ItPosixPthread018(VOID);
|
||||
VOID ItPosixPthread019(VOID);
|
||||
VOID ItPosixPthread020(VOID);
|
||||
VOID ItPosixPthread021(VOID);
|
||||
VOID ItPosixPthread022(VOID);
|
||||
VOID ItPosixPthread023(VOID);
|
||||
VOID ItPosixPthread024(VOID);
|
||||
VOID ItPosixPthread025(VOID);
|
||||
|
||||
#endif /* IT_POSIX_PTHREAD_H */
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static void *ThreadF01(void *arg)
|
||||
{
|
||||
sleep(1);
|
||||
|
||||
/* Shouldn't reach here. If we do, then the pthread_cancel()
|
||||
* function did not succeed. */
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_t newTh;
|
||||
UINT32 ret;
|
||||
UINTPTR temp;
|
||||
|
||||
if (pthread_create(&newTh, NULL, ThreadF01, NULL) < 0) {
|
||||
uart_printf_func("Error creating thread\n");
|
||||
ICUNIT_ASSERT_EQUAL(1, 0, errno);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
/* Try to cancel the newly created thread. If an error is returned,
|
||||
* then the thread wasn't created successfully. */
|
||||
if (pthread_cancel(newTh) != 0) {
|
||||
dprintf("Test FAILED: pthread cancel failed\n");
|
||||
ICUNIT_ASSERT_EQUAL(1, 0, errno);
|
||||
}
|
||||
|
||||
ret = pthread_join(newTh, (void *)&temp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(temp, 0, temp);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread001
|
||||
* @tc.desc: Test interface pthread_cancel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread001(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread001", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static void *ThreadF01(void *arg)
|
||||
{
|
||||
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
|
||||
|
||||
sleep(1);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
void *temp = NULL;
|
||||
pthread_t a;
|
||||
|
||||
if (pthread_create(&a, NULL, ThreadF01, NULL) != 0) {
|
||||
uart_printf_func("Error creating thread\n");
|
||||
ICUNIT_ASSERT_EQUAL(1, 0, errno);
|
||||
}
|
||||
|
||||
LOS_TaskDelay(1);
|
||||
if (pthread_cancel(a) != 0) {
|
||||
dprintf("Test failed: pthread cancel failed\n");
|
||||
return LOS_NOK;
|
||||
}
|
||||
/* If 'main' has reached here, then the test passed because it means
|
||||
* that the thread is truly asynchronise, and main isn't waiting for
|
||||
* it to return in order to move on. */
|
||||
|
||||
ret = pthread_join(a, &temp);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_NOT_EQUAL(temp, PTHREAD_CANCELED, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread002
|
||||
* @tc.desc: Test interface pthread_cancel
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread002(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread002", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL0, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
UINT32 ret;
|
||||
|
||||
ret = pthread_attr_init(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
ret = pthread_attr_destroy(NULL);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread003
|
||||
* @tc.desc: Test interface pthread_attr_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread003(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread003", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
UINT32 ret;
|
||||
int detachstate;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setdetachstate(NULL, PTHREAD_CREATE_DETACHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE - 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, 3); // 3, test the param of function.
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getdetachstate(NULL, &detachstate);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getdetachstate(&attr, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getdetachstate(&attr, &detachstate);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(detachstate, PTHREAD_CREATE_DETACHED, detachstate, EXIT);
|
||||
|
||||
EXIT:
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread004
|
||||
* @tc.desc: Test interface pthread_setdetachstate
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread004(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread004", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
UINT32 ret;
|
||||
int inherit;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_setinheritsched(NULL, PTHREAD_INHERIT_SCHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED - 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED + 1);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getinheritsched(NULL, &inherit);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, NULL);
|
||||
ICUNIT_GOTO_EQUAL(ret, EINVAL, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, &inherit);
|
||||
ICUNIT_GOTO_EQUAL(ret, 0, ret, EXIT);
|
||||
ICUNIT_GOTO_EQUAL(inherit, PTHREAD_EXPLICIT_SCHED, inherit, EXIT);
|
||||
|
||||
EXIT:
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread005
|
||||
* @tc.desc: Test interface pthread_attr_setinheritsched
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread005(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread005", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
pthread_cond_t cond1;
|
||||
pthread_cond_t cond2;
|
||||
int rc;
|
||||
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_cond_init(&cond1, &condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_cond_init(&cond2, NULL);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
rc = pthread_cond_destroy(&cond1);
|
||||
ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
|
||||
rc = pthread_cond_destroy(&cond2);
|
||||
ICUNIT_GOTO_EQUAL(rc, ENOERR, rc, EXIT);
|
||||
|
||||
return LOS_OK;
|
||||
EXIT:
|
||||
(void)pthread_cond_destroy(&cond1);
|
||||
(void)pthread_cond_destroy(&cond2);
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread006
|
||||
* @tc.desc: Test interface pthread_cond_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread006(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread006", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
int rc;
|
||||
pthread_cond_t cond1, cond2;
|
||||
pthread_cond_t cond3 = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
/* Initialize a condition variable attribute object */
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Initialize cond1 with the default condition variable attribute */
|
||||
rc = pthread_cond_init(&cond1, &condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Initialize cond2 with NULL attributes */
|
||||
rc = pthread_cond_init(&cond2, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy the condition variable attribute object */
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy cond1 */
|
||||
rc = pthread_cond_destroy(&cond1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy cond2 */
|
||||
rc = pthread_cond_destroy(&cond2);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy cond3 */
|
||||
rc = pthread_cond_destroy(&cond3);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread007
|
||||
* @tc.desc: Test interface pthread_cond_destroy
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread007(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread007", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static INT32 g_pthreadSchedPolicy = 0;
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_attr_t attr;
|
||||
INT32 ret;
|
||||
struct sched_param param;
|
||||
INT32 priority;
|
||||
INT32 offset = 0xff;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
g_pthreadSchedPolicy = SCHED_FIFO;
|
||||
ret = pthread_attr_setschedpolicy(&attr, g_pthreadSchedPolicy);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
priority = sched_get_priority_max(g_pthreadSchedPolicy);
|
||||
ICUNIT_ASSERT_EQUAL(priority, PTHREAD_IS_ERROR, priority);
|
||||
ICUNIT_ASSERT_EQUAL(errno, EINVAL, errno);
|
||||
|
||||
param.sched_priority = priority + offset;
|
||||
ret = pthread_attr_setschedparam(&attr, ¶m);
|
||||
ICUNIT_ASSERT_EQUAL(ret, ENOTSUP, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread008
|
||||
* @tc.desc: Test interface pthread_attr_setschedpolicy
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread008(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread008", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
int rc;
|
||||
|
||||
/* Initialize a condition variable attributes object */
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Destroy the condition variable attributes object */
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
/* Initialize the condition variable attributes object again. This shouldn't result in an error. */
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread009
|
||||
* @tc.desc: Test interface pthread_condattr_destroy
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread009(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread009", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t *condattr = NULL;
|
||||
int rc;
|
||||
|
||||
/* Initialize a condition variable attributes object */
|
||||
rc = pthread_condattr_init(condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
/* Destroy the condition variable attributes object */
|
||||
rc = pthread_condattr_destroy(condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread010
|
||||
* @tc.desc: Test interface pthread_condattr_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread010(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread010", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t attr;
|
||||
int ret;
|
||||
|
||||
/* Initialize a cond attributes object */
|
||||
ret = pthread_condattr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
/* Set 'pshared' to INVALID_PSHARED_VALUE. */
|
||||
ret = pthread_condattr_setpshared(&attr, INVALID_PSHARED_VALUE);
|
||||
ICUNIT_ASSERT_EQUAL(ret, EINVAL, ret);
|
||||
|
||||
/* Destroy the cond attributes object */
|
||||
ret = pthread_condattr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread011
|
||||
* @tc.desc: Test interface pthread_condattr_setpshared
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread011(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread011", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
INT32 ret;
|
||||
INT32 inheritsched;
|
||||
INT32 g_pthreadSchedInherit;
|
||||
pthread_attr_t attr;
|
||||
|
||||
ret = pthread_attr_init(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
g_pthreadSchedInherit = PTHREAD_INHERIT_SCHED;
|
||||
ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, g_pthreadSchedInherit, inheritsched);
|
||||
|
||||
g_pthreadSchedInherit = PTHREAD_EXPLICIT_SCHED;
|
||||
ret = pthread_attr_setinheritsched(&attr, g_pthreadSchedInherit);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
ret = pthread_attr_getinheritsched(&attr, &inheritsched);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
ICUNIT_ASSERT_EQUAL(inheritsched, g_pthreadSchedInherit, inheritsched);
|
||||
|
||||
ret = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(ret, 0, ret);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread012
|
||||
* @tc.desc: Test interface pthread_attr_getinheritsched
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread012(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread012", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
#define LOOP_NUM 2
|
||||
static pthread_mutex_t g_pthreadMutexTest1 = PTHREAD_MUTEX_INITIALIZER;
|
||||
static pthread_cond_t g_pthreadCondTest1 = PTHREAD_COND_INITIALIZER;
|
||||
|
||||
static VOID *PthreadF01(void *t)
|
||||
{
|
||||
int rc;
|
||||
|
||||
rc = pthread_mutex_lock(&g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
g_testCount++;
|
||||
LOS_TaskDelay(1);
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 2, g_testCount, EXIT); // 2, here assert the result.
|
||||
g_testCount++;
|
||||
|
||||
rc = pthread_cond_wait(&g_pthreadCondTest1, &g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 5, g_testCount, EXIT); // 5, here assert the result.
|
||||
rc = pthread_mutex_unlock(&g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
EXIT:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static VOID *PthreadF02(void *t)
|
||||
{
|
||||
int i;
|
||||
int rc;
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 1, g_testCount, EXIT);
|
||||
g_testCount++;
|
||||
rc = pthread_mutex_lock(&g_pthreadMutexTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 3, g_testCount, EXIT); // 3, here assert the result.
|
||||
g_testCount++;
|
||||
rc = pthread_cond_signal(&g_pthreadCondTest1);
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
|
||||
ICUNIT_GOTO_EQUAL(g_testCount, 4, g_testCount, EXIT); // 4, here assert the result.
|
||||
g_testCount++;
|
||||
|
||||
rc = pthread_mutex_unlock(&g_pthreadMutexTest1); /* Increase latency for thread polling mutex */
|
||||
ICUNIT_GOTO_EQUAL(rc, 0, rc, EXIT);
|
||||
LOS_TaskDelay(2); // 2, delay for Timing control.
|
||||
|
||||
EXIT:
|
||||
return NULL;
|
||||
}
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
int i;
|
||||
long t1 = 1;
|
||||
long t2 = 2; // 2, init
|
||||
int rc;
|
||||
pthread_t threads[3]; // 3, need 3 pthread for test.
|
||||
pthread_attr_t attr;
|
||||
|
||||
g_testCount = 0;
|
||||
pthread_mutex_init(&g_pthreadMutexTest1, NULL);
|
||||
/* When creating thread, it is set to connectable state, which is easy to transplant */
|
||||
pthread_cond_init(&g_pthreadCondTest1, NULL);
|
||||
pthread_attr_init(&attr);
|
||||
|
||||
rc = pthread_create(&threads[0], &attr, PthreadF01, (void *)t1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_create(&threads[1], &attr, PthreadF02, (void *)t2);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
for (i = 0; i < LOOP_NUM; i++) {
|
||||
rc = pthread_join(threads[i], NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
}
|
||||
|
||||
rc = pthread_attr_destroy(&attr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_mutex_destroy(&g_pthreadMutexTest1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
rc = pthread_cond_destroy(&g_pthreadCondTest1);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread013
|
||||
* @tc.desc: Test interface pthread_mutex_init
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread013(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread013", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
|
||||
* to endorse or promote products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "It_posix_pthread.h"
|
||||
|
||||
static UINT32 Testcase(VOID)
|
||||
{
|
||||
pthread_condattr_t condattr;
|
||||
pthread_cond_t cond1;
|
||||
pthread_cond_t cond2;
|
||||
int pshared;
|
||||
int rc;
|
||||
|
||||
rc = pthread_condattr_init(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(NULL, &pshared);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(&condattr, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(NULL, NULL);
|
||||
ICUNIT_ASSERT_EQUAL(rc, EINVAL, rc);
|
||||
|
||||
rc = pthread_condattr_getpshared(&condattr, &pshared);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
ICUNIT_ASSERT_EQUAL(pshared, PTHREAD_PROCESS_PRIVATE, pshared);
|
||||
|
||||
rc = pthread_condattr_destroy(&condattr);
|
||||
ICUNIT_ASSERT_EQUAL(rc, 0, rc);
|
||||
|
||||
return LOS_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: ItPosixPthread014
|
||||
* @tc.desc: Test interface pthread_condattr_getpshared
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issueI5TIRQ
|
||||
*/
|
||||
|
||||
VOID ItPosixPthread014(VOID)
|
||||
{
|
||||
TEST_ADD_CASE("ItPosixPthread014", Testcase, TEST_POSIX, TEST_PTHREAD, TEST_LEVEL2, TEST_FUNCTION);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user