20 #ifndef KERNEL_COMPILER_H 21 #define KERNEL_COMPILER_H 33 #define DEPRECATED __attribute__((deprecated)) 35 #define NORETURN __attribute__((noreturn)) 37 #define PURE __attribute__((pure)) 40 #define CONST __attribute__((const)) 42 #define ALWAYS_INLINE __attribute__((always_inline)) 44 #define NEVER_INLINE __attribute__((noinline)) 46 #define ALIGN(x) __attribute__((aligned(x))) 48 #define PACKED __attribute__((packed)) 50 #define MAY_ALIAS __attribute__((may_alias)) 52 #define LIKELY(exp) __builtin_expect(!!(exp), 1) 54 #define UNLIKELY(exp) __builtin_expect(!!(exp), 0) 56 #define UNREACHABLE __builtin_unreachable() 58 #define FORMAT(type, idx, first) __attribute__((format(type, idx, first))) 60 #define IS_CONSTANT(x) __builtin_constant_p(x) 62 #ifdef __MACH__ // Mach targets have special section specifications. 65 #define SECTION(x) __attribute__((__section__(x))) 68 #define MUST_USE_RESULT __attribute__((warn_unused_result)) 70 #define USED __attribute__((used)) 72 #define WEAK __attribute__((weak)) 78 #define EXPORTED_PUBLIC __attribute__((visibility("default"))) 82 #define __has_builtin(x) 0 86 #define __has_feature(x) 0 89 #if __has_builtin(__builtin_assume_aligned) || !defined(__clang__) 90 #define ASSUME_ALIGNMENT(b, sz) __builtin_assume_aligned((b), sz) 92 #define ASSUME_ALIGNMENT(b, sz) \ 93 ((reinterpret_cast<uintptr_t>(b) % (sz)) == 0) ? (b) : (UNREACHABLE, (b)) 98 #define INITIALISATION_ONLY SECTION(".init.text") 99 #define INITIALISATION_ONLY_DATA SECTION(".init.data") 102 #if __has_feature(address_sanitizer) || __has_feature(memory_sanitizer) 103 #define HAS_ADDRESS_SANITIZER 1 105 #define HAS_ADDRESS_SANITIZER 0 108 #if __has_feature(thread_sanitizer) 109 #define HAS_THREAD_SANITIZER 1 111 #define HAS_THREAD_SANITIZER 0 114 #if HAS_ADDRESS_SANITIZER || HAS_THREAD_SANITIZER 115 #define HAS_SANITIZERS 1 119 #define NOT_COPY_CONSTRUCTIBLE(Type) Type(const Type &) = delete 120 #define NOT_ASSIGNABLE(Type) Type &operator=(const Type &) = delete 121 #define NOT_COPYABLE_OR_ASSIGNABLE(Type) \ 122 NOT_COPY_CONSTRUCTIBLE(Type); \ 125 #define WITHOUT_IMPLICIT_CONSTRUCTORS(Type) \ 127 NOT_COPYABLE_OR_ASSIGNABLE(Type) 131 #define BARRIER() __asm__ __volatile__("" ::: "memory") 134 #define FENCE() __sync_synchronize() 137 #include "pedigree/kernel/utilities/threadsafety.h"