From: jsg Date: Tue, 23 Jan 2024 04:47:13 +0000 (+0000) Subject: move more defines out of kernel.h X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c96eac12212738df022e8da546facc2482b97a41;p=openbsd move more defines out of kernel.h --- diff --git a/sys/dev/pci/drm/include/linux/align.h b/sys/dev/pci/drm/include/linux/align.h index 183c68ca274..1db3dcdf279 100644 --- a/sys/dev/pci/drm/include/linux/align.h +++ b/sys/dev/pci/drm/include/linux/align.h @@ -5,7 +5,14 @@ #include +#define roundup2(x, y) (((x) + ((y) - 1)) & (~((__typeof(x))(y) - 1))) +#define rounddown2(x, y) ((x) & ~((__typeof(x))(y) - 1)) + #undef ALIGN #define ALIGN(x, y) roundup2((x), (y)) +#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0) +#define PTR_ALIGN(x, y) ((__typeof(x))roundup2((unsigned long)(x), (y))) +#define ALIGN_DOWN(x, y) ((__typeof(x))rounddown2((unsigned long)(x), (y))) + #endif diff --git a/sys/dev/pci/drm/include/linux/kernel.h b/sys/dev/pci/drm/include/linux/kernel.h index cc2c70edabc..76f1d3488da 100644 --- a/sys/dev/pci/drm/include/linux/kernel.h +++ b/sys/dev/pci/drm/include/linux/kernel.h @@ -3,7 +3,6 @@ #ifndef _LINUX_KERNEL_H #define _LINUX_KERNEL_H -#include #include #include #include @@ -19,24 +18,13 @@ #include #include #include +#include +#include #include #define swap(a, b) \ do { __typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0) -#define offsetofend(s, e) (offsetof(s, e) + sizeof((((s *)0)->e))) - -#define S8_MAX INT8_MAX -#define S16_MAX INT16_MAX -#define S32_MAX INT32_MAX -#define S64_MAX INT64_MAX - -#define U8_MAX UINT8_MAX -#define U16_MAX UINT16_MAX -#define U32_MAX UINT32_MAX -#define U64_C(x) UINT64_C(x) -#define U64_MAX UINT64_MAX - #define ARRAY_SIZE nitems #define lower_32_bits(n) ((u32)(n)) @@ -65,24 +53,6 @@ #define min_not_zero(a, b) (a == 0) ? b : ((b == 0) ? a : min(a, b)) -#define mult_frac(x, n, d) (((x) * (n)) / (d)) - -#define roundup2(x, y) (((x) + ((y) - 1)) & (~((__typeof(x))(y) - 1))) -#define rounddown2(x, y) ((x) & ~((__typeof(x))(y) - 1)) -#define round_up(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) -#define round_down(x, y) (((x) / (y)) * (y)) /* y is power of two */ -#define rounddown(x, y) (((x) / (y)) * (y)) /* arbitrary y */ -#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y)) -#define DIV_ROUND_UP_ULL(x, y) DIV_ROUND_UP(x, y) -#define DIV_ROUND_DOWN(x, y) ((x) / (y)) -#define DIV_ROUND_DOWN_ULL(x, y) DIV_ROUND_DOWN(x, y) -#define DIV_ROUND_CLOSEST(x, y) (((x) + ((y) / 2)) / (y)) -#define DIV_ROUND_CLOSEST_ULL(x, y) DIV_ROUND_CLOSEST(x, y) - -#define IS_ALIGNED(x, y) (((x) & ((y) - 1)) == 0) -#define PTR_ALIGN(x, y) ((__typeof(x))roundup2((unsigned long)(x), (y))) -#define ALIGN_DOWN(x, y) ((__typeof(x))rounddown2((unsigned long)(x), (y))) - static inline char * kvasprintf(int flags, const char *fmt, va_list ap) { @@ -127,17 +97,6 @@ vscnprintf(char *buf, size_t size, const char *fmt, va_list ap) return nc; } -static inline int -_in_dbg_master(void) -{ -#ifdef DDB - return (db_active); -#endif - return (0); -} - -#define oops_in_progress _in_dbg_master() - #define might_sleep() assertwaitok() #define might_sleep_if(x) do { \ if (x) \ diff --git a/sys/dev/pci/drm/include/linux/limits.h b/sys/dev/pci/drm/include/linux/limits.h index e69de29bb2d..93e6c0b7566 100644 --- a/sys/dev/pci/drm/include/linux/limits.h +++ b/sys/dev/pci/drm/include/linux/limits.h @@ -0,0 +1,19 @@ +/* Public domain. */ + +#ifndef _LINUX_LIMITS_H +#define _LINUX_LIMITS_H + +#include + +#define S8_MAX INT8_MAX +#define S16_MAX INT16_MAX +#define S32_MAX INT32_MAX +#define S64_MAX INT64_MAX + +#define U8_MAX UINT8_MAX +#define U16_MAX UINT16_MAX +#define U32_MAX UINT32_MAX +#define U64_C(x) UINT64_C(x) +#define U64_MAX UINT64_MAX + +#endif diff --git a/sys/dev/pci/drm/include/linux/math.h b/sys/dev/pci/drm/include/linux/math.h index e7d97986fa4..fbec6075ad0 100644 --- a/sys/dev/pci/drm/include/linux/math.h +++ b/sys/dev/pci/drm/include/linux/math.h @@ -3,4 +3,16 @@ #ifndef _LINUX_MATH_H #define _LINUX_MATH_H +#define mult_frac(x, n, d) (((x) * (n)) / (d)) + +#define round_up(x, y) ((((x) + ((y) - 1)) / (y)) * (y)) +#define round_down(x, y) (((x) / (y)) * (y)) /* y is power of two */ +#define rounddown(x, y) (((x) / (y)) * (y)) /* arbitrary y */ +#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y)) +#define DIV_ROUND_UP_ULL(x, y) DIV_ROUND_UP(x, y) +#define DIV_ROUND_DOWN(x, y) ((x) / (y)) +#define DIV_ROUND_DOWN_ULL(x, y) DIV_ROUND_DOWN(x, y) +#define DIV_ROUND_CLOSEST(x, y) (((x) + ((y) / 2)) / (y)) +#define DIV_ROUND_CLOSEST_ULL(x, y) DIV_ROUND_CLOSEST(x, y) + #endif diff --git a/sys/dev/pci/drm/include/linux/printk.h b/sys/dev/pci/drm/include/linux/printk.h index e7fc370f11e..f2c4e954c8d 100644 --- a/sys/dev/pci/drm/include/linux/printk.h +++ b/sys/dev/pci/drm/include/linux/printk.h @@ -69,4 +69,15 @@ struct va_format { va_list *va; }; +static inline int +_in_dbg_master(void) +{ +#ifdef DDB + return (db_active); +#endif + return (0); +} + +#define oops_in_progress _in_dbg_master() + #endif diff --git a/sys/dev/pci/drm/include/linux/stddef.h b/sys/dev/pci/drm/include/linux/stddef.h index 443d51101a9..b98034ee8e5 100644 --- a/sys/dev/pci/drm/include/linux/stddef.h +++ b/sys/dev/pci/drm/include/linux/stddef.h @@ -6,4 +6,6 @@ #define DECLARE_FLEX_ARRAY(t, n) \ struct { struct{} n ## __unused; t n[]; } +#define offsetofend(s, e) (offsetof(s, e) + sizeof((((s *)0)->e))) + #endif