Skip to content

Commit 924ef86

Browse files
committed
Move macros to macro header
1 parent 29f23cb commit 924ef86

File tree

3 files changed

+45
-44
lines changed

3 files changed

+45
-44
lines changed

include/xsimd/config/xsimd_macros.hpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,48 @@
2929
#define XSIMD_CONCAT_INNER(a, b) a##b
3030
#define XSIMD_CONCAT(a, b) XSIMD_CONCAT_INNER(a, b)
3131

32+
#if defined(__FAST_MATH__)
33+
#define XSIMD_NO_DENORMALS
34+
#define XSIMD_NO_INFINITIES
35+
#define XSIMD_NO_NANS
36+
#endif
37+
38+
#if defined(__has_cpp_attribute)
39+
// if this check passes, then the compiler supports feature test macros
40+
#if __has_cpp_attribute(nodiscard) >= 201603L
41+
// if this check passes, then the compiler supports [[nodiscard]] without a message
42+
#define XSIMD_NO_DISCARD [[nodiscard]]
43+
#endif
44+
#endif
45+
46+
#if !defined(XSIMD_NO_DISCARD) && __cplusplus >= 201703L
47+
// this means that the previous tests failed, but we are using C++17 or higher
48+
#define XSIMD_NO_DISCARD [[nodiscard]]
49+
#endif
50+
51+
#if !defined(XSIMD_NO_DISCARD) && (defined(__GNUC__) || defined(__clang__))
52+
// this means that the previous checks failed, but we are using GCC or Clang
53+
#define XSIMD_NO_DISCARD __attribute__((warn_unused_result))
54+
#endif
55+
56+
#if !defined(XSIMD_NO_DISCARD)
57+
// this means that all the previous checks failed, so we fallback to doing nothing
58+
#define XSIMD_NO_DISCARD
59+
#endif
60+
61+
#ifdef __cpp_if_constexpr
62+
// this means that the compiler supports the `if constexpr` construct
63+
#define XSIMD_IF_CONSTEXPR if constexpr
64+
#endif
65+
66+
#if !defined(XSIMD_IF_CONSTEXPR) && __cplusplus >= 201703L
67+
// this means that the previous test failed, but we are using C++17 or higher
68+
#define XSIMD_IF_CONSTEXPR if constexpr
69+
#endif
70+
71+
#if !defined(XSIMD_IF_CONSTEXPR)
72+
// this means that all the previous checks failed, so we fallback to a normal `if`
73+
#define XSIMD_IF_CONSTEXPR if
74+
#endif
75+
3276
#endif

include/xsimd/types/xsimd_batch.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <complex>
1717

1818
#include "../config/xsimd_arch.hpp"
19+
#include "../config/xsimd_macros.hpp"
1920
#include "../memory/xsimd_alignment.hpp"
2021
#include "./xsimd_utils.hpp"
2122

include/xsimd/xsimd.hpp

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,6 @@
1212
#ifndef XSIMD_HPP
1313
#define XSIMD_HPP
1414

15-
#if defined(__FAST_MATH__)
16-
#define XSIMD_NO_DENORMALS
17-
#define XSIMD_NO_INFINITIES
18-
#define XSIMD_NO_NANS
19-
#endif
20-
21-
#if defined(__has_cpp_attribute)
22-
// if this check passes, then the compiler supports feature test macros
23-
#if __has_cpp_attribute(nodiscard) >= 201603L
24-
// if this check passes, then the compiler supports [[nodiscard]] without a message
25-
#define XSIMD_NO_DISCARD [[nodiscard]]
26-
#endif
27-
#endif
28-
29-
#if !defined(XSIMD_NO_DISCARD) && __cplusplus >= 201703L
30-
// this means that the previous tests failed, but we are using C++17 or higher
31-
#define XSIMD_NO_DISCARD [[nodiscard]]
32-
#endif
33-
34-
#if !defined(XSIMD_NO_DISCARD) && (defined(__GNUC__) || defined(__clang__))
35-
// this means that the previous checks failed, but we are using GCC or Clang
36-
#define XSIMD_NO_DISCARD __attribute__((warn_unused_result))
37-
#endif
38-
39-
#if !defined(XSIMD_NO_DISCARD)
40-
// this means that all the previous checks failed, so we fallback to doing nothing
41-
#define XSIMD_NO_DISCARD
42-
#endif
43-
44-
#ifdef __cpp_if_constexpr
45-
// this means that the compiler supports the `if constexpr` construct
46-
#define XSIMD_IF_CONSTEXPR if constexpr
47-
#endif
48-
49-
#if !defined(XSIMD_IF_CONSTEXPR) && __cplusplus >= 201703L
50-
// this means that the previous test failed, but we are using C++17 or higher
51-
#define XSIMD_IF_CONSTEXPR if constexpr
52-
#endif
53-
54-
#if !defined(XSIMD_IF_CONSTEXPR)
55-
// this means that all the previous checks failed, so we fallback to a normal `if`
56-
#define XSIMD_IF_CONSTEXPR if
57-
#endif
58-
5915
#include "config/xsimd_config.hpp"
6016
#include "config/xsimd_macros.hpp"
6117

0 commit comments

Comments
 (0)