1 #ifndef __LUNAIX_ARCH_GENERIC_BITS_H
2 #define __LUNAIX_ARCH_GENERIC_BITS_H
4 #define _BITS_GENMASK(h, l) \
5 (((1UL << ((h) + 1)) - 1) ^ ((1UL << (l)) - 1))
7 #define _BITS_EXTRACT(from, h, l) \
8 (((from) & (((1UL << (h + 1)) - 1) ^ ((1UL << l) - 1))) >> l)
10 #define _BITS_INSERT(to, from, h, l) \
11 (((to) & ~_BITS_GENMASK(h, l)) | (((from) << l) & _BITS_GENMASK(h, l)))
13 #endif /* __LUNAIX_ARCH_BITS_H */