!1051 Fix : 修复gettimeofday对RTC钩子依赖的问题

Merge pull request !1051 from yinjiaming/fix
This commit is contained in:
openharmony_ci 2023-06-06 00:59:38 +00:00 committed by Gitee
commit 16dae422eb
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 3 additions and 12 deletions

View File

@ -720,20 +720,11 @@ int gettimeofday(struct timeval *tv, void *ptz)
struct timezone *tz = (struct timezone *)ptz; struct timezone *tz = (struct timezone *)ptz;
if (tv != NULL) { if (tv != NULL) {
INT32 rtcRet;
UINT64 usec = 0; UINT64 usec = 0;
UINT64 currentTime;
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) { if ((g_rtcTimeFunc.RtcGetTimeHook != NULL) && (g_rtcTimeFunc.RtcGetTimeHook(&usec) == 0)) {
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec); tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
if (rtcRet != 0) { tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
currentTime = GetCurrentTime();
tv->tv_sec = currentTime / OS_SYS_MS_PER_SECOND;
tv->tv_usec = (currentTime % OS_SYS_MS_PER_SECOND) * OS_SYS_MS_PER_SECOND;
} else {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
}
} else { } else {
struct timespec ts; struct timespec ts;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) { if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {