summaryrefslogtreecommitdiffabout
path: root/src
Side-by-side diff
Diffstat (limited to 'src') (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
@@ -35,2 +35,10 @@
+# if defined(MAP_POPULATE)
+# define GDBM_MMAP_FLAGS MAP_POPULATE
+# elif defined(MAP_PREFAULT_READ)
+# define GDBM_MMAP_FLAGS MAP_PREFAULT_READ
+# else
+# define GDBM_MMAP_FLAGS 0
+# endif
+
/* Translate current offset in the mapped region into the absolute position */
@@ -92,3 +100,3 @@ _gdbm_internal_remap (GDBM_FILE dbf, size_t size)
void *p;
- int flags = PROT_READ;
+ int prot = PROT_READ;
size_t page_size = sysconf (_SC_PAGESIZE);
@@ -109,5 +117,5 @@ _gdbm_internal_remap (GDBM_FILE dbf, size_t size)
if (dbf->read_write)
- flags |= PROT_WRITE;
+ prot |= PROT_WRITE;
- p = mmap (NULL, dbf->mapped_size, flags, MAP_SHARED,
+ p = mmap (NULL, dbf->mapped_size, prot, MAP_SHARED | GDBM_MMAP_FLAGS,
dbf->desc, dbf->mapped_off);

Return to:

Send suggestions and report system problems to the System administrator.