ARGOBOTS  dce6e727ffc4ca5b3ffc04cb9517c6689be51ec5
mprotect.c
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
2 /*
3  * See COPYRIGHT in top-level directory.
4  */
5 
6 #include "abti.h"
7 #include <sys/mman.h>
8 
9 ABTU_ret_err int ABTU_mprotect(void *addr, size_t size, ABT_bool protect)
10 {
11 #ifdef HAVE_MPROTECT
12  int ret;
13  if (protect) {
14  ret = mprotect(addr, size, PROT_READ);
15  } else {
16  ret = mprotect(addr, size, PROT_READ | PROT_WRITE);
17  }
18  return ret == 0 ? ABT_SUCCESS : ABT_ERR_SYS;
19 #else
20  return ABT_ERR_SYS;
21 #endif
22 }
ABT_ERR_SYS
#define ABT_ERR_SYS
Error code: error related to system calls and standard libraries.
Definition: abt.h:403
ABT_bool
int ABT_bool
Boolean type.
Definition: abt.h:1043
abti.h
ABT_SUCCESS
#define ABT_SUCCESS
Error code: the routine returns successfully.
Definition: abt.h:92
ABTU_ret_err
#define ABTU_ret_err
Definition: abtu.h:155
ABTU_mprotect
ABTU_ret_err int ABTU_mprotect(void *addr, size_t size, ABT_bool protect)
Definition: mprotect.c:9