aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog18
-rw-r--r--doc/gdbm.texinfo79
-rw-r--r--src/gdbm.h.in30
-rw-r--r--src/gdbmconst.h23
-rw-r--r--src/gdbmdefs.h3
-rw-r--r--src/gdbmopen.c11
-rw-r--r--src/gdbmreorg.c2
-rw-r--r--src/gdbmsetopt.c114
-rw-r--r--src/mmap.c10
9 files changed, 228 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index 1b358b9..f7a97c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
12011-08-11 Sergey Poznyakoff <gray@gnu.org.ua> 12011-08-11 Sergey Poznyakoff <gray@gnu.org.ua>
2 2
3 Improve gdbm_setopt interface.
4
5 * src/gdbm.h.in (GDBM_OPENMASK): New constant.
6 * src/gdbmconst.h: Remove constants duplicated in
7 gdbm.h.in.
8 * src/gdbmdefs.h (gdbm_file_info) <allow_mmap>
9 <mmap_inited>: Replace with a single member: memory_mapping.
10 All callers updated.
11 (GDBM_SETCACHESIZE,GDBM_SETSYNCMODE)
12 (GDBM_SETCENTFREE,GDBM_SETCOALESCEBLKS): New option names.
13 (GDBM_SETMMAP,GDBM_GETMMAP,GDBM_GETFLAGS)
14 (GDBM_GETCACHESIZE,GDBM_GETSYNCMODE,GDBM_GETCENTFREE)
15 (GDBM_GETCOALESCEBLKS,GDBM_GETMAXMAPSIZE): New option codes.
16 * src/gdbmsetopt.c: Implement new options.
17 * doc/gdbm.texinfo: Document new options.
18
192011-08-11 Sergey Poznyakoff <gray@gnu.org.ua>
20
3 Improve memory mapping support. 21 Improve memory mapping support.
4 22
5 The new code is more flexible and performs better when 23 The new code is more flexible and performs better when
diff --git a/doc/gdbm.texinfo b/doc/gdbm.texinfo
index 5dc8a97..04efeea 100644
--- a/doc/gdbm.texinfo
+++ b/doc/gdbm.texinfo
@@ -739,7 +739,7 @@ open database.
739 739
740@deftypefn {gdbm interface} int gdbm_setopt (GDBM_FILE @var{dbf}, int @var{option}, @ 740@deftypefn {gdbm interface} int gdbm_setopt (GDBM_FILE @var{dbf}, int @var{option}, @
741 void *@var{value}, int @var{size}) 741 void *@var{value}, int @var{size})
742Sets an option on the database. 742Sets an option on the database or returns the value of an option.
743 743
744The parameters are: 744The parameters are:
745 745
@@ -747,9 +747,10 @@ The parameters are:
747@item dbf 747@item dbf
748The pointer returned by @code{gdbm_open}. 748The pointer returned by @code{gdbm_open}.
749@item option 749@item option
750The option to be set. 750The option to be set or retreived.
751@item value 751@item value
752A pointer to the value to which @var{option} will be set. 752A pointer to the value to which @var{option} will be set or where to
753place the option value (depending on the option).
753@item size 754@item size
754The length of the data pointed to by @var{value}. 755The length of the data pointed to by @var{value}.
755@end table 756@end table
@@ -759,11 +760,29 @@ The valid options are:
759 760
760@table @asis 761@table @asis
761@kwindex GDBM_CACHESIZE 762@kwindex GDBM_CACHESIZE
762@item GDBM_CACHESIZE 763@kwindex GDBM_SETCACHESIZE
764@item GDBM_SETCACHESIZE
765@itemx GDBM_CACHESIZE
763Set the size of the internal bucket cache. This option may only be 766Set the size of the internal bucket cache. This option may only be
764set once on each GDBM_FILE descriptor, and is set automatically to 100 767set once on each GDBM_FILE descriptor, and is set automatically to 100
765upon the first access to the database. The @var{value} should point 768upon the first access to the database. The @var{value} should point
766to an integer holding the desired cache size. 769to a @code{size_t} holding the desired cache size.
770
771The @samp{GDBM_CACHESIZE} option is provided for compatibility with
772earlier versions.
773
774@kwindex GDBM_GETCACHESIZE
775@item GDBM_GETCACHESIZE
776Return the size of the internal bucket cache. The @var{value} should
777point to a @code{size_t} variable, where the size will be stored.
778
779@kwindex GDBM_GETFLAGS
780@item GDBM_GETFLAGS
781Return the flags describing the state of the database. The @var{value} should
782point to a @code{int} variable where to store the flags. The return
783is the same as the flags used when opening the database (@pxref{Open,
784gdbm_open}), except that it reflects the current state (which may have
785been altered by another calls to @code{gdbm_setopt}.
767 786
768@kwindex GDBM_FASTMODE 787@kwindex GDBM_FASTMODE
769@item GDBM_FASTMODE 788@item GDBM_FASTMODE
@@ -773,22 +792,34 @@ to an integer: @samp{TRUE} to enable fast mode, and @samp{FALSE} to
773disable it. 792disable it.
774 793
775This option is retained for compatibility with previous versions of 794This option is retained for compatibility with previous versions of
776@code{gdbm}. Its effect is the reverse of @code{GDBM_SYNCMODE} 795@code{gdbm}. Its effect is the reverse of @code{GDBM_SETSYNCMODE}
777(see below). 796(see below).
778 797
798@kwindex GDBM_SETSYNCMODE
779@kwindex GDBM_SYNCMODE 799@kwindex GDBM_SYNCMODE
780@item GDBM_SYNCMODE 800@item GDBM_SETSYNCMODE
801@itemx GDBM_SYNCMODE
781Turn on or off file system synchronization operations. This 802Turn on or off file system synchronization operations. This
782setting defaults to off. The @var{value} should point 803setting defaults to off. The @var{value} should point
783to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to 804to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to
784turn it off. 805turn it off.
785 806
786Note, that this option is a reverse of @code{GDBM_FASTMODE}, 807Note, that this option is a reverse of @code{GDBM_FASTMODE},
787i.e. calling @code{GDBM_SYNCMODE} with @samp{TRUE} has the same effect 808i.e. calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect
788as calling @code{GDBM_FASTMODE} with @samp{FALSE}. 809as calling @code{GDBM_FASTMODE} with @samp{FALSE}.
789 810
811The @samp{GDBM_SYNCMODE} option is provided for compatibility with
812earlier versions.
813
814@kwindex GDBM_GETSYNCMODE
815@item GDBM_GETSYNCMODE
816Return the current synchronization status. The @var{value} should
817point to an @code{int} where the status will be stored.
818
819@kwindex GDBM_SETCENTFREE
790@kwindex GDBM_CENTFREE 820@kwindex GDBM_CENTFREE
791@item GDBM_CENTFREE 821@item GDBM_SETCENTFREE
822@itemx GDBM_CENTFREE
792@emph{NOTICE: This feature is still under study.} 823@emph{NOTICE: This feature is still under study.}
793 824
794Set central free block pool to either on or off. The default is off, 825Set central free block pool to either on or off. The default is off,
@@ -798,8 +829,13 @@ set, this option causes all subsequent free blocks to be placed in the
798more quickly. The @var{value} should point to an integer: @samp{TRUE} to 829more quickly. The @var{value} should point to an integer: @samp{TRUE} to
799turn central block pool on, and @samp{FALSE} to turn it off. 830turn central block pool on, and @samp{FALSE} to turn it off.
800 831
832The @samp{GDBM_CENTFREE} option is provided for compatibility with
833earlier versions.
834
835@kwindex GDBM_SETCOALESCEBLKS
801@kwindex GDBM_COALESCEBLKS 836@kwindex GDBM_COALESCEBLKS
802@item GDBM_COALESCEBLKS 837@item GDBM_SETCOALESCEBLKS
838@itemx GDBM_COALESCEBLKS
803@emph{NOTICE: This feature is still under study.} 839@emph{NOTICE: This feature is still under study.}
804 840
805Set free block merging to either on or off. The default is off, which 841Set free block merging to either on or off. The default is off, which
@@ -810,13 +846,34 @@ used in conjunction with GDBM_CENTFREE. The @var{value} should point
810to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to 846to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to
811turn it off. 847turn it off.
812 848
849@kwindex GDBM_GETCOALESCEBLKS
850@item GDBM_GETCOALESCEBLKS
851Return the current status of free block merging. The @var{value} should
852point to an @code{int} where the status will be stored.
853
813@kwindex GDBM_SETMAXMAPSIZE 854@kwindex GDBM_SETMAXMAPSIZE
814@item GDBM_SETMAXMAPSIZE 855@item GDBM_SETMAXMAPSIZE
815Sets maximum size of the memory mapped region. The @var{value} should 856Sets maximum size of a memory mapped region. The @var{value} should
816point to a value of type @code{size_t}, @code{unsigned long} or 857point to a value of type @code{size_t}, @code{unsigned long} or
817@code{unsigned}. The actual value is rounded to the nearest page 858@code{unsigned}. The actual value is rounded to the nearest page
818boundary (the page size is obtained from 859boundary (the page size is obtained from
819@code{sysconf(_SC_PAGESIZE)}). 860@code{sysconf(_SC_PAGESIZE)}).
861
862@kwindex GDBM_GETMAXMAPSIZE
863@item GDBM_GETMAXMAPSIZE
864Return the maximum size of a memory mapped region. The @var{value} should
865point to a value of type @code{size_t} where to return the data.
866
867@kwindex GDBM_SETMMAP
868@item GDBM_SETMMAP
869Enable or disable memory mapping mode. The @var{value} should point
870to an integer: @samp{TRUE} to enable memory mapping or @samp{FALSE} to
871disable it.
872
873@kwindex GDBM_GETMMAP
874@item GDBM_GETMMAP
875Check whether memory mapping is enabled. The @var{value} should point
876to an integer where to return the status.
820@end table 877@end table
821 878
822The return value will be @samp{-1} upon failure, or @samp{0} upon 879The return value will be @samp{-1} upon failure, or @samp{0} upon
diff --git a/src/gdbm.h.in b/src/gdbm.h.in
index 8eaee79..da88777 100644
--- a/src/gdbm.h.in
+++ b/src/gdbm.h.in
@@ -35,6 +35,8 @@
35#define GDBM_WRITER 1 /* A writer. */ 35#define GDBM_WRITER 1 /* A writer. */
36#define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */ 36#define GDBM_WRCREAT 2 /* A writer. Create the db if needed. */
37#define GDBM_NEWDB 3 /* A writer. Always create a new db. */ 37#define GDBM_NEWDB 3 /* A writer. Always create a new db. */
38#define GDBM_OPENMASK 7 /* Mask for the above. */
39
38#define GDBM_FAST 0x10 /* Write fast! => No fsyncs. OBSOLETE. */ 40#define GDBM_FAST 0x10 /* Write fast! => No fsyncs. OBSOLETE. */
39#define GDBM_SYNC 0x20 /* Sync operations to the disk. */ 41#define GDBM_SYNC 0x20 /* Sync operations to the disk. */
40#define GDBM_NOLOCK 0x40 /* Don't do file locking operations. */ 42#define GDBM_NOLOCK 0x40 /* Don't do file locking operations. */
@@ -46,12 +48,28 @@
46#define GDBM_REPLACE 1 /* Always replace old data with new. */ 48#define GDBM_REPLACE 1 /* Always replace old data with new. */
47 49
48/* Parameters to gdbm_setopt, specifing the type of operation to perform. */ 50/* Parameters to gdbm_setopt, specifing the type of operation to perform. */
49#define GDBM_CACHESIZE 1 /* Set the cache size. */ 51#define GDBM_SETCACHESIZE 1 /* Set the cache size. */
50#define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */ 52#define GDBM_FASTMODE 2 /* Toggle fast mode. OBSOLETE. */
51#define GDBM_SYNCMODE 3 /* Turn on or off sync operations. */ 53#define GDBM_SETSYNCMODE 3 /* Turn on or off sync operations. */
52#define GDBM_CENTFREE 4 /* Keep all free blocks in the header. */ 54#define GDBM_SETCENTFREE 4 /* Keep all free blocks in the header. */
53#define GDBM_COALESCEBLKS 5 /* Attempt to coalesce free blocks. */ 55#define GDBM_SETCOALESCEBLKS 5 /* Attempt to coalesce free blocks. */
54#define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */ 56#define GDBM_SETMAXMAPSIZE 6 /* Set maximum mapped memory size */
57#define GDBM_SETMMAP 7
58
59/* Compatibility defines: */
60#define GDBM_CACHESIZE GDBM_SETCACHESIZ