-/* $OpenBSD: drm_linux.h,v 1.70 2018/01/30 08:31:38 jsg Exp $ */
+/* $OpenBSD: drm_linux.h,v 1.71 2018/01/30 08:35:21 jsg Exp $ */
/*
* Copyright (c) 2013, 2014, 2015 Mark Kettenis
* Copyright (c) 2017 Martin Pieuchot
}
#define mult_frac(x, n, d) (((x) * (n)) / (d))
+#define order_base_2(x) drm_order(x)
static inline int64_t
abs64(int64_t x)
#define DIV_ROUND_CLOSEST(x, y) (((x) + ((y) / 2)) / (y))
#define DIV_ROUND_CLOSEST_ULL(x, y) DIV_ROUND_CLOSEST(x, y)
+/*
+ * Compute the greatest common divisor of a and b.
+ * from libc getopt_long.c
+ */
+static inline unsigned long
+gcd(unsigned long a, unsigned long b)
+{
+ unsigned long c;
+
+ c = a % b;
+ while (c != 0) {
+ a = b;
+ b = c;
+ c = a % b;
+ }
+
+ return (b);
+}
+
+
static inline unsigned long
roundup_pow_of_two(unsigned long x)
{
return flsl((size - 1) >> PAGE_SHIFT);
}
+#define ilog2(x) ((sizeof(x) <= 4) ? (fls(x) - 1) : (flsl(x) - 1))
+
#if defined(__i386__) || defined(__amd64__)
#define _PAGE_PRESENT PG_V