setitimer.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * setitimer() 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. #include <sys/time.h>
  10. #if defined(__UCLIBC_USE_TIME64__)
  11. struct itimerval32_struct {
  12. __S32_TYPE __interval_sec;
  13. __S32_TYPE __interval_usec;
  14. __S32_TYPE __value_sec;
  15. __S32_TYPE __value_usec;
  16. };
  17. int setitimer(__itimer_which_t which, const struct itimerval *restrict new, struct itimerval *restrict old)
  18. {
  19. struct itimerval32_struct __itv32 = {
  20. .__interval_sec = new->it_interval.tv_sec,
  21. .__interval_usec = new->it_interval.tv_usec,
  22. .__value_sec = new->it_value.tv_sec,
  23. .__value_usec = new->it_value.tv_usec
  24. };
  25. struct itimerval32_struct __itv32_old;
  26. int __ret = INLINE_SYSCALL(setitimer, 3, which, &__itv32, &__itv32_old);
  27. if (__ret == 0 && old) {
  28. old->it_interval.tv_sec = __itv32_old.__interval_sec;
  29. old->it_interval.tv_usec = __itv32_old.__interval_usec;
  30. old->it_value.tv_sec = __itv32_old.__value_sec;
  31. old->it_value.tv_usec = __itv32_old.__value_usec;
  32. }
  33. return __ret;
  34. }
  35. #else
  36. _syscall3(int, setitimer, __itimer_which_t, which,
  37. const struct itimerval *, new, struct itimerval *, old)
  38. #endif
  39. libc_hidden_def(setitimer)