iso9660fs: initialize buffer cache
[minix.git] / include / minix / u64.h
blob466b73e3f95c4c29a28fc215f4cd00eed2f2c28d
1 /* minix/u64.h Author: Kees J. Bot
2 * 7 Dec 1995
3 * Functions to manipulate 64 bit disk addresses.
4 */
5 #ifndef _MINIX__U64_H
6 #define _MINIX__U64_H
8 #ifndef _TYPES_H
9 #include <minix/types.h>
10 #endif
12 #include <limits.h>
14 #define is_zero64(i) ((i) == 0)
15 #define make_zero64(i) ((i) = 0)
16 #define neg64(i) ((i) = -(i))
18 static inline u64_t add64(u64_t i, u64_t j)
20 return i + j;
23 static inline u64_t add64u(u64_t i, unsigned j)
25 return i + j;
28 static inline u64_t add64ul(u64_t i, unsigned long j)
30 return i + j;
33 static inline int bsr64(u64_t i)
35 int index;
36 u64_t mask;
38 for (index = 63, mask = 1ULL << 63; index >= 0; --index, mask >>= 1) {
39 if (i & mask)
40 return index;
43 return -1;
46 static inline int cmp64(u64_t i, u64_t j)
48 if (i > j)
49 return 1;
50 else if (i < j)
51 return -1;
52 else /* (i == j) */
53 return 0;
56 static inline int cmp64u(u64_t i, unsigned j)
58 if (i > j)
59 return 1;
60 else if (i < j)
61 return -1;
62 else /* (i == j) */
63 return 0;
66 static inline int cmp64ul(u64_t i, unsigned long j)
68 if (i > j)
69 return 1;
70 else if (i < j)
71 return -1;
72 else /* (i == j) */
73 return 0;
76 static inline unsigned cv64u(u64_t i)
78 /* return ULONG_MAX if really big */
79 if (i>>32)
80 return ULONG_MAX;
82 return (unsigned)i;
85 static inline unsigned long cv64ul(u64_t i)
87 /* return ULONG_MAX if really big */
88 if (i>>32)
89 return ULONG_MAX;
91 return (unsigned long)i;
94 static inline u64_t cvu64(unsigned i)
96 return i;
99 static inline u64_t cvul64(unsigned long i)
101 return i;
104 static inline unsigned diff64(u64_t i, u64_t j)
106 return (unsigned)(i - j);
109 static inline u64_t div64(u64_t i, u64_t j)
111 return i / j;
114 static inline u64_t rem64(u64_t i, u64_t j)
116 return i % j;
119 static inline unsigned long div64u(u64_t i, unsigned j)
121 return (unsigned long)(i / j);
124 static inline u64_t div64u64(u64_t i, unsigned j)
126 return i / j;
129 static inline unsigned rem64u(u64_t i, unsigned j)
131 return (unsigned)(i % j);
134 static inline unsigned long ex64lo(u64_t i)
136 return (unsigned long)i;
139 static inline unsigned long ex64hi(u64_t i)
141 return (unsigned long)(i>>32);
144 static inline u64_t make64(unsigned long lo, unsigned long hi)
146 return ((u64_t)hi << 32) | (u64_t)lo;
149 static inline u64_t mul64(u64_t i, u64_t j)
151 return i * j;
154 static inline u64_t mul64u(unsigned long i, unsigned j)
156 return (u64_t)i * j;
159 static inline u64_t sub64(u64_t i, u64_t j)
161 return i - j;
164 static inline u64_t sub64u(u64_t i, unsigned j)
166 return i - j;
169 static inline u64_t sub64ul(u64_t i, unsigned long j)
171 return i - j;
174 u64_t rrotate64(u64_t x, unsigned short b);
175 u64_t rshift64(u64_t x, unsigned short b);
176 u64_t xor64(u64_t a, u64_t b);
177 u64_t and64(u64_t a, u64_t b);
178 u64_t not64(u64_t a);
180 #endif /* _MINIX__U64_H */