sync with OpenBSD -current
This commit is contained in:
parent
18e54d401d
commit
9394581c89
58 changed files with 711 additions and 763 deletions
|
@ -5,7 +5,14 @@
|
|||
|
||||
#include <sys/param.h>
|
||||
|
||||
#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
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
/* Public domain. */
|
||||
|
||||
#ifndef _LINUX_ARGS_H
|
||||
#define _LINUX_ARGS_H
|
||||
|
||||
#define CONCATENATE(x, y) __CONCAT(x, y)
|
||||
|
||||
#endif
|
|
@ -3,7 +3,6 @@
|
|||
#ifndef _LINUX_KERNEL_H
|
||||
#define _LINUX_KERNEL_H
|
||||
|
||||
#include <sys/stdint.h>
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/stdarg.h>
|
||||
|
@ -19,24 +18,13 @@
|
|||
#include <linux/container_of.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/align.h>
|
||||
#include <linux/math.h>
|
||||
#include <linux/limits.h>
|
||||
#include <asm/byteorder.h>
|
||||
|
||||
#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) \
|
||||
|
@ -155,8 +114,6 @@ _in_dbg_master(void)
|
|||
|
||||
#define STUB() do { printf("%s: stub\n", __func__); } while(0)
|
||||
|
||||
#define CONCATENATE(x, y) __CONCAT(x, y)
|
||||
|
||||
#define PTR_IF(c, p) ((c) ? (p) : NULL)
|
||||
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/* Public domain. */
|
||||
|
||||
#ifndef _LINUX_LIMITS_H
|
||||
#define _LINUX_LIMITS_H
|
||||
|
||||
#include <sys/stdint.h>
|
||||
|
||||
#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
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue