Fixes for MSVC
This commit is contained in:
@@ -99,18 +99,9 @@
|
||||
///
|
||||
|
||||
|
||||
// Most major compilers support __has_builtin, notably GCC, MINGW, CLANG, and MSVC
|
||||
// Most major compilers support __has_builtin, notably GCC, MINGW, and CLANG
|
||||
#if defined(__has_builtin)
|
||||
|
||||
|
||||
// bitcast is slightly more efficient for build times than using memcpy
|
||||
#if __has_builtin(__builtin_bit_cast)
|
||||
# define FENNEC_HAS_BUILTIN_BIT_CAST 1
|
||||
# define FENNEC_BUILTIN_BIT_CAST(type, arg) __builtin_bit_cast(type, arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_BIT_CAST 0
|
||||
#endif
|
||||
|
||||
// addressof is very difficult to implement without intrinsics.
|
||||
#if __has_builtin(__builtin_addressof)
|
||||
# define FENNEC_HAS_BUILTIN_ADDRESSOF 1
|
||||
@@ -119,9 +110,31 @@
|
||||
# define FENNEC_HAS_BUILTIN_ADDRESSOF 0
|
||||
#endif
|
||||
|
||||
// bitcast is slightly more efficient for build times than using memcpy
|
||||
#if __has_builtin(__builtin_bit_cast)
|
||||
# define FENNEC_HAS_BUILTIN_BIT_CAST 1
|
||||
# define FENNEC_BUILTIN_BIT_CAST(type, arg) __builtin_bit_cast(type, arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_BIT_CAST 0
|
||||
#endif
|
||||
|
||||
// Inconsistent without intrinsics
|
||||
#if __has_builtin(__is_abstract)
|
||||
# define FENNEC_HAS_BUILTIN_IS_ABSTRACT 1
|
||||
# define FENNEC_BUILTIN_IS_ABSTRACT(arg) __is_abstract(arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_ABSTRACT 0
|
||||
#endif
|
||||
|
||||
// Difficult and Inconsistent without intrinsics
|
||||
#if __has_builtin(__is_constructible)
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONSTRUCTIBLE 1
|
||||
# define FENNEC_BUILTIN_IS_CONSTRUCTIBLE(type, ...) __is_constructible(type, __VA_ARGS__)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONSTRUCTIBLE 0
|
||||
#endif
|
||||
|
||||
// Type Traits
|
||||
|
||||
// can_convert is also very difficult to implement without intrinsics
|
||||
#if __has_builtin(__is_convertible)
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONVERTIBLE 1
|
||||
@@ -136,6 +149,14 @@
|
||||
# define FENNEC_BUILTIN_IS_EMPTY(arg) __is_empty(arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_EMPTY 0
|
||||
|
||||
// Inconsistent without intrinsics
|
||||
#if __has_builtin(__is_final)
|
||||
# define FENNEC_HAS_BUILTIN_IS_FINAL 1
|
||||
# define FENNEC_BUILTIN_IS_FINAL(arg) __is_final(arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_FINAL 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Inconsistent without intrinsics
|
||||
@@ -146,22 +167,6 @@
|
||||
# define FENNEC_HAS_BUILTIN_IS_POLYMORPHIC 0
|
||||
#endif
|
||||
|
||||
// Inconsistent without intrinsics
|
||||
#if __has_builtin(__is_final)
|
||||
# define FENNEC_HAS_BUILTIN_IS_FINAL 1
|
||||
# define FENNEC_BUILTIN_IS_FINAL(arg) __is_final(arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_FINAL 0
|
||||
#endif
|
||||
|
||||
// Inconsistent without intrinsics
|
||||
#if __has_builtin(__is_abstract)
|
||||
# define FENNEC_HAS_BUILTIN_IS_ABSTRACT 1
|
||||
# define FENNEC_BUILTIN_IS_ABSTRACT(arg) __is_abstract(arg)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_ABSTRACT 0
|
||||
#endif
|
||||
|
||||
// Impossible without instrinsics
|
||||
#if __has_builtin(__is_standard_layout)
|
||||
# define FENNEC_HAS_BUILTIN_IS_STANDARD_LAYOUT 1
|
||||
@@ -170,20 +175,40 @@
|
||||
# define FENNEC_HAS_BUILTIN_IS_STANDARD_LAYOUT 0
|
||||
#endif
|
||||
|
||||
// Difficult and Inconsistent without intrinsics
|
||||
#if __has_builtin(__is_constructible)
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONSTRUCTIBLE 1
|
||||
# define FENNEC_BUILTIN_IS_CONSTRUCTIBLE(type, ...) __is_constructible(type, __VA_ARGS__)
|
||||
#else
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONSTRUCTIBLE 0
|
||||
#endif
|
||||
|
||||
|
||||
// For compilers without or differently named builtins
|
||||
#else
|
||||
|
||||
// TODO: More compiler support
|
||||
|
||||
#if _MSC_VER
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_ADDRESS_OF 1
|
||||
# define FENNEC_BUILTIN_ADDRESS_OF(arg) __builtin_addressof(arg)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_BIT_CAST 1
|
||||
# define FENNEC_BUILTIN_BIT_CAST(type, arg) __builtin_bit_cast(type, arg)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONVERTIBLE 1
|
||||
# define FENNEC_BUILTIN_IS_CONVERTIBLE(arg0, arg1) __is_convertible_to(arg0, arg1)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_IS_CONSTRUCTIBLE 1
|
||||
# define FENNEC_BUILTIN_IS_CONSTRUCTIBLE(...) __is_constructible(__VA_ARGS__)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_IS_EMPTY 1
|
||||
# define FENNEC_BUILTIN_IS_EMPTY(arg) __is_empty(arg)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_IS_FINAL 1
|
||||
# define FENNEC_BUILTIN_IS_FINAL(arg) __is_final(arg)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_IS_POLYMORPHIC 1
|
||||
# define FENNEC_BUILTIN_IS_POLYMORPHIC(arg) __is_polymorphic(arg)
|
||||
|
||||
# define FENNEC_HAS_BUILTIN_IS_STANDARD_LAYOUT 1
|
||||
# define FENNEC_BUILTIN_IS_STANDARD_LAYOUT(arg) __is_standard_layout(arg)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif // FENNEC_LANG_INTRINSICS_H
|
||||
|
||||
Reference in New Issue
Block a user