time.c 333 B

1234567891011121314151617181920
  1. #include <errno.h>
  2. #include <sys/time.h>
  3. #include <syscall.h>
  4. int gettimeofday(struct timeval* tv, struct timezone* tz)
  5. {
  6. if (tz) {
  7. errno = -EINVAL;
  8. return -1;
  9. }
  10. int ret = syscall2(SYS_gettimeofday, (uint32_t)tv, 0);
  11. if (ret < 0) {
  12. errno = -ret;
  13. return -1;
  14. }
  15. return ret;
  16. }