Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 Google Inc. All rights reserved. |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef FRUIT_CONFIG_H |
| 18 | #define FRUIT_CONFIG_H |
| 19 | |
Marco Poletti | 0d5e069 | 2016-01-31 09:42:41 +0000 | [diff] [blame] | 20 | #include <fruit/impl/fruit-config-base.h> |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 21 | |
| 22 | #if FRUIT_HAS_STD_MAX_ALIGN_T |
| 23 | #define FRUIT_MAX_ALIGN_T std::max_align_t |
| 24 | #elif FRUIT_HAS_MAX_ALIGN_T |
| 25 | // In e.g. GCC 4.8.x, we need a non-standard max_align_t. |
| 26 | #define FRUIT_MAX_ALIGN_T ::max_align_t |
| 27 | #else |
Marco Poletti | 370e4ff | 2016-02-14 10:52:43 +0000 | [diff] [blame] | 28 | // We use the standard one, but most likely it won't work. |
| 29 | #define FRUIT_MAX_ALIGN_T std::max_align_t |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #if FRUIT_HAS_STD_IS_TRIVIALLY_COPYABLE |
Marco Poletti | 905dc09 | 2017-03-12 15:54:31 +0000 | [diff] [blame] | 33 | #if FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 34 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copyable<T>::value || (std::is_empty<T>::value && std::is_trivially_copy_constructible<T>::value)) |
| 35 | #else // !FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 36 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copyable<T>::value) |
| 37 | #endif // FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 38 | #elif FRUIT_HAS_IS_TRIVIALLY_COPYABLE |
Marco Poletti | 905dc09 | 2017-03-12 15:54:31 +0000 | [diff] [blame] | 39 | #if FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 40 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (__is_trivially_copyable(T) || (std::is_empty<T>::value && std::is_trivially_copy_constructible<T>::value)) |
| 41 | #else // !FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 42 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (__is_trivially_copyable(T)) |
Marco Poletti | 6412745 | 2017-03-12 16:58:34 +0000 | [diff] [blame] | 43 | #endif // FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 44 | #elif FRUIT_HAS_HAS_TRIVIAL_COPY |
| 45 | // The compiler doesn't support __is_trivially_copyable (nor is std::is_trivially_copyable |
| 46 | // supported by the library). We use this check as a proxy, but it's not exactly the same thing. |
Marco Poletti | 905dc09 | 2017-03-12 15:54:31 +0000 | [diff] [blame] | 47 | #if FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 48 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (__has_trivial_copy(T) || (std::is_empty<T>::value && std::is_trivially_copy_constructible<T>::value)) |
| 49 | #else // !FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 50 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (__has_trivial_copy(T)) |
Marco Poletti | 6412745 | 2017-03-12 16:58:34 +0000 | [diff] [blame] | 51 | #endif // FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 52 | #else |
Marco Poletti | 370e4ff | 2016-02-14 10:52:43 +0000 | [diff] [blame] | 53 | // We use the standard one, but most likely it won't work. |
Marco Poletti | 905dc09 | 2017-03-12 15:54:31 +0000 | [diff] [blame] | 54 | #if FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 55 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copyable<T>::value || (std::is_empty<T>::value && std::is_trivially_copy_constructible<T>::value)) |
| 56 | #else // !FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
| 57 | #define FRUIT_IS_TRIVIALLY_COPYABLE(T) (std::is_trivially_copyable<T>::value) |
| 58 | #endif // FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 59 | #endif |
| 60 | |
Marco Poletti | dfcdced | 2017-05-20 15:24:14 +0100 | [diff] [blame] | 61 | #if FRUIT_HAS_ALWAYS_INLINE_ATTRIBUTE |
| 62 | #define FRUIT_ALWAYS_INLINE __attribute__((always_inline)) |
| 63 | #elif FRUIT_HAS_FORCEINLINE |
| 64 | #define FRUIT_ALWAYS_INLINE __forceinline |
| 65 | #else |
| 66 | #define FRUIT_ALWAYS_INLINE |
| 67 | #endif |
| 68 | |
Marco Poletti | 3e21dcf | 2017-06-17 15:58:00 +0100 | [diff] [blame^] | 69 | #if FRUIT_HAS_GCC_ATTRIBUTE_DEPRECATED |
| 70 | #define FRUIT_DEPRECATED_DECLARATION(...) __VA_ARGS__ __attribute__((deprecated)) |
| 71 | // Marking the declaration is enough. |
| 72 | #define FRUIT_DEPRECATED_DEFINITION(...) __VA_ARGS__ |
Marco Poletti | c9e7a0b | 2017-06-11 20:04:03 +0100 | [diff] [blame] | 73 | #elif FRUIT_HAS_DECLSPEC_DEPRECATED |
Marco Poletti | 3e21dcf | 2017-06-17 15:58:00 +0100 | [diff] [blame^] | 74 | #define FRUIT_DEPRECATED_DECLARATION(...) __declspec(deprecated) __VA_ARGS__ |
| 75 | #define FRUIT_DEPRECATED_DEFINITION(...) __declspec(deprecated) __VA_ARGS__ |
| 76 | // We use this only if the above two are not supported, because some compilers "support" this syntax (i.e., it compiles) but they just ignore the attribute. |
| 77 | #elif FRUIT_HAS_ATTRIBUTE_DEPRECATED |
| 78 | #define FRUIT_DEPRECATED_DECLARATION(...) [[deprecated]] __VA_ARGS__ |
| 79 | #define FRUIT_DEPRECATED_DEFINITION(...) [[deprecated]] __VA_ARGS__ |
Marco Poletti | c9e7a0b | 2017-06-11 20:04:03 +0100 | [diff] [blame] | 80 | #else |
Marco Poletti | 3e21dcf | 2017-06-17 15:58:00 +0100 | [diff] [blame^] | 81 | #define FRUIT_DEPRECATED_DECLARATION(...) __VA_ARGS__ |
| 82 | #define FRUIT_DEPRECATED_DEFINITION(...) __VA_ARGS__ |
Marco Poletti | c9e7a0b | 2017-06-11 20:04:03 +0100 | [diff] [blame] | 83 | #endif |
| 84 | |
Marco Poletti | f289510 | 2016-01-30 13:38:37 +0000 | [diff] [blame] | 85 | #endif // FRUIT_CONFIG_H |