优化get_timeval set_timeval 条件编译代码结构
This commit is contained in:
parent
b74022e2c4
commit
46d51a99f1
|
@ -77,7 +77,6 @@ static int get_timeval(struct timeval *tv)
|
||||||
{
|
{
|
||||||
#ifdef RT_USING_RTC
|
#ifdef RT_USING_RTC
|
||||||
static rt_device_t device = RT_NULL;
|
static rt_device_t device = RT_NULL;
|
||||||
#endif
|
|
||||||
rt_err_t rst = -RT_ERROR;
|
rt_err_t rst = -RT_ERROR;
|
||||||
|
|
||||||
if (tv == RT_NULL)
|
if (tv == RT_NULL)
|
||||||
|
@ -87,7 +86,6 @@ static int get_timeval(struct timeval *tv)
|
||||||
tv->tv_sec = 0;
|
tv->tv_sec = 0;
|
||||||
tv->tv_usec = 0;
|
tv->tv_usec = 0;
|
||||||
|
|
||||||
#ifdef RT_USING_RTC
|
|
||||||
/* optimization: find rtc device only first */
|
/* optimization: find rtc device only first */
|
||||||
if (device == RT_NULL)
|
if (device == RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -127,15 +125,13 @@ static int get_timeval(struct timeval *tv)
|
||||||
*/
|
*/
|
||||||
static int set_timeval(struct timeval *tv)
|
static int set_timeval(struct timeval *tv)
|
||||||
{
|
{
|
||||||
rt_err_t rst = -RT_ERROR;
|
|
||||||
#ifdef RT_USING_RTC
|
#ifdef RT_USING_RTC
|
||||||
static rt_device_t device = RT_NULL;
|
static rt_device_t device = RT_NULL;
|
||||||
#endif
|
rt_err_t rst = -RT_ERROR;
|
||||||
|
|
||||||
if (tv == RT_NULL)
|
if (tv == RT_NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
#ifdef RT_USING_RTC
|
|
||||||
/* optimization: find rtc device only first */
|
/* optimization: find rtc device only first */
|
||||||
if (device == RT_NULL)
|
if (device == RT_NULL)
|
||||||
{
|
{
|
||||||
|
@ -311,7 +307,7 @@ RT_WEAK time_t time(time_t *t)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
errno = EFAULT;
|
errno = EFAULT;
|
||||||
return -1;
|
return ((time_t)-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RTM_EXPORT(time);
|
RTM_EXPORT(time);
|
||||||
|
|
Loading…
Reference in New Issue