diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2004-10-14 15:33:33 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2004-10-14 15:33:33 -0400 |
| commit | e58d2eb090023ea4b8e1fe0af2a1bb5314ecfdcb (patch) | |
| tree | bfc1440ee2d3558f78c690d807b7bc788201b301 /include/linux/times.h | |
| parent | 5c6f34a71be8749b386e5a773fea0f4784da6a51 (diff) | |
| parent | 8b5915b08dda13ffe1f70f00322dcc34ce161904 (diff) | |
Merge pobox.com:/spare/repo/linux-2.6
into pobox.com:/spare/repo/libata-2.6
Diffstat (limited to 'include/linux/times.h')
| -rw-r--r-- | include/linux/times.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/include/linux/times.h b/include/linux/times.h index ff00f334ffaa..0c5aa078dad4 100644 --- a/include/linux/times.h +++ b/include/linux/times.h @@ -55,6 +55,26 @@ static inline u64 jiffies_64_to_clock_t(u64 x) } #endif +static inline u64 nsec_to_clock_t(u64 x) +{ +#if (NSEC_PER_SEC % USER_HZ) == 0 + do_div(x, (NSEC_PER_SEC / USER_HZ)); +#elif (USER_HZ % 512) == 0 + x *= USER_HZ/512; + do_div(x, (NSEC_PER_SEC / 512)); +#else + /* + * max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024, + * overflow after 64.99 years. + * exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ... + */ + x *= 9; + do_div(x, (unsigned long)((9ull * NSEC_PER_SEC + (USER_HZ/2)) + / USER_HZ)); +#endif + return x; +} + struct tms { clock_t tms_utime; clock_t tms_stime; |
