From 41ae5cbc581cc91379223252ecf8248c703ea0ab Mon Sep 17 00:00:00 2001 From: Martin Kronbichler Date: Thu, 1 Feb 2018 11:23:01 +0100 Subject: [PATCH] Add macro for __restrict keyword. --- cmake/checks/check_01_compiler_features.cmake | 18 ++++++++++++++++++ include/deal.II/base/config.h.in | 1 + 2 files changed, 19 insertions(+) diff --git a/cmake/checks/check_01_compiler_features.cmake b/cmake/checks/check_01_compiler_features.cmake index d22d786fec..479d274b3b 100644 --- a/cmake/checks/check_01_compiler_features.cmake +++ b/cmake/checks/check_01_compiler_features.cmake @@ -33,6 +33,7 @@ # DEAL_II_COMPILER_HAS_ATTRIBUTE_ALWAYS_INLINE # DEAL_II_DEPRECATED # DEAL_II_ALWAYS_INLINE +# DEAL_II_RESTRICT # DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA # DEAL_II_COMPILER_HAS_FUSE_LD_GOLD # @@ -363,6 +364,23 @@ ELSE() SET(DEAL_II_ALWAYS_INLINE " ") ENDIF() +# +# Check whether the compiler understands the __restrict keyword. +# +CHECK_CXX_SOURCE_COMPILES( + " + void fn (double *__restrict a, double *__restrict b) { a[0] = b[0]; a[1] = b[0]; } + int main() { } + " + DEAL_II_COMPILER_HAS_RESTRICT_KEYWORD + ) + +IF(DEAL_II_COMPILER_HAS_RESTRICT_KEYWORD) + SET(DEAL_II_RESTRICT "__restrict") +ELSE() + SET(DEAL_II_RESTRICT " ") +ENDIF() + # # GCC and Clang allow fine grained control of diagnostics via the "GCC diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 89edbc5ae3..151371bdc4 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -93,6 +93,7 @@ #cmakedefine __PRETTY_FUNCTION__ @__PRETTY_FUNCTION__@ #cmakedefine DEAL_II_DEPRECATED @DEAL_II_DEPRECATED@ #cmakedefine DEAL_II_ALWAYS_INLINE @DEAL_II_ALWAYS_INLINE@ +#cmakedefine DEAL_II_RESTRICT @DEAL_II_RESTRICT@ #cmakedefine DEAL_II_COMPILER_HAS_DIAGNOSTIC_PRAGMA -- 2.39.5