add basic exception model and context switching for aarch64
[lunaix-os.git] / lunaix-os / includes / lunaix / bits.h
diff --git a/lunaix-os/includes/lunaix/bits.h b/lunaix-os/includes/lunaix/bits.h
new file mode 100644 (file)
index 0000000..1029bb0
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef __LUNAIX_BITS_H
+#define __LUNAIX_BITS_H
+
+#include <lunaix/compiler.h>
+
+#define BITS(h, l)               (((1UL << ((h) + 1)) - 1) ^ ((1UL << (l)) - 1))
+#define BIT(p)                   BITS(p, p)
+
+#define BITS_GET(from, bits)     (((from) & (bits)) >> ctzl(bits))
+
+#define BITS_SET(to, bits, val)  \
+            (((to) & ~(bits)) | (((val) << ctzl(bits)) & (bits)))
+
+#endif /* __LUNAIX_BITS_H */