aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linuxkpi/common/include/linux/kernel.h
diff options
context:
space:
mode:
authorBjoern A. Zeeb <bz@FreeBSD.org>2022-02-09 11:58:40 +0000
committerBjoern A. Zeeb <bz@FreeBSD.org>2022-02-14 00:20:41 +0000
commitc840d5cec2607932d077ffcfee7ccf0a6b50cdf3 (patch)
tree3f96f98f7a7c9882b0fb202bf090aa736b7cf4dd /sys/compat/linuxkpi/common/include/linux/kernel.h
parent0c37ffda799a9d44370bfe9898f220c193306842 (diff)
Diffstat (limited to 'sys/compat/linuxkpi/common/include/linux/kernel.h')
-rw-r--r--sys/compat/linuxkpi/common/include/linux/kernel.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h
index a84f577dd912..39520cd271ac 100644
--- a/sys/compat/linuxkpi/common/include/linux/kernel.h
+++ b/sys/compat/linuxkpi/common/include/linux/kernel.h
@@ -510,6 +510,21 @@ kstrtobool_from_user(const char __user *s, size_t count, bool *res)
}
static inline int
+kstrtoint_from_user(const char __user *s, size_t count, unsigned int base,
+ int *p)
+{
+ char buf[36] = {};
+
+ if (count > (sizeof(buf) - 1))
+ count = (sizeof(buf) - 1);
+
+ if (copy_from_user(buf, s, count))
+ return (-EFAULT);
+
+ return (kstrtoint(buf, base, p));
+}
+
+static inline int
kstrtou8_from_user(const char __user *s, size_t count, unsigned int base,
u8 *p)
{
@@ -684,6 +699,9 @@ hex2bin(uint8_t *bindst, const char *hexsrc, size_t binlen)
return (0);
}
+#define DECLARE_FLEX_ARRAY(_t, _n) \
+ struct { struct { } __dummy_ ## _n; _t _n[]; }
+
/*
* Checking if an option is defined would be easy if we could do CPP inside CPP.
* The defined case whether -Dxxx or -Dxxx=1 are easy to deal with. In either