diff options
Diffstat (limited to 'sysdeps/mach/hurd/times.c')
-rw-r--r-- | sysdeps/mach/hurd/times.c | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/sysdeps/mach/hurd/times.c b/sysdeps/mach/hurd/times.c index e232757090..2065aac49a 100644 --- a/sysdeps/mach/hurd/times.c +++ b/sysdeps/mach/hurd/times.c @@ -33,6 +33,17 @@ clock_from_time_value (const time_value_t *t) return t->seconds * 1000000 + t->microseconds; } +#if NO_CREATION_TIME +static time_value_t startup_time; +static void times_init (void) __attribute__ ((unused)); +static void +times_init (void) +{ + __gettimeofday ((struct timeval *) &startup_time, NULL); +} +text_set_element (__libc_subinit, times_init); +#endif + /* Store the CPU time used by this process and all its dead children (and their dead children) in BUFFER. Return the elapsed real time, or (clock_t) -1 for errors. @@ -66,15 +77,15 @@ __times (struct tms *tms) /* XXX This can't be implemented until getrusage(RUSAGE_CHILDREN) can be. */ tms->tms_cutime = tms->tms_cstime = 0; - err = __host_get_time (__mach_host_self (), &now); - if (err) - return __hurd_fail (err); + if (__gettimeofday ((struct timeval *) &now, NULL) < 0) + return -1; #if NO_CREATION_TIME - return 0; /* XXX */ +# define our_creation_time startup_time #else - return (clock_from_time_value (&now) - - clock_from_time_value (&bi.creation_time)); +# define our_creation_time bi.startup_time #endif + return (clock_from_time_value (&now) + - clock_from_time_value (&our_creation_time)); } weak_alias (__times, times) |