mirror of
https://github.com/g-truc/glm.git
synced 2024-11-10 12:41:54 +00:00
Alignof is a C++11 feature
This commit is contained in:
parent
d8e30c5fde
commit
8c960dc647
@ -424,6 +424,19 @@
|
|||||||
((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA50))))
|
((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA50))))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// N2341 http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
|
||||||
|
#if GLM_COMPILER & GLM_COMPILER_CLANG
|
||||||
|
# define GLM_HAS_ALIGNOF __has_feature(c_alignof)
|
||||||
|
#elif GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||||
|
# define GLM_HAS_ALIGNOF 1
|
||||||
|
#else
|
||||||
|
# define GLM_HAS_ALIGNOF ((GLM_LANG & GLM_LANG_CXX0X_FLAG) && (\
|
||||||
|
((GLM_COMPILER & GLM_COMPILER_GCC) && (GLM_COMPILER >= GLM_COMPILER_GCC48)) || \
|
||||||
|
((GLM_COMPILER & GLM_COMPILER_INTEL) && (GLM_COMPILER >= GLM_COMPILER_INTEL15)) || \
|
||||||
|
((GLM_COMPILER & GLM_COMPILER_VC) && (GLM_COMPILER >= GLM_COMPILER_VC2015)) || \
|
||||||
|
((GLM_COMPILER & GLM_COMPILER_CUDA) && (GLM_COMPILER >= GLM_COMPILER_CUDA70))))
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
#if GLM_LANG & GLM_LANG_CXX11_FLAG
|
#if GLM_LANG & GLM_LANG_CXX11_FLAG
|
||||||
# define GLM_HAS_ASSIGNABLE 1
|
# define GLM_HAS_ASSIGNABLE 1
|
||||||
|
@ -6,39 +6,38 @@ int test_aligned()
|
|||||||
|
|
||||||
size_t size1_aligned = sizeof(glm::detail::storage<int, 1, true>::type);
|
size_t size1_aligned = sizeof(glm::detail::storage<int, 1, true>::type);
|
||||||
Error += size1_aligned == 1 ? 0 : 1;
|
Error += size1_aligned == 1 ? 0 : 1;
|
||||||
size_t align1_aligned = alignof(glm::detail::storage<int, 1, true>::type);
|
|
||||||
Error += align1_aligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size2_aligned = sizeof(glm::detail::storage<int, 2, true>::type);
|
size_t size2_aligned = sizeof(glm::detail::storage<int, 2, true>::type);
|
||||||
Error += size2_aligned == 2 ? 0 : 1;
|
Error += size2_aligned == 2 ? 0 : 1;
|
||||||
size_t align2_aligned = alignof(glm::detail::storage<int, 2, true>::type);
|
|
||||||
Error += align2_aligned == 2 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size4_aligned = sizeof(glm::detail::storage<int, 4, true>::type);
|
size_t size4_aligned = sizeof(glm::detail::storage<int, 4, true>::type);
|
||||||
Error += size4_aligned == 4 ? 0 : 1;
|
Error += size4_aligned == 4 ? 0 : 1;
|
||||||
size_t align4_aligned = alignof(glm::detail::storage<int, 4, true>::type);
|
|
||||||
Error += align4_aligned == 4 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size8_aligned = sizeof(glm::detail::storage<int, 8, true>::type);
|
size_t size8_aligned = sizeof(glm::detail::storage<int, 8, true>::type);
|
||||||
Error += size8_aligned == 8 ? 0 : 1;
|
Error += size8_aligned == 8 ? 0 : 1;
|
||||||
size_t align8_aligned = alignof(glm::detail::storage<int, 8, true>::type);
|
|
||||||
Error += align8_aligned == 8 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size16_aligned = sizeof(glm::detail::storage<int, 16, true>::type);
|
size_t size16_aligned = sizeof(glm::detail::storage<int, 16, true>::type);
|
||||||
Error += size16_aligned == 16 ? 0 : 1;
|
Error += size16_aligned == 16 ? 0 : 1;
|
||||||
size_t align16_aligned = alignof(glm::detail::storage<int, 16, true>::type);
|
|
||||||
Error += align16_aligned == 16 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size32_aligned = sizeof(glm::detail::storage<int, 32, true>::type);
|
size_t size32_aligned = sizeof(glm::detail::storage<int, 32, true>::type);
|
||||||
Error += size32_aligned == 32 ? 0 : 1;
|
Error += size32_aligned == 32 ? 0 : 1;
|
||||||
size_t align32_aligned = alignof(glm::detail::storage<int, 32, true>::type);
|
|
||||||
Error += align32_aligned == 32 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size64_aligned = sizeof(glm::detail::storage<int, 64, true>::type);
|
size_t size64_aligned = sizeof(glm::detail::storage<int, 64, true>::type);
|
||||||
Error += size64_aligned == 64 ? 0 : 1;
|
Error += size64_aligned == 64 ? 0 : 1;
|
||||||
|
|
||||||
|
# if GLM_HAS_ALIGNOF
|
||||||
|
|
||||||
|
size_t align1_aligned = alignof(glm::detail::storage<int, 1, true>::type);
|
||||||
|
Error += align1_aligned == 1 ? 0 : 1;
|
||||||
|
size_t align2_aligned = alignof(glm::detail::storage<int, 2, true>::type);
|
||||||
|
Error += align2_aligned == 2 ? 0 : 1;
|
||||||
|
size_t align4_aligned = alignof(glm::detail::storage<int, 4, true>::type);
|
||||||
|
Error += align4_aligned == 4 ? 0 : 1;
|
||||||
|
size_t align8_aligned = alignof(glm::detail::storage<int, 8, true>::type);
|
||||||
|
Error += align8_aligned == 8 ? 0 : 1;
|
||||||
|
size_t align16_aligned = alignof(glm::detail::storage<int, 16, true>::type);
|
||||||
|
Error += align16_aligned == 16 ? 0 : 1;
|
||||||
|
size_t align32_aligned = alignof(glm::detail::storage<int, 32, true>::type);
|
||||||
|
Error += align32_aligned == 32 ? 0 : 1;
|
||||||
size_t align64_aligned = alignof(glm::detail::storage<int, 64, true>::type);
|
size_t align64_aligned = alignof(glm::detail::storage<int, 64, true>::type);
|
||||||
Error += align64_aligned == 64 ? 0 : 1;
|
Error += align64_aligned == 64 ? 0 : 1;
|
||||||
|
|
||||||
|
# endif //GLM_HAS_ALIGNOF
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,39 +47,38 @@ int test_unaligned()
|
|||||||
|
|
||||||
size_t size1_unaligned = sizeof(glm::detail::storage<int, 1, false>::type);
|
size_t size1_unaligned = sizeof(glm::detail::storage<int, 1, false>::type);
|
||||||
Error += size1_unaligned == 1 ? 0 : 1;
|
Error += size1_unaligned == 1 ? 0 : 1;
|
||||||
size_t align1_unaligned = alignof(glm::detail::storage<int, 1, false>::type);
|
|
||||||
Error += align1_unaligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size2_unaligned = sizeof(glm::detail::storage<int, 2, false>::type);
|
size_t size2_unaligned = sizeof(glm::detail::storage<int, 2, false>::type);
|
||||||
Error += size2_unaligned == 2 ? 0 : 1;
|
Error += size2_unaligned == 2 ? 0 : 1;
|
||||||
size_t align2_unaligned = alignof(glm::detail::storage<int, 2, false>::type);
|
|
||||||
Error += align2_unaligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size4_unaligned = sizeof(glm::detail::storage<int, 4, false>::type);
|
size_t size4_unaligned = sizeof(glm::detail::storage<int, 4, false>::type);
|
||||||
Error += size4_unaligned == 4 ? 0 : 1;
|
Error += size4_unaligned == 4 ? 0 : 1;
|
||||||
size_t align4_unaligned = alignof(glm::detail::storage<int, 4, false>::type);
|
|
||||||
Error += align4_unaligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size8_unaligned = sizeof(glm::detail::storage<int, 8, false>::type);
|
size_t size8_unaligned = sizeof(glm::detail::storage<int, 8, false>::type);
|
||||||
Error += size8_unaligned == 8 ? 0 : 1;
|
Error += size8_unaligned == 8 ? 0 : 1;
|
||||||
size_t align8_unaligned = alignof(glm::detail::storage<int, 8, false>::type);
|
|
||||||
Error += align8_unaligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size16_unaligned = sizeof(glm::detail::storage<int, 16, false>::type);
|
size_t size16_unaligned = sizeof(glm::detail::storage<int, 16, false>::type);
|
||||||
Error += size16_unaligned == 16 ? 0 : 1;
|
Error += size16_unaligned == 16 ? 0 : 1;
|
||||||
size_t align16_unaligned = alignof(glm::detail::storage<int, 16, false>::type);
|
|
||||||
Error += align16_unaligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size32_unaligned = sizeof(glm::detail::storage<int, 32, false>::type);
|
size_t size32_unaligned = sizeof(glm::detail::storage<int, 32, false>::type);
|
||||||
Error += size32_unaligned == 32 ? 0 : 1;
|
Error += size32_unaligned == 32 ? 0 : 1;
|
||||||
size_t align32_unaligned = alignof(glm::detail::storage<int, 32, false>::type);
|
|
||||||
Error += align32_unaligned == 1 ? 0 : 1;
|
|
||||||
|
|
||||||
size_t size64_unaligned = sizeof(glm::detail::storage<int, 64, false>::type);
|
size_t size64_unaligned = sizeof(glm::detail::storage<int, 64, false>::type);
|
||||||
Error += size64_unaligned == 64 ? 0 : 1;
|
Error += size64_unaligned == 64 ? 0 : 1;
|
||||||
|
|
||||||
|
# if GLM_HAS_ALIGNOF
|
||||||
|
|
||||||
|
size_t align1_unaligned = alignof(glm::detail::storage<int, 1, false>::type);
|
||||||
|
Error += align1_unaligned == 1 ? 0 : 1;
|
||||||
|
size_t align2_unaligned = alignof(glm::detail::storage<int, 2, false>::type);
|
||||||
|
Error += align2_unaligned == 1 ? 0 : 1;
|
||||||
|
size_t align4_unaligned = alignof(glm::detail::storage<int, 4, false>::type);
|
||||||
|
Error += align4_unaligned == 1 ? 0 : 1;
|
||||||
|
size_t align8_unaligned = alignof(glm::detail::storage<int, 8, false>::type);
|
||||||
|
Error += align8_unaligned == 1 ? 0 : 1;
|
||||||
|
size_t align16_unaligned = alignof(glm::detail::storage<int, 16, false>::type);
|
||||||
|
Error += align16_unaligned == 1 ? 0 : 1;
|
||||||
|
size_t align32_unaligned = alignof(glm::detail::storage<int, 32, false>::type);
|
||||||
|
Error += align32_unaligned == 1 ? 0 : 1;
|
||||||
size_t align64_unaligned = alignof(glm::detail::storage<int, 64, false>::type);
|
size_t align64_unaligned = alignof(glm::detail::storage<int, 64, false>::type);
|
||||||
Error += align64_unaligned == 1 ? 0 : 1;
|
Error += align64_unaligned == 1 ? 0 : 1;
|
||||||
|
|
||||||
|
# endif //GLM_HAS_ALIGNOF
|
||||||
|
|
||||||
return Error;
|
return Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user