|
17 | 17 | #ifndef SWIFT_RUNTIME_CONFIG_H |
18 | 18 | #define SWIFT_RUNTIME_CONFIG_H |
19 | 19 |
|
| 20 | +#include "swift/Basic/Compiler.h" |
20 | 21 | #include "swift/Runtime/CMakeConfig.h" |
21 | 22 |
|
22 | | -/// \macro SWIFT_RUNTIME_GNUC_PREREQ |
23 | | -/// Extend the default __GNUC_PREREQ even if glibc's features.h isn't |
24 | | -/// available. |
25 | | -#ifndef SWIFT_RUNTIME_GNUC_PREREQ |
26 | | -# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) |
27 | | -# define SWIFT_RUNTIME_GNUC_PREREQ(maj, min, patch) \ |
28 | | - ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \ |
29 | | - ((maj) << 20) + ((min) << 10) + (patch)) |
30 | | -# elif defined(__GNUC__) && defined(__GNUC_MINOR__) |
31 | | -# define SWIFT_RUNTIME_GNUC_PREREQ(maj, min, patch) \ |
32 | | - ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10)) |
33 | | -# else |
34 | | -# define SWIFT_RUNTIME_GNUC_PREREQ(maj, min, patch) 0 |
35 | | -# endif |
36 | | -#endif |
37 | | - |
38 | 23 | /// SWIFT_RUNTIME_LIBRARY_VISIBILITY - If a class marked with this attribute is |
39 | 24 | /// linked into a shared library, then the class should be private to the |
40 | 25 | /// library and not accessible from outside it. Can also be used to mark |
41 | 26 | /// variables and functions, making them private to any shared library they are |
42 | 27 | /// linked into. |
43 | 28 | /// On PE/COFF targets, library visibility is the default, so this isn't needed. |
44 | | -#if (__has_attribute(visibility) || SWIFT_RUNTIME_GNUC_PREREQ(4, 0, 0)) && \ |
| 29 | +#if (__has_attribute(visibility) || SWIFT_GNUC_PREREQ(4, 0, 0)) && \ |
45 | 30 | !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(_WIN32) |
46 | 31 | #define SWIFT_RUNTIME_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) |
47 | 32 | #else |
48 | 33 | #define SWIFT_RUNTIME_LIBRARY_VISIBILITY |
49 | 34 | #endif |
50 | 35 |
|
51 | | -/// Attributes. |
52 | | -/// SWIFT_RUNTIME_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, |
53 | | -/// mark a method "not for inlining". |
54 | | -#if __has_attribute(noinline) || SWIFT_RUNTIME_GNUC_PREREQ(3, 4, 0) |
55 | | -#define SWIFT_RUNTIME_ATTRIBUTE_NOINLINE __attribute__((noinline)) |
56 | | -#elif defined(_MSC_VER) |
57 | | -#define SWIFT_RUNTIME_ATTRIBUTE_NOINLINE __declspec(noinline) |
58 | | -#else |
59 | | -#define SWIFT_RUNTIME_ATTRIBUTE_NOINLINE |
60 | | -#endif |
61 | | - |
62 | | -/// SWIFT_RUNTIME_ATTRIBUTE_ALWAYS_INLINE - On compilers where we have a directive to do |
63 | | -/// so, mark a method "always inline" because it is performance sensitive. GCC |
64 | | -/// 3.4 supported this but is buggy in various cases and produces unimplemented |
65 | | -/// errors, just use it in GCC 4.0 and later. |
66 | | -#if __has_attribute(always_inline) || SWIFT_RUNTIME_GNUC_PREREQ(4, 0, 0) |
67 | | -#define SWIFT_RUNTIME_ATTRIBUTE_ALWAYS_INLINE __attribute__((always_inline)) |
68 | | -#elif defined(_MSC_VER) |
69 | | -#define SWIFT_RUNTIME_ATTRIBUTE_ALWAYS_INLINE __forceinline |
70 | | -#else |
71 | | -#define SWIFT_RUNTIME_ATTRIBUTE_ALWAYS_INLINE |
72 | | -#endif |
73 | | - |
74 | | -#ifdef __GNUC__ |
75 | | -#define SWIFT_RUNTIME_ATTRIBUTE_NORETURN __attribute__((noreturn)) |
76 | | -#elif defined(_MSC_VER) |
77 | | -#define SWIFT_RUNTIME_ATTRIBUTE_NORETURN __declspec(noreturn) |
78 | | -#else |
79 | | -#define SWIFT_RUNTIME_ATTRIBUTE_NORETURN |
80 | | -#endif |
| 36 | +#define SWIFT_RUNTIME_ATTRIBUTE_NOINLINE SWIFT_ATTRIBUTE_NOINLINE |
| 37 | +#define SWIFT_RUNTIME_ATTRIBUTE_ALWAYS_INLINE SWIFT_ATTRIBUTE_ALWAYS_INLINE |
| 38 | +#define SWIFT_RUNTIME_ATTRIBUTE_NORETURN SWIFT_ATTRIBUTE_NORETURN |
81 | 39 |
|
82 | 40 | /// SWIFT_RUNTIME_BUILTIN_TRAP - On compilers which support it, expands to an expression |
83 | 41 | /// which causes the program to exit abnormally. |
84 | | -#if __has_builtin(__builtin_trap) || SWIFT_RUNTIME_GNUC_PREREQ(4, 3, 0) |
| 42 | +#if __has_builtin(__builtin_trap) || SWIFT_GNUC_PREREQ(4, 3, 0) |
85 | 43 | # define SWIFT_RUNTIME_BUILTIN_TRAP __builtin_trap() |
86 | 44 | #elif defined(_MSC_VER) |
87 | 45 | // The __debugbreak intrinsic is supported by MSVC, does not require forward |
|
0 commit comments