summaryrefslogtreecommitdiffabout
path: root/src/mmap.c
Unidiff
Diffstat (limited to 'src/mmap.c') (more/less context) (ignore whitespace changes)
-rw-r--r--src/mmap.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/mmap.c b/src/mmap.c
index 3d57b11..273f64c 100644
--- a/src/mmap.c
+++ b/src/mmap.c
@@ -33,6 +33,14 @@
33# define MAP_FAILED ((void*)-1) 33# define MAP_FAILED ((void*)-1)
34# endif 34# endif
35 35
36# if defined(MAP_POPULATE)
37# define GDBM_MMAP_FLAGS MAP_POPULATE
38# elif defined(MAP_PREFAULT_READ)
39# define GDBM_MMAP_FLAGS MAP_PREFAULT_READ
40# else
41# define GDBM_MMAP_FLAGS 0
42# endif
43
36/* Translate current offset in the mapped region into the absolute position */ 44/* Translate current offset in the mapped region into the absolute position */
37# define _GDBM_MMAPPED_POS(dbf) ((dbf)->mapped_off + (dbf)->mapped_pos) 45# define _GDBM_MMAPPED_POS(dbf) ((dbf)->mapped_off + (dbf)->mapped_pos)
38/* Return true if the absolute offset OFF lies within the currentlty mmapped 46/* Return true if the absolute offset OFF lies within the currentlty mmapped
@@ -90,7 +98,7 @@ int
90_gdbm_internal_remap (GDBM_FILE dbf, size_t size) 98_gdbm_internal_remap (GDBM_FILE dbf, size_t size)
91{ 99{
92 void *p; 100 void *p;
93 int flags = PROT_READ; 101 int prot = PROT_READ;
94 size_t page_size = sysconf (_SC_PAGESIZE); 102 size_t page_size = sysconf (_SC_PAGESIZE);
95 103
96 if (dbf->mapped_region) 104 if (dbf->mapped_region)
@@ -107,9 +115,9 @@ _gdbm_internal_remap (GDBM_FILE dbf, size_t size)
107 dbf->mapped_off = (dbf->mapped_off / page_size) * page_size; 115 dbf->mapped_off = (dbf->mapped_off / page_size) * page_size;
108 116
109 if (dbf->read_write) 117 if (dbf->read_write)
110 flags |= PROT_WRITE; 118 prot |= PROT_WRITE;
111 119
112 p = mmap (NULL, dbf->mapped_size, flags, MAP_SHARED, 120 p = mmap (NULL, dbf->mapped_size, prot, MAP_SHARED | GDBM_MMAP_FLAGS,
113 dbf->desc, dbf->mapped_off); 121 dbf->desc, dbf->mapped_off);
114 if (p == MAP_FAILED) 122 if (p == MAP_FAILED)
115 { 123 {

Return to:

Send suggestions and report system problems to the System administrator.