git: 7db428f0bb28 - stable/13 - LinuxKPI: Add helper functions to store integers to linux/xarray.h
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 13 Oct 2021 09:19:16 UTC
The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=7db428f0bb28defcac0c05b9745d09237a8293d3 commit 7db428f0bb28defcac0c05b9745d09237a8293d3 Author: Vladimir Kondratyev <wulf@FreeBSD.org> AuthorDate: 2021-09-29 20:14:23 +0000 Commit: Vladimir Kondratyev <wulf@FreeBSD.org> CommitDate: 2021-10-13 09:03:29 +0000 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) --- sys/compat/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 afe66c1f2b5f..7427f6e4f9f9 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_ */