MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / gettimeofday

Function gettimeofday

components/libc/compilers/common/ctime.c:467–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465RTM_EXPORT(timegm);
466
467int gettimeofday(struct timeval *tv, struct timezone *tz)
468{
469 /* The use of the timezone structure is obsolete;
470 * the tz argument should normally be specified as NULL.
471 * The tz_dsttime field has never been used under Linux.
472 * Thus, the following is purely of historic interest.
473 */
474 if(tz != RT_NULL)
475 {
476 tz->tz_dsttime = DST_NONE;
477#if defined(RT_LIBC_USING_LIGHT_TZ_DST)
478 tz->tz_minuteswest = -(rt_tz_get() / 60);
479#else
480 tz->tz_minuteswest = 0;
481#endif /* RT_LIBC_USING_LIGHT_TZ_DST */
482 }
483
484#ifdef RT_USING_RTC
485 if (tv != RT_NULL)
486 {
487 tv->tv_sec = 0;
488 tv->tv_usec = 0;
489
490 if (_control_rtc(RT_DEVICE_CTRL_RTC_GET_TIMEVAL, tv) == RT_EOK)
491 {
492 return 0;
493 }
494 else
495 {
496 if (_control_rtc(RT_DEVICE_CTRL_RTC_GET_TIME, (void *)&tv->tv_sec) == RT_EOK)
497 {
498 return 0;
499 }
500 }
501 }
502#endif /* RT_USING_RTC */
503
504 rt_set_errno(EINVAL);
505 return -1;
506}
507RTM_EXPORT(gettimeofday);
508
509int settimeofday(const struct timeval *tv, const struct timezone *tz)

Callers 10

getmicrotimeFunction · 0.85
dateFunction · 0.85
cmd_rtc_syncFunction · 0.85
ulog_head_formaterFunction · 0.85
reset_link_statsFunction · 0.85
update_link_statsFunction · 0.85
reset_link_statsFunction · 0.85
update_link_statsFunction · 0.85
file_mode_sendFunction · 0.85
test_threadFunction · 0.85

Calls 3

rt_tz_getFunction · 0.85
_control_rtcFunction · 0.85
rt_set_errnoFunction · 0.85

Tested by 1

test_threadFunction · 0.68