ATLAS Offline Software
Control
CxxUtils
CxxUtils
page_access.h
Go to the documentation of this file.
1
// dear emacs, this is -*- C++ -*-
2
3
/*
4
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
5
*/
6
7
#ifndef CXXUTILS_PAGEADDRESS_H
8
#define CXXUTILS_PAGEADDRESS_H 1
9
#include <cstdio>
10
#include <sys/mman.h>
/* mprotect */
11
#define DEBUG 1
12
namespace
athena
{
13
const
void
*
page_address
(
const
void
* addr);
14
void
*
page_address
(
void
* addr);
15
void
*
next_page_address
(
void
* addr);
16
int
page_protect
(
void
* addr,
int
prot);
19
template
<
typename
T>
20
size_t
page_protect
(T* addr,
int
prot) {
21
void
* pageAddr(
page_address
((
void
*)addr));
22
size_t
lProtected((
long
)addr-(
long
)pageAddr+
sizeof
(T));
23
int
rc=mprotect(pageAddr, lProtected, prot);
24
if
(rc) printf(
"page_protect WARNING: mprotect heap failed for address %p\n"
, (
void
*)addr);
25
#ifdef DEBUG
26
else
printf(
"page_protect DEBUG: set protection @%i for range @%lx - @%zx containing addr=%p\n"
,
27
prot,(
long
unsigned
int
)
page_address
(addr),(
long
unsigned
int
)addr+
sizeof
(T), (
void
*)addr);
28
#endif
29
return
(rc == 0 ? lProtected : 0);
30
}
31
}
32
#endif
athena::page_protect
int page_protect(void *addr, int prot)
Definition:
page_access.cxx:21
athena
Definition:
athena.py:1
athena::next_page_address
void * next_page_address(void *addr)
Definition:
page_access.cxx:17
athena::page_address
const void * page_address(const void *addr)
Definition:
page_access.cxx:11
Generated on Thu Nov 7 2024 21:23:14 for ATLAS Offline Software by
1.8.18