fix: 修复gettimeofday接口获取时间方式依赖RTC钩子

gettimeofday 接口获取时间的方式依赖于RTC钩子,造成了精度的差异,
现去掉其依赖

BREAKING CHANGE:
修复gettimeofday接口获取时间方式依赖RTC钩子对外变更描述:
修改API:
int gettimeofday(struct timeval *tv, void *ptz);

Close #I6WV3V

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I87f46661a2b6edf9fd179e8c6e2cfe72da0c0c61
This commit is contained in:
yinjiaming 2023-04-18 17:22:43 +08:00
parent 748e0a4447
commit 96c16b0cbf
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;
if (tv != NULL) {
INT32 rtcRet;
UINT64 usec = 0;
UINT64 currentTime;
if (g_rtcTimeFunc.RtcGetTimeHook != NULL) {
rtcRet = g_rtcTimeFunc.RtcGetTimeHook(&usec);
if (rtcRet != 0) {
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;
}
if ((g_rtcTimeFunc.RtcGetTimeHook != NULL) && (g_rtcTimeFunc.RtcGetTimeHook(&usec) == 0)) {
tv->tv_sec = usec / OS_SYS_US_PER_SECOND;
tv->tv_usec = usec % OS_SYS_US_PER_SECOND;
} else {
struct timespec ts;
if (-1 == clock_gettime(CLOCK_REALTIME, &ts)) {