sched_rr_get_interval.c 631 B

123456789101112131415161718192021
  1. #include <sched.h>
  2. #include "syscall.h"
  3. int sched_rr_get_interval(pid_t pid, struct timespec *ts)
  4. {
  5. #ifdef SYS_sched_rr_get_interval_time64
  6. /* On a 32-bit arch, use the old syscall if it exists. */
  7. if (SYS_sched_rr_get_interval != SYS_sched_rr_get_interval_time64) {
  8. long ts32[2];
  9. int r = __syscall(SYS_sched_rr_get_interval, pid, ts32);
  10. if (!r) {
  11. ts->tv_sec = ts32[0];
  12. ts->tv_nsec = ts32[1];
  13. }
  14. return __syscall_ret(r);
  15. }
  16. #endif
  17. /* If reaching this point, it's a 64-bit arch or time64-only
  18. * 32-bit arch and we can get result directly into timespec. */
  19. return syscall(SYS_sched_rr_get_interval, pid, ts);
  20. }