blob: 3ff8a2fdf0c56db81156e5bd3167f383eac5b517 [file] [log] [blame]
Marco Polettif2895102016-01-30 13:38:37 +00001/*
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 Poletti0d5e0692016-01-31 09:42:41 +000020#include <fruit/impl/fruit-config-base.h>
Marco Polettif2895102016-01-30 13:38:37 +000021
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 Poletti370e4ff2016-02-14 10:52:43 +000028// We use the standard one, but most likely it won't work.
29#define FRUIT_MAX_ALIGN_T std::max_align_t
Marco Polettif2895102016-01-30 13:38:37 +000030#endif
31
32#if FRUIT_HAS_STD_IS_TRIVIALLY_COPYABLE
Marco Poletti905dc092017-03-12 15:54:31 +000033#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 Polettif2895102016-01-30 13:38:37 +000038#elif FRUIT_HAS_IS_TRIVIALLY_COPYABLE
Marco Poletti905dc092017-03-12 15:54:31 +000039#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 Poletti64127452017-03-12 16:58:34 +000043#endif // FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE
Marco Polettif2895102016-01-30 13:38:37 +000044#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 Poletti905dc092017-03-12 15:54:31 +000047#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 Poletti64127452017-03-12 16:58:34 +000051#endif // FRUIT_HAS_STD_IS_TRIVIALLY_COPY_CONSTRUCTIBLE
Marco Polettif2895102016-01-30 13:38:37 +000052#else
Marco Poletti370e4ff2016-02-14 10:52:43 +000053// We use the standard one, but most likely it won't work.
Marco Poletti905dc092017-03-12 15:54:31 +000054#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 Polettif2895102016-01-30 13:38:37 +000059#endif
60
Marco Polettidfcdced2017-05-20 15:24:14 +010061#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 Poletti3e21dcf2017-06-17 15:58:00 +010069#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 Polettic9e7a0b2017-06-11 20:04:03 +010073#elif FRUIT_HAS_DECLSPEC_DEPRECATED
Marco Poletti3e21dcf2017-06-17 15:58:00 +010074#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 Polettic9e7a0b2017-06-11 20:04:03 +010080#else
Marco Poletti3e21dcf2017-06-17 15:58:00 +010081#define FRUIT_DEPRECATED_DECLARATION(...) __VA_ARGS__
82#define FRUIT_DEPRECATED_DEFINITION(...) __VA_ARGS__
Marco Polettic9e7a0b2017-06-11 20:04:03 +010083#endif
84
Marco Polettif2895102016-01-30 13:38:37 +000085#endif // FRUIT_CONFIG_H