Merge pull request #2690 from SummerGGift/master_rt-thread

[components][libc] Modify the gettimeofday() function
This commit is contained in:
Bernard Xiong 2019-05-16 13:49:45 +08:00 committed by GitHub
commit b7a6cc42de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 172 additions and 184 deletions

View File

@ -16,8 +16,8 @@ int gettimeofday(struct timeval *tp, void *ignore)
rt_device_t device;
device = rt_device_find("rtc");
if (device != RT_NULL)
{
RT_ASSERT(device != RT_NULL);
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
if (tp != RT_NULL)
{
@ -26,9 +26,6 @@ int gettimeofday(struct timeval *tp, void *ignore)
}
return time;
}
return 0;
}
#endif

View File

@ -16,8 +16,8 @@ int gettimeofday(struct timeval *tp, void *ignore)
rt_device_t device;
device = rt_device_find("rtc");
if (device != RT_NULL)
{
RT_ASSERT(device != RT_NULL);
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
if (tp != RT_NULL)
{
@ -26,9 +26,6 @@ int gettimeofday(struct timeval *tp, void *ignore)
}
return time;
}
return 0;
}
#endif

View File

@ -11,20 +11,20 @@
/* days per month -- nonleap! */
const short __spm[13] =
{ 0,
{ 0,
(31),
(31+28),
(31+28+31),
(31+28+31+30),
(31+28+31+30+31),
(31+28+31+30+31+30),
(31+28+31+30+31+30+31),
(31+28+31+30+31+30+31+31),
(31+28+31+30+31+30+31+31+30),
(31+28+31+30+31+30+31+31+30+31),
(31+28+31+30+31+30+31+31+30+31+30),
(31+28+31+30+31+30+31+31+30+31+30+31),
};
(31 + 28),
(31 + 28 + 31),
(31 + 28 + 31 + 30),
(31 + 28 + 31 + 30 + 31),
(31 + 28 + 31 + 30 + 31 + 30),
(31 + 28 + 31 + 30 + 31 + 30 + 31),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30),
(31 + 28 + 31 + 30 + 31 + 30 + 31 + 31 + 30 + 31 + 30 + 31),
};
static long int timezone;
static const char days[] = "Sun Mon Tue Wed Thu Fri Sat ";
static const char months[] = "Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec ";
@ -134,7 +134,7 @@ time_t mktime(struct tm * const t)
}
if (t->tm_year < 70)
return (time_t) -1;
return (time_t) - 1;
/* Days since 1970 is 365 * number of years + number of leap years since 1970 */
day = years * 365 + (years + 1) / 4;
@ -211,8 +211,8 @@ int gettimeofday(struct timeval *tp, void *ignore)
rt_device_t device;
device = rt_device_find("rtc");
if (device != RT_NULL)
{
RT_ASSERT(device != RT_NULL);
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
if (tp != RT_NULL)
{
@ -221,9 +221,6 @@ int gettimeofday(struct timeval *tp, void *ignore)
}
return time;
}
return 0;
}
#endif

View File

@ -16,8 +16,8 @@ int gettimeofday(struct timeval *tp, void *ignore)
rt_device_t device;
device = rt_device_find("rtc");
if (device != RT_NULL)
{
RT_ASSERT(device != RT_NULL);
rt_device_control(device, RT_DEVICE_CTRL_RTC_GET_TIME, &time);
if (tp != RT_NULL)
{
@ -26,9 +26,6 @@ int gettimeofday(struct timeval *tp, void *ignore)
}
return time;
}
return 0;
}
#endif