1#pragma once
2
3/*
4 * Compiler-specific attributes/macros go here. This is the default placeholder
5 * that should work for MSVC/GCC/clang.
6 */
7
8#ifdef UACPI_OVERRIDE_COMPILER
9#include "uacpi_compiler.h"
10#else
11
12#define UACPI_ALIGN(x) __declspec(align(x))
13
14#ifdef _MSC_VER
15 #include <intrin.h>
16
17 #define UACPI_ALWAYS_INLINE __forceinline
18
19 #define UACPI_PACKED(decl) \
20 __pragma(pack(push, 1)) \
21 decl; \
22 __pragma(pack(pop))
23#else
24 #define UACPI_ALWAYS_INLINE inline __attribute__((always_inline))
25 #define UACPI_PACKED(decl) decl __attribute__((packed));
26#endif
27
28#ifdef __GNUC__
29 #define uacpi_unlikely(expr) __builtin_expect(!!(expr), 0)
30 #define uacpi_likely(expr) __builtin_expect(!!(expr), 1)
31
32 #if __has_attribute(__fallthrough__)
33 #define UACPI_FALLTHROUGH __attribute__((__fallthrough__))
34 #endif
35
36 #define UACPI_MAYBE_UNUSED __attribute__ ((unused))
37
38 #define UACPI_NO_UNUSED_PARAMETER_WARNINGS_BEGIN \
39 _Pragma("GCC diagnostic push") \
40 _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"")
41
42 #define UACPI_NO_UNUSED_PARAMETER_WARNINGS_END \
43 _Pragma("GCC diagnostic pop")
44
45 #ifdef __clang__
46 #define UACPI_PRINTF_DECL(fmt_idx, args_idx) \
47 __attribute__((format(printf, fmt_idx, args_idx)))
48 #else
49 #define UACPI_PRINTF_DECL(fmt_idx, args_idx) \
50 __attribute__((format(gnu_printf, fmt_idx, args_idx)))
51 #endif
52#else
53 #define uacpi_unlikely(expr) expr
54 #define uacpi_likely(expr) expr
55
56 #define UACPI_MAYBE_UNUSED
57
58 #define UACPI_NO_UNUSED_PARAMETER_WARNINGS_BEGIN
59 #define UACPI_NO_UNUSED_PARAMETER_WARNINGS_END
60
61 #define UACPI_PRINTF_DECL(fmt_idx, args_idx)
62#endif
63
64#ifndef UACPI_FALLTHROUGH
65 #define UACPI_FALLTHROUGH do {} while (0)
66#endif
67
68#ifndef UACPI_POINTER_SIZE
69 #ifdef _WIN32
70 #ifdef _WIN64
71 #define UACPI_POINTER_SIZE 8
72 #else
73 #define UACPI_POINTER_SIZE 4
74 #endif
75 #elif defined(__GNUC__)
76 #define UACPI_POINTER_SIZE __SIZEOF_POINTER__
77 #else
78 #error Failed to detect pointer size
79 #endif
80#endif
81
82#endif
83