stime.c 764 B

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