X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/6be108db01439d3463342689446e457a315d6705..6b995c8cb722d10aaacba52999f5c43e43daeb85:/lunaix-os/arch/generic/includes/asm-generic/bits.h diff --git a/lunaix-os/arch/generic/includes/asm-generic/bits.h b/lunaix-os/arch/generic/includes/asm-generic/bits.h new file mode 100644 index 0000000..430e395 --- /dev/null +++ b/lunaix-os/arch/generic/includes/asm-generic/bits.h @@ -0,0 +1,13 @@ +#ifndef __LUNAIX_ARCH_GENERIC_BITS_H +#define __LUNAIX_ARCH_GENERIC_BITS_H + +#define _BITS_GENMASK(h, l) \ + (((1UL << ((h) + 1)) - 1) ^ ((1UL << (l)) - 1)) + +#define _BITS_EXTRACT(from, h, l) \ + (((from) & (((1UL << (h + 1)) - 1) ^ ((1UL << l) - 1))) >> l) + +#define _BITS_INSERT(to, from, h, l) \ + (((to) & ~_BITS_GENMASK(h, l)) | (((from) << l) & _BITS_GENMASK(h, l))) + +#endif /* __LUNAIX_ARCH_BITS_H */