| 465 | RTM_EXPORT(timegm); |
| 466 | |
| 467 | int 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 | } |
| 507 | RTM_EXPORT(gettimeofday); |
| 508 | |
| 509 | int settimeofday(const struct timeval *tv, const struct timezone *tz) |