times.c 354 B

12345678910111213141516
  1. #include <sys/types.h>
  2. #define Xval(xx) ((xx).l1*60+(xx).l2/(100000/6))
  3. times(bp)
  4. struct { time_t l1,l2,l3,l4;} *bp;
  5. {
  6. struct { struct { long l1,l2; }s1,s2; long x[20]; } t;
  7. if (getrusage(0,&t) < 0) return -1;
  8. bp->l1 = Xval(t.s1);
  9. bp->l2 = Xval(t.s2);
  10. if (getrusage(-1,&t) < 0) return -1;
  11. bp->l3 = Xval(t.s1);
  12. bp->l4 = Xval(t.s2);
  13. return 0;
  14. }