summaryrefslogtreecommitdiff
path: root/components/libc/compilers/common/ctime.c
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2023-11-14 18:18:07 +0800
committerguo <[email protected]>2023-11-16 13:09:32 +0800
commit3143289486c3d716070e797170ef659cfee3a747 (patch)
tree763d2c854b5d6bd77c494487920473503f4d6b9b /components/libc/compilers/common/ctime.c
parent35e773d46acc6652099d3e792d9b097a8cd97ba2 (diff)
[libc] update ctime.c compatible with old drivers
Diffstat (limited to 'components/libc/compilers/common/ctime.c')
-rw-r--r--components/libc/compilers/common/ctime.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/components/libc/compilers/common/ctime.c b/components/libc/compilers/common/ctime.c
index f2cc76df47..44822ec379 100644
--- a/components/libc/compilers/common/ctime.c
+++ b/components/libc/compilers/common/ctime.c
@@ -480,7 +480,16 @@ int gettimeofday(struct timeval *tv, struct timezone *tz)
tv->tv_usec = 0;
if (_control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMEVAL, tv) == RT_EOK)
+ {
return 0;
+ }
+ else
+ {
+ if (_control_rtc(RT_DEVICE_CTRL_RTC_GET_TIME, (void *)&tv->tv_sec) == RT_EOK)
+ {
+ return 0;
+ }
+ }
}
rt_set_errno(EINVAL);
@@ -498,7 +507,16 @@ int settimeofday(const struct timeval *tv, const struct timezone *tz)
if (tv != RT_NULL && (long)tv->tv_usec >= 0 && (long)tv->tv_sec >= 0)
{
if (_control_rtc(RT_DEVICE_CTRL_RTC_SET_TIMEVAL, (void *)tv) == RT_EOK)
+ {
return 0;
+ }
+ else
+ {
+ if (_control_rtc(RT_DEVICE_CTRL_RTC_SET_TIME, (void *)&tv->tv_sec) == RT_EOK)
+ {
+ return 0;
+ }
+ }
}
rt_set_errno(EINVAL);