summaryrefslogtreecommitdiffhomepage
path: root/compat/defs.hpp
blob: 6f3c9ab2f019c3582abc285bde7ce2ef562f4516 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once

#ifdef _MSC_VER
#   define fm_FUNCTION_NAME __FUNCSIG__
#else
#   define fm_FUNCTION_NAME __PRETTY_FUNCTION__
#endif

#define fm_DECLARE_DEPRECATED_COPY_ASSIGNMENT(type)                                 \
    [[deprecated, maybe_unused]] type(const type&) noexcept = default;              \
    [[deprecated, maybe_unused]] type& operator=(const type&) noexcept = default

#define fm_DECLARE_DEFAULT_COPY_ASSIGNMENT(type)                                    \
    [[maybe_unused]] constexpr type(const type&) noexcept = default;                \
    [[maybe_unused]] constexpr type& operator=(const type&) noexcept = default

#define fm_DECLARE_DEFAULT_COPY_ASSIGNMENT_(type)                                   \
    [[maybe_unused]] type(const type&) noexcept = default;                          \
    [[maybe_unused]] type& operator=(const type&) noexcept = default

#define fm_DECLARE_DELETED_COPY_ASSIGNMENT(type)                                    \
    type(const type&) = delete;                                                     \
    type& operator=(const type&) = delete

#define fm_DECLARE_DELETED_MOVE_ASSIGNMENT(type)                                    \
    type(type&&) = delete;                                                          \
    type& operator=(type&&) = delete

#define fm_DECLARE_DEPRECATED_MOVE_ASSIGNMENT(type)                                 \
    [[deprecated, maybe_unused]] type(type&&) = default;                            \
    [[deprecated, maybe_unused]] type& operator=(type&&) = default

#define fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT(type)                                    \
    [[maybe_unused]] constexpr type(type&&) noexcept = default;                     \
    [[maybe_unused]] constexpr type& operator=(type&&) noexcept = default

#define fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(type)                                   \
    [[maybe_unused]] type(type&&) noexcept = default;                               \
    [[maybe_unused]] type& operator=(type&&) noexcept = default

#define fm_DECLARE_DEFAULT_MOVE_COPY_ASSIGNMENTS(type)                              \
    [[maybe_unused]] fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT(type);                      \
    [[maybe_unused]] fm_DECLARE_DEFAULT_COPY_ASSIGNMENT(type)

#define fm_DECLARE_DEFAULT_MOVE_COPY_ASSIGNMENTS_(type)                             \
    [[maybe_unused]] fm_DECLARE_DEFAULT_MOVE_ASSIGNMENT_(type);                     \
    [[maybe_unused]] fm_DECLARE_DEFAULT_COPY_ASSIGNMENT_(type)

#ifdef _MSC_VER
#   define fm_noinline __declspec(noinline)
#else
#   define fm_noinline __attribute__((noinline))
#endif

#ifdef _MSC_VER
// standard version not supported in MSVC v14x ABI
// see https://devblogs.microsoft.com/cppblog/msvc-cpp20-and-the-std-cpp20-switch/
#define fm_no_unique_address msvc::no_unique_address
#else
#define fm_no_unique_address no_unique_address
#endif

#ifdef _MSC_VER
#define fm_UNROLL _Pragma("loop(ivdep)")
#define fm_UNROLL_4 fm_UNROLL
#define fm_UNROLL_8 fm_UNROLL
#define fm_UNROLL_2 fm_UNROLL
#else
#ifndef __SIZEOF_POINTER__
#error "missing __SIZEOF_POINTER__"
#endif
#define fm_UNROLL_2 _Pragma("GCC unroll 2")
#define fm_UNROLL_4 _Pragma("GCC unroll 4")
#define fm_UNROLL_8 _Pragma("GCC unroll 8")
#if __SIZEOF_POINTER__ > 4
#define fm_UNROLL _Pragma("GCC unroll 8")
#else
#define fm_UNROLL _Pragma("GCC unroll 4")
#endif
#endif

#ifdef __SANITIZE_ADDRESS__
#define fm_ASAN 1
#elif defined __has_feature
#if __has_feature(address_sanitizer)
#define fm_ASAN 1
#endif
#endif
#ifndef fm_ASAN
#define fm_ASAN 0
#endif

#define fm_FILENAME_MAX 260