kernel: add utility math functions
This commit is contained in:
@@ -6,5 +6,14 @@
|
|||||||
|
|
||||||
extern void data_size_to_string(size_t value, char *out, size_t outsz);
|
extern void data_size_to_string(size_t value, char *out, size_t outsz);
|
||||||
static inline bool power_of_2(size_t x) { return (x > 0 && (x & (x - 1)) == 0); }
|
static inline bool power_of_2(size_t x) { return (x > 0 && (x & (x - 1)) == 0); }
|
||||||
|
static inline unsigned long long div64_pow2(unsigned long long x, unsigned long long y)
|
||||||
|
{
|
||||||
|
return x >> (__builtin_ctz(y));
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline unsigned long long absdiff64(unsigned long long x, unsigned long long y)
|
||||||
|
{
|
||||||
|
return x > y ? y - x : x - y;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user