feat: a better boot command line parser
[lunaix-os.git] / lunaix-os / includes / lunaix / compiler.h
1 #ifndef __LUNAIX_COMPILER_H
2 #define __LUNAIX_COMPILER_H
3
4 #define likely(x) __builtin_expect((x), 1)
5 #define unlikely(x) __builtin_expect((x), 0)
6
7 #define weak_alias(name) __attribute__((weak, alias(name)))
8 #define weak __attribute__((weak))
9 #define noret __attribute__((noreturn))
10 #define optimize(opt) __attribute__((optimize(opt)))
11 #define must_inline __attribute__((always_inline))
12
13 #define clz(bits) __builtin_clz(bits)
14 #define sadd_overflow(a, b, of) __builtin_sadd_overflow(a, b, of)
15 #define umul_overflow(a, b, of) __builtin_umul_overflow(a, b, of)
16 #define offsetof(f, m) __builtin_offsetof(f, m)
17
18 #define prefetch_rd(ptr, ll) __builtin_prefetch((ptr), 0, ll)
19 #define prefetch_wr(ptr, ll) __builtin_prefetch((ptr), 1, ll)
20
21 #define stringify(v) #v
22 #define stringify__(v) stringify(v)
23
24 #define compact __attribute__((packed))
25 #define align(v) __attribute__((aligned (v)))
26
27 inline static void noret
28 spin()
29 {
30     volatile int __infloop = 1;
31     while (__infloop)
32         ;
33     __builtin_unreachable();
34 }
35
36 #endif /* __LUNAIX_COMPILER_H */