ATLAS Offline Software
Loading...
Searching...
No Matches
page_access.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6#include <unistd.h>
7#include <limits.h>
8namespace athena{
9 const size_t PAGESIZE = sysconf(_SC_PAGE_SIZE);
10
11 const void* page_address(const void* addr) {
12 return (const void*)((long)addr & ~(PAGESIZE-1));
13 }
14 void* page_address(void* addr) {
15 return (void*)((long)addr & ~(PAGESIZE-1));
16 }
17 void* next_page_address(void* addr) {
18 return (void*)(((long)addr & ~(PAGESIZE-1)) + PAGESIZE);
19 }
20
21 int page_protect(void* addr, int prot) {
22 int rc=mprotect(page_address(addr), PAGESIZE, prot);
23 if (rc) printf("page_protect WARNING: mprotect heap failed for void *address %p\n", addr);
24#ifdef DEBUG
25 else printf("page_protect DEBUG: set protection @%i for range @%zx - @%zx containing void* addr=%p\n",
26 prot,(size_t)page_address(addr),
27 (size_t)page_address(addr) + PAGESIZE, addr);
28#endif
29 return rc;
30 }
31}
static Double_t rc
const void * page_address(const void *addr)
const size_t PAGESIZE
void * next_page_address(void *addr)
int page_protect(void *addr, int prot)