fix time mould-kernel:fix 2 api clock_gettime、clock_getres
Change-Id: I260e47c895ced01e033ef8a824744e574887c9f5
This commit is contained in:
parent
a53ad12907
commit
e8427a45c5
|
@ -467,11 +467,9 @@ static int PthreadGetCputime(clockid_t clockID, struct timespec *ats)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
SCHEDULER_LOCK(intSave);
|
||||
runtime = task->taskCpup.allTime;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
#endif
|
||||
|
||||
ats->tv_sec = 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)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
SCHEDULER_LOCK(intSave);
|
||||
runtime = spcb->processCpup.allTime;
|
||||
SCHEDULER_UNLOCK(intSave);
|
||||
#endif
|
||||
|
||||
ats->tv_sec = 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)
|
|||
UINT32 intSave;
|
||||
struct timespec64 tmp = {0};
|
||||
struct timespec64 hwTime = {0};
|
||||
int ret;
|
||||
|
||||
if (clockID > MAX_CLOCKS) {
|
||||
goto ERROUT;
|
||||
|
@ -572,8 +569,12 @@ int clock_gettime(clockid_t clockID, struct timespec *tp)
|
|||
TIME_RETURN(ENOTSUP);
|
||||
default:
|
||||
{
|
||||
int ret = GetCputime(clockID, tp);
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
ret = GetCputime(clockID, tp);
|
||||
TIME_RETURN(-ret);
|
||||
#else
|
||||
TIME_RETURN(EINVAL);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -606,6 +607,10 @@ static int CheckClock(const clockid_t clockID)
|
|||
|
||||
static int CpuClockGetres(const clockid_t clockID, struct timespec *tp)
|
||||
{
|
||||
if (clockID > 0) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
int error = CheckClock(clockID);
|
||||
if (!error) {
|
||||
error = ProcessGetCputime(clockID, 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 ret;
|
||||
|
||||
if (tp == NULL) {
|
||||
TIME_RETURN(EINVAL);
|
||||
}
|
||||
|
@ -644,10 +651,14 @@ int clock_getres(clockid_t clockID, struct timespec *tp)
|
|||
case CLOCK_TAI:
|
||||
TIME_RETURN(ENOTSUP);
|
||||
default:
|
||||
#ifdef LOSCFG_KERNEL_CPUP
|
||||
{
|
||||
int ret = CpuClockGetres(clockID, tp);
|
||||
ret = CpuClockGetres(clockID, tp);
|
||||
TIME_RETURN(-ret);
|
||||
}
|
||||
#else
|
||||
TIME_RETURN(EINVAL);
|
||||
#endif
|
||||
}
|
||||
|
||||
TIME_RETURN(0);
|
||||
|
|
|
@ -327,6 +327,17 @@ HWTEST_F(PosixPthreadTest, ItPosixPthread022, TestSize.Level0)
|
|||
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
|
||||
|
||||
#if defined(LOSCFG_USER_TEST_FULL)
|
||||
|
|
|
@ -293,4 +293,36 @@ HWTEST_F(ProcessMutexTest, ItTestPthreadMutex022, TestSize.Level0)
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue