refactor: add a async read/write variant to device ops, with allow async io to be...
[lunaix-os.git] / lunaix-os / includes / lunaix / compiler.h
index 314afd95e297948b6d3596f341ed6f770c32c819..68a43ead66721a7998af8dcbb9bf2f6ebd811edb 100644 (file)
@@ -7,8 +7,27 @@
 #define weak_alias(name) __attribute__((weak, alias(name)))
 #define weak __attribute__((weak))
 #define noret __attribute__((noreturn))
+#define optimize(opt) __attribute__((optimize(opt)))
+#define must_inline __attribute__((always_inline))
+
+#define clz(bits) __builtin_clz(bits)
+#define sadd_overflow(a, b, of) __builtin_sadd_overflow(a, b, of)
+#define umul_overflow(a, b, of) __builtin_umul_overflow(a, b, of)
+#define offsetof(f, m) __builtin_offsetof(f, m)
+
+#define prefetch_rd(ptr, ll) __builtin_prefetch((ptr), 0, ll)
+#define prefetch_wr(ptr, ll) __builtin_prefetch((ptr), 1, ll)
 
 #define stringify(v) #v
 #define stringify__(v) stringify(v)
 
+inline static void noret
+spin()
+{
+    volatile int __infloop = 1;
+    while (__infloop)
+        ;
+    __builtin_unreachable();
+}
+
 #endif /* __LUNAIX_COMPILER_H */