From 7db428f0bb28defcac0c05b9745d09237a8293d3 Mon Sep 17 00:00:00 2001 From: Vladimir Kondratyev Date: Wed, 29 Sep 2021 23:14:23 +0300 Subject: [PATCH] LinuxKPI: Add helper functions to store integers to linux/xarray.h Required by drm-kmod. Reviewed by: hselasky Differential revision: https://reviews.freebsd.org/D32091 (cherry picked from commit b59ffedae8f3707bf0079b4fd0cbf8190eed0c5e) --- .../linuxkpi/common/include/linux/xarray.h | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/sys/compat/linuxkpi/common/include/linux/xarray.h b/sys/compat/linuxkpi/common/include/linux/xarray.h index afe66c1f2b5..7427f6e4f9f 100644 --- a/sys/compat/linuxkpi/common/include/linux/xarray.h +++ b/sys/compat/linuxkpi/common/include/linux/xarray.h @@ -97,4 +97,27 @@ xa_init(struct xarray *xa) xa_init_flags(xa, 0); } +static inline void * +xa_mk_value(unsigned long v) +{ + unsigned long r = (v << 1) | 1; + + return ((void *)r); +} + +static inline bool +xa_is_value(const void *e) +{ + unsigned long v = (unsigned long)e; + + return (v & 1); +} + +static inline unsigned long +xa_to_value(const void *e) +{ + unsigned long v = (unsigned long)e; + + return (v >> 1); +} #endif /* _LINUX_XARRAY_H_ */