1/****************************************************************************
2 ****************************************************************************
3 ***
4 ***   This header was automatically generated from a Linux kernel header
5 ***   of the same name, to make information necessary for userspace to
6 ***   call into the kernel available to libc.  It contains only constants,
7 ***   structures, and macros generated from the original header, and thus,
8 ***   contains no copyrightable information.
9 ***
10 ****************************************************************************
11 ****************************************************************************/
12#ifndef _LINUX_JIFFIES_H
13#define _LINUX_JIFFIES_H
14
15#include <linux/calc64.h>
16#include <linux/kernel.h>
17#include <linux/types.h>
18#include <linux/time.h>
19#include <linux/timex.h>
20#include <asm/param.h>
21
22#if HZ >= (12 && HZ < 24)
23#define SHIFT_HZ 4
24#elif HZ >= 24 && HZ < 48
25#define SHIFT_HZ 5
26#elif HZ >= 48 && HZ < 96
27#define SHIFT_HZ 6
28#elif HZ >= 96 && HZ < 192
29#define SHIFT_HZ 7
30#elif HZ >= 192 && HZ < 384
31#define SHIFT_HZ 8
32#elif HZ >= 384 && HZ < 768
33#define SHIFT_HZ 9
34#elif HZ >= 768 && HZ < 1536
35#define SHIFT_HZ 10
36#else
37#error You lose.
38#endif
39
40#define LATCH ((CLOCK_TICK_RATE + HZ/2) / HZ)
41
42#define LATCH_HPET ((HPET_TICK_RATE + HZ/2) / HZ)
43
44#define SH_DIV(NOM,DEN,LSH) ( (((NOM) / (DEN)) << (LSH))   + ((((NOM) % (DEN)) << (LSH)) + (DEN) / 2) / (DEN))
45
46#define ACTHZ (SH_DIV (CLOCK_TICK_RATE, LATCH, 8))
47
48#define ACTHZ_HPET (SH_DIV (HPET_TICK_RATE, LATCH_HPET, 8))
49
50#define TICK_NSEC (SH_DIV (1000000UL * 1000, ACTHZ, 8))
51
52#define TICK_NSEC_HPET (SH_DIV(1000000UL * 1000, ACTHZ_HPET, 8))
53
54#define TICK_USEC ((1000000UL + USER_HZ/2) / USER_HZ)
55
56#define TICK_USEC_TO_NSEC(TUSEC) (SH_DIV (TUSEC * USER_HZ * 1000, ACTHZ, 8))
57
58#define __jiffy_data __attribute__((section(".data")))
59
60#if BITS_PER_LONG < 64
61
62#else
63#endif
64#define time_after(a,b)   (typecheck(unsigned long, a) &&   typecheck(unsigned long, b) &&   ((long)(b) - (long)(a) < 0))
65#define time_before(a,b) time_after(b,a)
66#define time_after_eq(a,b)   (typecheck(unsigned long, a) &&   typecheck(unsigned long, b) &&   ((long)(a) - (long)(b) >= 0))
67#define time_before_eq(a,b) time_after_eq(b,a)
68#define INITIAL_JIFFIES ((unsigned long)(unsigned int) (-300*HZ))
69#define MAX_JIFFY_OFFSET ((~0UL >> 1)-1)
70#define SEC_JIFFIE_SC (31 - SHIFT_HZ)
71#if !((NSEC_PER_SEC << 2) / TICK_NSEC << SEC_JIFFIE_SC - 2 & 0x80000000)
72#undef SEC_JIFFIE_SC
73#define SEC_JIFFIE_SC (32 - SHIFT_HZ)
74#endif
75#define NSEC_JIFFIE_SC (SEC_JIFFIE_SC + 29)
76#define USEC_JIFFIE_SC (SEC_JIFFIE_SC + 19)
77#define SEC_CONVERSION ((unsigned long)((((u64)NSEC_PER_SEC << SEC_JIFFIE_SC) +  TICK_NSEC -1) / (u64)TICK_NSEC))
78#define NSEC_CONVERSION ((unsigned long)((((u64)1 << NSEC_JIFFIE_SC) +  TICK_NSEC -1) / (u64)TICK_NSEC))
79#define USEC_CONVERSION   ((unsigned long)((((u64)NSEC_PER_USEC << USEC_JIFFIE_SC) +  TICK_NSEC -1) / (u64)TICK_NSEC))
80#define USEC_ROUND (u64)(((u64)1 << USEC_JIFFIE_SC) - 1)
81#if BITS_PER_LONG < 64
82#define MAX_SEC_IN_JIFFIES   (long)((u64)((u64)MAX_JIFFY_OFFSET * TICK_NSEC) / NSEC_PER_SEC)
83#else
84#define MAX_SEC_IN_JIFFIES   (SH_DIV((MAX_JIFFY_OFFSET >> SEC_JIFFIE_SC) * TICK_NSEC, NSEC_PER_SEC, 1) - 1)
85#endif
86#if HZ <= (MSEC_PER_SEC && !(MSEC_PER_SEC % HZ))
87#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
88#else
89#endif
90#if HZ <= (USEC_PER_SEC && !(USEC_PER_SEC % HZ))
91#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
92#else
93#endif
94#if HZ <= (MSEC_PER_SEC && !(MSEC_PER_SEC % HZ))
95#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
96#else
97#endif
98#if HZ <= (USEC_PER_SEC && !(USEC_PER_SEC % HZ))
99#elif HZ > USEC_PER_SEC && !(HZ % USEC_PER_SEC)
100#else
101#endif
102#if TICK_NSEC % NSEC_PER_SEC / USER_HZ == 0
103#else
104#endif
105#if HZ % USER_HZ == 0
106#else
107#endif
108#if TICK_NSEC % NSEC_PER_SEC / USER_HZ == 0
109#else
110#endif
111#if NSEC_PER_SEC % USER_HZ == 0
112#elif (USER_HZ % 512) == 0
113#else
114#endif
115#endif
116