Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
e8427a45
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
460
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e8427a45
编写于
5月 14, 2021
作者:
T
teamol
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix time mould-kernel:fix 2 api clock_gettime、clock_getres
Change-Id: I260e47c895ced01e033ef8a824744e574887c9f5
上级
a53ad129
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
60 addition
and
6 deletion
+60
-6
compat/posix/src/time.c
compat/posix/src/time.c
+17
-6
testsuites/unittest/posix/pthread/posix_pthread_test.cpp
testsuites/unittest/posix/pthread/posix_pthread_test.cpp
+11
-0
testsuites/unittest/process/mutex/process_mutex_test.cpp
testsuites/unittest/process/mutex/process_mutex_test.cpp
+32
-0
未找到文件。
compat/posix/src/time.c
浏览文件 @
e8427a45
...
@@ -467,11 +467,9 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
...
@@ -467,11 +467,9 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
return
-
EINVAL
;
return
-
EINVAL
;
}
}
#ifdef LOSCFG_KERNEL_CPUP
SCHEDULER_LOCK
(
intSave
);
SCHEDULER_LOCK
(
intSave
);
runtime
=
task
->
taskCpup
.
allTime
;
runtime
=
task
->
taskCpup
.
allTime
;
SCHEDULER_UNLOCK
(
intSave
);
SCHEDULER_UNLOCK
(
intSave
);
#endif
ats
->
tv_sec
=
runtime
/
OS_SYS_NS_PER_SECOND
;
ats
->
tv_sec
=
runtime
/
OS_SYS_NS_PER_SECOND
;
ats
->
tv_nsec
=
runtime
%
OS_SYS_NS_PER_SECOND
;
ats
->
tv_nsec
=
runtime
%
OS_SYS_NS_PER_SECOND
;
...
@@ -495,11 +493,9 @@ static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
...
@@ -495,11 +493,9 @@ static int ProcessGetCputime(clockid_t clockID, struct timespec *ats)
return
-
EINVAL
;
return
-
EINVAL
;
}
}
#ifdef LOSCFG_KERNEL_CPUP
SCHEDULER_LOCK
(
intSave
);
SCHEDULER_LOCK
(
intSave
);
runtime
=
spcb
->
processCpup
.
allTime
;
runtime
=
spcb
->
processCpup
.
allTime
;
SCHEDULER_UNLOCK
(
intSave
);
SCHEDULER_UNLOCK
(
intSave
);
#endif
ats
->
tv_sec
=
runtime
/
OS_SYS_NS_PER_SECOND
;
ats
->
tv_sec
=
runtime
/
OS_SYS_NS_PER_SECOND
;
ats
->
tv_nsec
=
runtime
%
OS_SYS_NS_PER_SECOND
;
ats
->
tv_nsec
=
runtime
%
OS_SYS_NS_PER_SECOND
;
...
@@ -529,6 +525,7 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
...
@@ -529,6 +525,7 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
UINT32
intSave
;
UINT32
intSave
;
struct
timespec64
tmp
=
{
0
};
struct
timespec64
tmp
=
{
0
};
struct
timespec64
hwTime
=
{
0
};
struct
timespec64
hwTime
=
{
0
};
int
ret
;
if
(
clockID
>
MAX_CLOCKS
)
{
if
(
clockID
>
MAX_CLOCKS
)
{
goto
ERROUT
;
goto
ERROUT
;
...
@@ -572,8 +569,12 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
...
@@ -572,8 +569,12 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
TIME_RETURN
(
ENOTSUP
);
TIME_RETURN
(
ENOTSUP
);
default:
default:
{
{
int
ret
=
GetCputime
(
clockID
,
tp
);
#ifdef LOSCFG_KERNEL_CPUP
ret
=
GetCputime
(
clockID
,
tp
);
TIME_RETURN
(
-
ret
);
TIME_RETURN
(
-
ret
);
#else
TIME_RETURN
(
EINVAL
);
#endif
}
}
}
}
...
@@ -606,6 +607,10 @@ static int CheckClock(const clockid_t clockID)
...
@@ -606,6 +607,10 @@ static int CheckClock(const clockid_t clockID)
static
int
CpuClockGetres
(
const
clockid_t
clockID
,
struct
timespec
*
tp
)
static
int
CpuClockGetres
(
const
clockid_t
clockID
,
struct
timespec
*
tp
)
{
{
if
(
clockID
>
0
)
{
return
-
EINVAL
;
}
int
error
=
CheckClock
(
clockID
);
int
error
=
CheckClock
(
clockID
);
if
(
!
error
)
{
if
(
!
error
)
{
error
=
ProcessGetCputime
(
clockID
,
tp
);
error
=
ProcessGetCputime
(
clockID
,
tp
);
...
@@ -616,6 +621,8 @@ static int CpuClockGetres(const clockid_t clockID, struct timespec *tp)
...
@@ -616,6 +621,8 @@ static int CpuClockGetres(const clockid_t clockID, struct timespec *tp)
int
clock_getres
(
clockid_t
clockID
,
struct
timespec
*
tp
)
int
clock_getres
(
clockid_t
clockID
,
struct
timespec
*
tp
)
{
{
int
ret
;
if
(
tp
==
NULL
)
{
if
(
tp
==
NULL
)
{
TIME_RETURN
(
EINVAL
);
TIME_RETURN
(
EINVAL
);
}
}
...
@@ -644,10 +651,14 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
...
@@ -644,10 +651,14 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
case
CLOCK_TAI
:
case
CLOCK_TAI
:
TIME_RETURN
(
ENOTSUP
);
TIME_RETURN
(
ENOTSUP
);
default:
default:
#ifdef LOSCFG_KERNEL_CPUP
{
{
int
ret
=
CpuClockGetres
(
clockID
,
tp
);
ret
=
CpuClockGetres
(
clockID
,
tp
);
TIME_RETURN
(
-
ret
);
TIME_RETURN
(
-
ret
);
}
}
#else
TIME_RETURN
(
EINVAL
);
#endif
}
}
TIME_RETURN
(
0
);
TIME_RETURN
(
0
);
...
...
testsuites/unittest/posix/pthread/posix_pthread_test.cpp
浏览文件 @
e8427a45
...
@@ -327,6 +327,17 @@ HWTEST_F(PosixPthreadTest, ItPosixPthread022, TestSize.Level0)
...
@@ -327,6 +327,17 @@ HWTEST_F(PosixPthreadTest, ItPosixPthread022, TestSize.Level0)
ItPosixPthread022
();
// pthread_cancel
ItPosixPthread022
();
// pthread_cancel
}
}
/* *
* @tc.name: IT_POSIX_PTHREAD_203
* @tc.desc: function for pthread concurrency
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
PosixPthreadTest
,
ItPosixPthread203
,
TestSize
.
Level0
)
{
ItPosixPthread203
();
}
#endif
#endif
#if defined(LOSCFG_USER_TEST_FULL)
#if defined(LOSCFG_USER_TEST_FULL)
...
...
testsuites/unittest/process/mutex/process_mutex_test.cpp
浏览文件 @
e8427a45
...
@@ -293,4 +293,36 @@ HWTEST_F(ProcessMutexTest, ItTestPthreadMutex022, TestSize.Level0)
...
@@ -293,4 +293,36 @@ HWTEST_F(ProcessMutexTest, ItTestPthreadMutex022, TestSize.Level0)
ItTestPthreadMutex022
();
ItTestPthreadMutex022
();
}
}
/* *
* @tc.name: it_test_pthread_mutex_023
* @tc.desc: function for test mutexattr robust
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F
(
ProcessMutexTest
,
ItTestPthreadMutex023
,
TestSize
.
Level0
)
{
ItTestPthreadMutex023
();
}
/* *
* @tc.name: it_test_pthread_mutex_024
* @tc.desc: function for test mutexattr robust:error return value
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F
(
ProcessMutexTest
,
ItTestPthreadMutex024
,
TestSize
.
Level0
)
{
ItTestPthreadMutex024
();
}
/* *
* @tc.name: it_test_pthread_mutex_025
* @tc.desc: test mutexattr robust:robustness product deadlock is not set
* @tc.type: FUNC
* @tc.require: AR000E0QAB
*/
HWTEST_F
(
ProcessMutexTest
,
ItTestPthreadMutex025
,
TestSize
.
Level0
)
{
ItTestPthreadMutex025
();
}
}
// namespace OHOS
}
// namespace OHOS
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录