Commit afd13745 authored by Simon Praetorius's avatar Simon Praetorius Committed by Christoph Grüninger
Browse files

Remove HAVE_MPROTECT cmake check

parent ff9237b5
Pipeline #34900 passed with stage
in 8 minutes and 39 seconds
# Master (will become release 2.8)
- Remove the cmake check for `HAVE_MPROTECT` and also do not define this variable in the
`config.h` file. It is defined only inside the header `debugallocator.hh`.
- Deprecate fallback implementations `Dune::Std::apply`, `Dune::Std::bool_constant`, and
`Dune::Std::make_array` in favor of std c++ implementations.
......
......@@ -41,7 +41,6 @@ install(FILES
FindInkscape.cmake
FindLatexMk.cmake
FindMETIS.cmake
FindMProtect.cmake
FindParMETIS.cmake
FindPTScotch.cmake
FindQuadMath.cmake
......
......@@ -16,7 +16,6 @@ include(AddQuadMathFlags)
# find program for image manipulation
find_package(Inkscape)
include(UseInkscape)
include(FindMProtect)
# find the threading library
find_package(Threads)
......
# .. cmake_module::
#
# Module that detects mprotect support
#
# Sets the following variables:
#
# * :code:`HAVE_SYS_MMAN_H`
# * :code:`HAVE_MPROTECT`
#
include(CheckIncludeFile)
check_include_file("sys/mman.h" HAVE_SYS_MMAN_H)
include(CheckCSourceCompiles)
check_c_source_compiles("
#include <sys/mman.h>
int main(void){
mprotect(0,0,PROT_NONE);
}" HAVE_MPROTECT)
......@@ -59,12 +59,6 @@
to facilitate activating and deactivating Vc using compile flags. */
#cmakedefine HAVE_VC ENABLE_VC
/* Define to 1 if you have the symbol mprotect. */
#cmakedefine HAVE_MPROTECT 1
/* Define to 1 if you have <sys/mman.h>. */
#cmakedefine HAVE_SYS_MMAN_H 1
/* Define to 1 if you have the Threading Building Blocks (TBB) library */
#cmakedefine HAVE_TBB 1
......
......@@ -5,13 +5,9 @@ add_subdirectory("test")
#build the library dunecommon
if(HAVE_MPROTECT)
set(debugallocator_src "debugallocator.cc")
endif(HAVE_MPROTECT)
dune_add_library("dunecommon"
debugalign.cc
${debugallocator_src}
debugallocator.cc
exceptions.cc
fmatrixev.cc
ios_state.cc
......
......@@ -6,6 +6,8 @@
#include "debugallocator.hh"
#if HAVE_MPROTECT
#include <iostream>
#include <unistd.h>
#include <cstdlib>
......@@ -29,3 +31,5 @@ namespace Dune
} // end namespace DebugMemory
} // end namespace Dune
#endif // HAVE_MPROTECT
......@@ -3,6 +3,12 @@
#ifndef DUNE_DEBUG_ALLOCATOR_HH
#define DUNE_DEBUG_ALLOCATOR_HH
#if __has_include(<sys/mman.h>)
#include <sys/mman.h>
#define HAVE_SYS_MMAN_H 1
#define HAVE_MPROTECT 1
#include <dune/common/unused.hh>
#include <exception>
#include <typeinfo>
......@@ -12,18 +18,9 @@
#include <cstdint>
#include <cstdlib>
#include <new>
#if HAVE_SYS_MMAN_H && HAVE_MPROTECT
#include <sys/mman.h>
#else
enum DummyProtFlags { PROT_NONE, PROT_WRITE, PROT_READ };
#endif
#include "mallocallocator.hh"
#if not HAVE_MPROTECT
#error mprotect is required to use the DebugAllocator
#else
namespace Dune
{
......@@ -352,6 +349,6 @@ void operator delete(void * p, size_t size) noexcept
#endif // DEBUG_NEW_DELETE
#endif // HAVE_PROTECT
#endif // __has_include(<sys/mman.h>)
#endif // DUNE_DEBUG_ALLOCATOR_HH
......@@ -341,7 +341,6 @@ dune_add_test(SOURCES stringutilitytest.cc
dune_add_test(SOURCES testdebugallocator.cc
LINK_LIBRARIES dunecommon
CMAKE_GUARD HAVE_MPROTECT
LABELS quick)
dune_add_test(NAME testdebugallocator_fail1
......@@ -349,7 +348,6 @@ dune_add_test(NAME testdebugallocator_fail1
LINK_LIBRARIES dunecommon
COMPILE_DEFINITIONS "FAILURE1;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS"
EXPECT_FAIL
CMAKE_GUARD HAVE_MPROTECT
LABELS quick)
dune_add_test(NAME testdebugallocator_fail2
......@@ -357,7 +355,6 @@ dune_add_test(NAME testdebugallocator_fail2
LINK_LIBRARIES dunecommon
COMPILE_DEFINITIONS "FAILURE2;EXPECTED_SIGNAL=SIGABRT"
EXPECT_FAIL
CMAKE_GUARD HAVE_MPROTECT
LABELS quick)
dune_add_test(NAME testdebugallocator_fail3
......@@ -365,7 +362,6 @@ dune_add_test(NAME testdebugallocator_fail3
LINK_LIBRARIES dunecommon
COMPILE_DEFINITIONS "FAILURE3;EXPECTED_SIGNAL=SIGABRT"
EXPECT_FAIL
CMAKE_GUARD HAVE_MPROTECT
LABELS quick)
dune_add_test(NAME testdebugallocator_fail4
......@@ -373,7 +369,6 @@ dune_add_test(NAME testdebugallocator_fail4
LINK_LIBRARIES dunecommon
COMPILE_DEFINITIONS "FAILURE4;DEBUG_ALLOCATOR_KEEP=1;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS"
EXPECT_FAIL
CMAKE_GUARD HAVE_MPROTECT
LABELS quick)
dune_add_test(NAME testdebugallocator_fail5
......@@ -381,7 +376,6 @@ dune_add_test(NAME testdebugallocator_fail5
LINK_LIBRARIES dunecommon
COMPILE_DEFINITIONS "FAILURE5;EXPECTED_SIGNAL=SIGSEGV;EXPECTED_ALT_SIGNAL=SIGBUS"
EXPECT_FAIL
CMAKE_GUARD HAVE_MPROTECT
LABELS quick)
dune_add_test(SOURCES testfloatcmp.cc
......
......@@ -8,6 +8,7 @@
#define DEBUG_NEW_DELETE 3
#include <dune/common/debugallocator.hh>
#if HAVE_MPROTECT
#include <iostream>
#include <csignal>
......@@ -88,6 +89,8 @@ void new_delete_tests()
z4 = 0;
}
#endif // HAVE_MPROTECT
int main(int, char**)
{
#if EXPECTED_SIGNAL
......@@ -97,9 +100,12 @@ int main(int, char**)
std::signal(EXPECTED_ALT_SIGNAL, std::_Exit);
#endif
#if HAVE_MPROTECT
basic_tests();
allocator_tests();
new_delete_tests();
#endif
#ifdef EXPECTED_SIGNAL
return 1;
#else
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment