diff --git a/src/core/Sanitizer.h b/src/core/Sanitizer.h new file mode 100644 index 0000000000000000000000000000000000000000..8ccb5f7b868a053643d0518bac63c020a330a49c --- /dev/null +++ b/src/core/Sanitizer.h @@ -0,0 +1,37 @@ +//====================================================================================================================== +// +// This file is part of waLBerla. waLBerla is free software: you can +// redistribute it and/or modify it under the terms of the GNU General Public +// License as published by the Free Software Foundation, either version 3 of +// the License, or (at your option) any later version. +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// for more details. +// +// You should have received a copy of the GNU General Public License along +// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. +// +//! \file Sanitizer.h +//! \ingroup core +//! \author Dominik Thoennes <dominik.thoennes@fau.de> +// +//====================================================================================================================== + +#pragma once + +#if (( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( __clang_major__ >=4 ) ) \ + || (( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( __GNUC__ >= 5 ) ) +# define ATTRIBUTE_NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) +#else +# define ATTRIBUTE_NO_SANITIZE_ADDRESS +#endif + +#if ( ( defined WALBERLA_CXX_COMPILER_IS_GNU ) && ( __GNUC__ >= 5 ) ) +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize_undefined)) +#elif (( defined WALBERLA_CXX_COMPILER_IS_CLANG ) && ( __clang_major__ >= 4 ) ) +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED __attribute__((no_sanitize("undefined"))) +#else +# define ATTRIBUTE_NO_SANITIZE_UNDEFINED +#endif \ No newline at end of file diff --git a/src/core/mpi/RecvBuffer.h b/src/core/mpi/RecvBuffer.h index e1af9c26473236323d21c55a141ca866a3a13d52..cf8e327437fad21157cee9d7441e8c196fa1f23e 100644 --- a/src/core/mpi/RecvBuffer.h +++ b/src/core/mpi/RecvBuffer.h @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -30,6 +30,7 @@ #include "SendBuffer.h" #include "core/debug/Debug.h" +#include "core/Sanitizer.h" #include <boost/mpl/logical.hpp> #include <boost/type_traits/is_enum.hpp> @@ -388,6 +389,7 @@ inline bool GenericRecvBuffer<T>::isEmpty() const */ template< typename T > // Element type template< typename V > // Type of the built-in data value +ATTRIBUTE_NO_SANITIZE_UNDEFINED typename boost::enable_if< boost::mpl::or_< boost::is_arithmetic<V>, boost::is_enum<V> >, GenericRecvBuffer<T> & >::type GenericRecvBuffer<T>::get( V& value ) diff --git a/src/core/mpi/SendBuffer.h b/src/core/mpi/SendBuffer.h index 57d097a2113a5db73705f667f5e4fe9fe47495eb..448c94af1809115b79fa4fc91896879c2bba83c1 100644 --- a/src/core/mpi/SendBuffer.h +++ b/src/core/mpi/SendBuffer.h @@ -1,15 +1,15 @@ //====================================================================================================================== // -// This file is part of waLBerla. waLBerla is free software: you can +// This file is part of waLBerla. waLBerla is free software: you can // redistribute it and/or modify it under the terms of the GNU General Public -// License as published by the Free Software Foundation, either version 3 of +// License as published by the Free Software Foundation, either version 3 of // the License, or (at your option) any later version. -// -// waLBerla is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +// +// waLBerla is distributed in the hope that it will be useful, but WITHOUT +// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License // for more details. -// +// // You should have received a copy of the GNU General Public License along // with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>. // @@ -32,6 +32,7 @@ #include "growPolicies/OptimalGrowth.h" #include "core/debug/Debug.h" +#include "core/Sanitizer.h" #include <boost/mpl/logical.hpp> #include <boost/type_traits/is_enum.hpp> @@ -442,6 +443,7 @@ inline bool GenericSendBuffer<T,G>::isEmpty() const template< typename T // Element type , typename G > // Growth policy template< typename V > // Type of the built-in data value +ATTRIBUTE_NO_SANITIZE_UNDEFINED typename boost::enable_if< boost::mpl::or_< boost::is_arithmetic<V>, boost::is_enum<V> >, GenericSendBuffer<T,G>& >::type GenericSendBuffer<T,G>::put( V value )