Skip to content
Snippets Groups Projects
Commit 160b4d95 authored by Christian Engwer's avatar Christian Engwer
Browse files

[debugallocator]

use mprotect only if the m4-test succeeded

[[Imported from SVN: r7016]]
parent b5256028
No related branches found
No related tags found
No related merge requests found
...@@ -5,13 +5,15 @@ ...@@ -5,13 +5,15 @@
#include <exception> #include <exception>
#include <typeinfo> #include <typeinfo>
#include <sys/mman.h>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#include <malloc.h> #include <malloc.h>
#include <new> #include <new>
#if HAVE_SYS_MMAN_H and HAVE_MPROTECT
#include <sys/mman.h>
#endif
#include "mallocallocator.hh" #include "mallocallocator.hh"
...@@ -58,6 +60,7 @@ namespace Dune ...@@ -58,6 +60,7 @@ namespace Dune
private: private:
void memprotect(void* from, difference_type len, int prot) void memprotect(void* from, difference_type len, int prot)
{ {
#if HAVE_SYS_MMAN_H and HAVE_MPROTECT
int result = mprotect(from, len, prot); int result = mprotect(from, len, prot);
if (result == -1) if (result == -1)
{ {
...@@ -75,6 +78,9 @@ namespace Dune ...@@ -75,6 +78,9 @@ namespace Dune
<< std::endl; << std::endl;
abort(); abort();
} }
#else
std::cerr << "WARNING: memory protection not available" << std::endl;
#endif
} }
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment