/* [<][>][^][v][top][bottom][index][help] */
DEFINITIONS
This source file includes following definitions.
- mmap
- mmap64
- munmap
- mremap
- mremap
1 /****************************************************************************
2 * Copyright (C) 2006-2013 by Jason Ansel, Kapil Arya, and Gene Cooperman *
3 * jansel@csail.mit.edu, kapil@ccs.neu.edu, gene@ccs.neu.edu *
4 * *
5 * This file is part of the dmtcp/src module of DMTCP (DMTCP:dmtcp/src). *
6 * *
7 * DMTCP:dmtcp/src is free software: you can redistribute it and/or *
8 * modify it under the terms of the GNU Lesser General Public License as *
9 * published by the Free Software Foundation, either version 3 of the *
10 * License, or (at your option) any later version. *
11 * *
12 * DMTCP:dmtcp/src is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with DMTCP:dmtcp/src. If not, see *
19 * <http://www.gnu.org/licenses/>. *
20 ****************************************************************************/
21
22 #include <stdarg.h>
23 #include <sys/mman.h>
24 #include "dmtcp.h"
25 #include "alloc.h"
26
27 //#define ENABLE_MMAP_WRAPPERS
28 #ifdef ENABLE_MMAP_WRAPPERS
29 extern "C" void *mmap(void *addr, size_t length, int prot, int flags,
30 int fd, off_t offset)
31 {
32 DMTCP_PLUGIN_DISABLE_CKPT();
33 void *retval = _real_mmap(addr, length, prot, flags, fd, offset);
34 DMTCP_PLUGIN_ENABLE_CKPT();
35 return retval;
36 }
37
38 extern "C" void *mmap64 (void *addr, size_t length, int prot, int flags,
39 int fd, off64_t offset)
40 {
41 DMTCP_PLUGIN_DISABLE_CKPT();
42 void *retval = _real_mmap64(addr, length, prot, flags, fd, offset);
43 DMTCP_PLUGIN_ENABLE_CKPT();
44 return retval;
45 }
46
47 extern "C" int munmap(void *addr, size_t length)
48 {
49 DMTCP_PLUGIN_DISABLE_CKPT();
50 int retval = _real_munmap(addr, length);
51 DMTCP_PLUGIN_ENABLE_CKPT();
52 return retval;
53 }
54
55 # if __GLIBC_PREREQ (2,4)
56 extern "C" void *mremap(void *old_address, size_t old_size,
57 size_t new_size, int flags, ...)
58 {
59 void *retval;
60 DMTCP_PLUGIN_DISABLE_CKPT();
61 if (flags == MREMAP_FIXED) {
62 va_list ap;
63 va_start( ap, flags );
64 void *new_address = va_arg ( ap, void * );
65 va_end ( ap );
66 retval = _real_mremap(old_address, old_size, new_size, flags, new_address);
67 } else {
68 retval = _real_mremap(old_address, old_size, new_size, flags);
69 }
70 DMTCP_PLUGIN_ENABLE_CKPT();
71 return retval;
72 }
73 # else
74 extern "C" void *mremap(void *old_address, size_t old_size,
75 size_t new_size, int flags)
76 {
77 DMTCP_PLUGIN_DISABLE_CKPT();
78 void *retval = _real_mremap(old_address, old_size, new_size, flags);
79 DMTCP_PLUGIN_ENABLE_CKPT();
80 return retval;
81 }
82 #endif
83 #endif // ENABLE_MMAP_WRAPPERS