stime.c 789 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * stime() for uClibc
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #ifdef __USE_SVID
  11. # include <time.h>
  12. # ifdef __NR_stime
  13. _syscall1(int, stime, const time_t *, t)
  14. # elif defined __USE_BSD && defined __NR_settimeofday
  15. # define __need_NULL
  16. # include <stddef.h>
  17. # include <errno.h>
  18. # include <sys/time.h>
  19. int stime(const time_t *when)
  20. {
  21. struct timeval tv;
  22. if (when == NULL) {
  23. __set_errno(EINVAL);
  24. return -1;
  25. }
  26. tv.tv_sec = *when;
  27. tv.tv_usec = 0;
  28. return settimeofday(&tv, (struct timezone *) 0);
  29. }
  30. # endif
  31. # if defined __NR_stime || (defined __USE_BSD && defined __NR_settimeofday)
  32. libc_hidden_def(stime)
  33. # endif
  34. #endif