1
0

getrusage_time32.c 862 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "time32.h"
  2. #include <string.h>
  3. #include <stddef.h>
  4. #include <sys/resource.h>
  5. struct compat_rusage {
  6. struct timeval32 ru_utime;
  7. struct timeval32 ru_stime;
  8. long ru_maxrss;
  9. long ru_ixrss;
  10. long ru_idrss;
  11. long ru_isrss;
  12. long ru_minflt;
  13. long ru_majflt;
  14. long ru_nswap;
  15. long ru_inblock;
  16. long ru_oublock;
  17. long ru_msgsnd;
  18. long ru_msgrcv;
  19. long ru_nsignals;
  20. long ru_nvcsw;
  21. long ru_nivcsw;
  22. };
  23. int __getrusage_time32(int who, struct compat_rusage *usage)
  24. {
  25. struct rusage ru;
  26. int r = getrusage(who, &ru);
  27. if (!r) {
  28. usage->ru_utime.tv_sec = ru.ru_utime.tv_sec;
  29. usage->ru_utime.tv_usec = ru.ru_utime.tv_usec;
  30. usage->ru_stime.tv_sec = ru.ru_stime.tv_sec;
  31. usage->ru_stime.tv_usec = ru.ru_stime.tv_usec;
  32. memcpy(&usage->ru_maxrss, &ru.ru_maxrss,
  33. sizeof(struct compat_rusage) -
  34. offsetof(struct compat_rusage, ru_maxrss));
  35. }
  36. return r;
  37. }