diff options
| author | SummerGift <[email protected]> | 2019-05-16 08:47:04 +0800 |
|---|---|---|
| committer | SummerGift <[email protected]> | 2019-05-16 08:47:47 +0800 |
| commit | 9f300de9cc9ca0a921f1cd5364b01a06d96efcf8 (patch) | |
| tree | 3a96508dadb22b8b7f9a1d358f906df5e8002673 /components | |
| parent | ec99faf022bbfc26099e9fd56d7b91668b3dae57 (diff) | |
【修改】dlib newlib minilib 中的 gettimeofday() 函数实现
Diffstat (limited to 'components')
| -rw-r--r-- | components/libc/compilers/dlib/time.c | 17 | ||||
| -rw-r--r-- | components/libc/compilers/minilibc/time.c | 19 | ||||
| -rw-r--r-- | components/libc/compilers/newlib/time.c | 17 |
3 files changed, 22 insertions, 31 deletions
diff --git a/components/libc/compilers/dlib/time.c b/components/libc/compilers/dlib/time.c index 87574df851..df35313b0e 100644 --- a/components/libc/compilers/dlib/time.c +++ b/components/libc/compilers/dlib/time.c @@ -16,19 +16,16 @@ int gettimeofday(struct timeval *tp, void *ignore) rt_device_t device; device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } + RT_ASSERT(device != RT_NULL); - return time; + rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); + if (tp != RT_NULL) + { + tp->tv_sec = time; + tp->tv_usec = 0; } - return 0; + return time; } #endif diff --git a/components/libc/compilers/minilibc/time.c b/components/libc/compilers/minilibc/time.c index 508558bafc..c04652c884 100644 --- a/components/libc/compilers/minilibc/time.c +++ b/components/libc/compilers/minilibc/time.c @@ -211,19 +211,16 @@ int gettimeofday(struct timeval *tp, void *ignore) rt_device_t device; device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } + RT_ASSERT(device != RT_NULL); - return time; - } + rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); + if (tp != RT_NULL) + { + tp->tv_sec = time; + tp->tv_usec = 0; + } - return 0; + return time; } #endif diff --git a/components/libc/compilers/newlib/time.c b/components/libc/compilers/newlib/time.c index 29c5c6cdd2..f099d51330 100644 --- a/components/libc/compilers/newlib/time.c +++ b/components/libc/compilers/newlib/time.c @@ -16,19 +16,16 @@ int gettimeofday(struct timeval *tp, void *ignore) rt_device_t device; device = rt_device_find("rtc"); - if (device != RT_NULL) - { - rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); - if (tp != RT_NULL) - { - tp->tv_sec = time; - tp->tv_usec = 0; - } + RT_ASSERT(device != RT_NULL); - return time; + rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time); + if (tp != RT_NULL) + { + tp->tv_sec = time; + tp->tv_usec = 0; } - return 0; + return time; } #endif |
