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

Function settimeofday

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

Source from the content-addressed store, hash-verified

507RTM_EXPORT(gettimeofday);
508
509int settimeofday(const struct timeval *tv, const struct timezone *tz)
510{
511 /* The use of the timezone structure is obsolete;
512 * the tz argument should normally be specified as NULL.
513 * The tz_dsttime field has never been used under Linux.
514 * Thus, the following is purely of historic interest.
515 */
516#ifdef RT_USING_RTC
517 if (tv != RT_NULL && (long)tv->tv_usec >= 0 && (long)tv->tv_sec >= 0)
518 {
519 if (_control_rtc(RT_DEVICE_CTRL_RTC_SET_TIMEVAL, (void *)tv) == RT_EOK)
520 {
521 return 0;
522 }
523 else
524 {
525 if (_control_rtc(RT_DEVICE_CTRL_RTC_SET_TIME, (void *)&tv->tv_sec) == RT_EOK)
526 {
527 return 0;
528 }
529 }
530 }
531#endif /* RT_USING_RTC */
532
533 rt_set_errno(EINVAL);
534 return -1;
535}
536RTM_EXPORT(settimeofday);
537
538#if defined(RT_USING_POSIX_DELAY) && defined(RT_USING_KTIME)

Callers

nothing calls this directly

Calls 2

_control_rtcFunction · 0.85
rt_set_errnoFunction · 0.85

Tested by

no test coverage detected