aboutsummaryrefslogtreecommitdiff
path: root/src/gdbm.h.in
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2011-08-10 22:00:34 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2011-08-10 22:00:34 +0000
commit74f7fe561e31637bdbf21aeb817d4a22bbf9c91a (patch)
treebae9da9f2c749d290ad4f1764dc205bcd23b750e /src/gdbm.h.in
parent6b6dcc80555d77858733e44b72e92d1dc60e2c38 (diff)
downloadgdbm-74f7fe561e31637bdbf21aeb817d4a22bbf9c91a.tar.gz
gdbm-74f7fe561e31637bdbf21aeb817d4a22bbf9c91a.tar.bz2
Improve memory mapping support.
The new code is more flexible and performs better when lots of inserts are being made (e.g. when populating the database with new data). * src/gdbm.h.in (GDBM_SETMAXMAPSIZE): New constant. * src/gdbmconst.h (SIZE_T_MAX): New define. * src/gdbmdefs.h (gdbm_file_info) <cache_size>: Change type to size_t. <mmap_inited,mapped_size_max>: New member. <mapped_remap>: Remove. * src/gdbmopen.c: Fix a typo. (gdbm_open): Initialize new members. (_gdbm_init_cache): Second argument is size_t. * src/gdbmsetopt.c (gdbm_setopt): Optval argument is void*. Handle GDBM_SETMAXMAPSIZE. Improve error checking. * src/mmap.c (_GDBM_IN_MAPPED_REGION_P): Fix comparison with the lower bound. (_GDBM_NEED_REMAP): Return true if mapped_region is NULL. (SUM_FILE_SIZE): Rewrite. (_gdbm_mapped_unmap): Don't call msync. (_gdbm_internal_remap): Take 2 arguments, the second one giving the new mapped size. Unmap the region prior to remapping it. Always pass NULL as the argument to mmap. (_gdbm_mapped_remap): Rewrite the logic. Change semantics of the third argument. All uses updated. (_gdbm_mapped_init): Reflect the above changes. (_gdbm_mapped_read,_gdbm_mapped_write): Use mmap_inited to decide whether to use mmap, because mapped_region can be reset to zero by another functions (namely, _gdbm_mapped_lseek). Reset mmap_inited to FALSE, if _gdbm_mapped_remap fails. (_gdbm_mapped_lseek): Rewrite offset computations. Invalidate the mapped region. * src/proto.h (_gdbm_init_cache): Change prototype. * src/update.c (write_header, _gdbm_end_update): Remove checks for dbf->mapped_region. * tests/gtload.c: Implement the -maxmap option (set maximal mapped memory size). * doc/gdbm.texinfo: Document GDBM_SETMAXMAPSIZE.
Diffstat (limited to 'src/gdbm.h.in')
-rw-r--r--src/gdbm.h.in4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/gdbm.h.in b/src/gdbm.h.in
index 70de4e0..8eaee79 100644
--- a/src/gdbm.h.in
+++ b/src/gdbm.h.in
@@ -51,6 +51,7 @@
#define GDBM_SYNCMODE 3 /* Turn on or off sync operations. */
#define GDBM_CENTFREE 4 /* Keep all free blocks in the header. */
#define GDBM_COALESCEBLKS 5 /* Attempt to coalesce free blocks. */
+#define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */
/* The data and key structure. */
typedef struct {
@@ -89,7 +90,7 @@ extern datum gdbm_nextkey (GDBM_FILE, datum);
extern int gdbm_reorganize (GDBM_FILE);
extern void gdbm_sync (GDBM_FILE);
extern int gdbm_exists (GDBM_FILE, datum);
-extern int gdbm_setopt (GDBM_FILE, int, int *, int);
+extern int gdbm_setopt (GDBM_FILE, int, void *, int);
extern int gdbm_fdesc (GDBM_FILE);
extern int gdbm_export (GDBM_FILE, const char *, int, int);
extern int gdbm_import (GDBM_FILE, const char *, int);
@@ -136,6 +137,7 @@ extern "C" {
#endif
extern const char *gdbm_strerror (gdbm_error);
+extern int gdbm_version_cmp (int const a[], int const b[]);
#if defined(__cplusplus) || defined(c_plusplus)
}

Return to:

Send suggestions and report system problems to the System administrator.