|
17 | 17 |
|
18 | 18 | #include "rusagestub.h" |
19 | 19 |
|
20 | | -/* This code works on: |
21 | | - * solaris_i386 |
22 | | - * solaris_sparc |
23 | | - * win32 |
24 | | - * which currently is all the supported platforms that don't have a |
25 | | - * native version of getrusage(). So, if configure decides to compile |
26 | | - * this file at all, we just use this version unconditionally. |
| 20 | +/* |
| 21 | + * This code works on Windows, which is the only supported platform without a |
| 22 | + * native version of getrusage(). |
27 | 23 | */ |
28 | 24 |
|
29 | 25 | int |
30 | 26 | getrusage(int who, struct rusage *rusage) |
31 | 27 | { |
32 | | -#ifdef WIN32 |
33 | 28 | FILETIME starttime; |
34 | 29 | FILETIME exittime; |
35 | 30 | FILETIME kerneltime; |
@@ -66,44 +61,6 @@ getrusage(int who, struct rusage *rusage) |
66 | 61 | li.QuadPart /= 10L; /* Convert to microseconds */ |
67 | 62 | rusage->ru_utime.tv_sec = li.QuadPart / 1000000L; |
68 | 63 | rusage->ru_utime.tv_usec = li.QuadPart % 1000000L; |
69 | | -#else /* all but WIN32 */ |
70 | | - |
71 | | - struct tms tms; |
72 | | - int tick_rate = CLK_TCK; /* ticks per second */ |
73 | | - clock_t u, |
74 | | - s; |
75 | | - |
76 | | - if (rusage == (struct rusage *) NULL) |
77 | | - { |
78 | | - errno = EFAULT; |
79 | | - return -1; |
80 | | - } |
81 | | - if (times(&tms) < 0) |
82 | | - { |
83 | | - /* errno set by times */ |
84 | | - return -1; |
85 | | - } |
86 | | - switch (who) |
87 | | - { |
88 | | - case RUSAGE_SELF: |
89 | | - u = tms.tms_utime; |
90 | | - s = tms.tms_stime; |
91 | | - break; |
92 | | - case RUSAGE_CHILDREN: |
93 | | - u = tms.tms_cutime; |
94 | | - s = tms.tms_cstime; |
95 | | - break; |
96 | | - default: |
97 | | - errno = EINVAL; |
98 | | - return -1; |
99 | | - } |
100 | | -#define TICK_TO_SEC(T, RATE) ((T)/(RATE)) |
101 | | -#define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) |
102 | | - rusage->ru_utime.tv_sec = TICK_TO_SEC(u, tick_rate); |
103 | | - rusage->ru_utime.tv_usec = TICK_TO_USEC(u, tick_rate); |
104 | | - rusage->ru_stime.tv_sec = TICK_TO_SEC(s, tick_rate); |
105 | | - rusage->ru_stime.tv_usec = TICK_TO_USEC(u, tick_rate); |
106 | | -#endif /* WIN32 */ |
107 | 64 |
|
108 | 65 | return 0; |
109 | 66 | } |
0 commit comments