30 #include <linux/export.h>
31 #include <linux/timex.h>
32 #include <linux/capability.h>
34 #include <linux/errno.h>
39 #include <linux/ptrace.h>
41 #include <asm/uaccess.h>
42 #include <asm/unistd.h>
44 #include "timeconst.h"
54 #ifdef __ARCH_WANT_SYS_TIME
133 static inline void warp_clock(
void)
138 adjust.tv_sec +=
sys_tz.tz_minuteswest * 60;
155 static int firsttime = 1;
158 if (tv && !timespec_valid(tv))
237 #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
239 #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
242 # if BITS_PER_LONG == 32
243 return (HZ_TO_MSEC_MUL32 * j) >> HZ_TO_MSEC_SHR32;
245 return (j * HZ_TO_MSEC_NUM) / HZ_TO_MSEC_DEN;
253 #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
255 #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
258 # if BITS_PER_LONG == 32
259 return (HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32;
261 return (j * HZ_TO_USEC_NUM) / HZ_TO_USEC_DEN;
288 }
else if (gran == 1000000000) {
291 t.tv_nsec -=
t.tv_nsec % gran;
313 mktime(
const unsigned int year0,
const unsigned int mon0,
314 const unsigned int day,
const unsigned int hour,
315 const unsigned int min,
const unsigned int sec)
317 unsigned int mon = mon0,
year = year0;
320 if (0 >= (
int) (mon -= 2)) {
325 return ((((
unsigned long)
326 (year/4 - year/100 + year/400 + 367*mon/12 + day) +
357 asm(
"" :
"+rm"(
nsec));
362 asm(
"" :
"+rm"(
nsec));
436 #if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
443 #elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
464 return (MSEC_TO_HZ_MUL32 * m + MSEC_TO_HZ_ADJ32)
474 #if HZ <= USEC_PER_SEC && !(USEC_PER_SEC % HZ)
476 #elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
479 return (USEC_TO_HZ_MUL32 * u + USEC_TO_HZ_ADJ32)
574 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
588 #if (HZ % USER_HZ)==0
598 return div_u64((
u64)x *
HZ, USER_HZ);
605 #if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
609 x = div_u64(x,
HZ / USER_HZ);
627 #if (NSEC_PER_SEC % USER_HZ) == 0
629 #elif (USER_HZ % 512) == 0
656 #if (NSEC_PER_SEC % HZ) == 0
659 #elif (HZ % 512) == 0
699 lhs.tv_nsec + rhs.tv_nsec);