LinuxKPI: Add helper functions to store integers to linux/xarray.h

Required by drm-kmod.

Reviewed by:	hselasky
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D32091
This commit is contained in:
Vladimir Kondratyev 2021-09-29 23:14:23 +03:00
parent 62ff0566c9
commit b59ffedae8

View File

@ -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_ */