diff options
-rw-r--r-- | ChangeLog | 18 | ||||
-rw-r--r-- | doc/gdbm.texinfo | 79 | ||||
-rw-r--r-- | src/gdbm.h.in | 30 | ||||
-rw-r--r-- | src/gdbmconst.h | 23 | ||||
-rw-r--r-- | src/gdbmdefs.h | 3 | ||||
-rw-r--r-- | src/gdbmopen.c | 11 | ||||
-rw-r--r-- | src/gdbmreorg.c | 2 | ||||
-rw-r--r-- | src/gdbmsetopt.c | 114 | ||||
-rw-r--r-- | src/mmap.c | 10 |
9 files changed, 228 insertions, 62 deletions
@@ -1,5 +1,23 @@ | |||
1 | 2011-08-11 Sergey Poznyakoff <gray@gnu.org.ua> | 1 | 2011-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 | |||
19 | 2011-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}) |
742 | Sets an option on the database. | 742 | Sets an option on the database or returns the value of an option. |
743 | 743 | ||
744 | The parameters are: | 744 | The parameters are: |
745 | 745 | ||
@@ -747,9 +747,10 @@ The parameters are: | |||
747 | @item dbf | 747 | @item dbf |
748 | The pointer returned by @code{gdbm_open}. | 748 | The pointer returned by @code{gdbm_open}. |
749 | @item option | 749 | @item option |
750 | The option to be set. | 750 | The option to be set or retreived. |
751 | @item value | 751 | @item value |
752 | A pointer to the value to which @var{option} will be set. | 752 | A pointer to the value to which @var{option} will be set or where to |
753 | place the option value (depending on the option). | ||
753 | @item size | 754 | @item size |
754 | The length of the data pointed to by @var{value}. | 755 | The 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 | ||
763 | Set the size of the internal bucket cache. This option may only be | 766 | Set the size of the internal bucket cache. This option may only be |
764 | set once on each GDBM_FILE descriptor, and is set automatically to 100 | 767 | set once on each GDBM_FILE descriptor, and is set automatically to 100 |
765 | upon the first access to the database. The @var{value} should point | 768 | upon the first access to the database. The @var{value} should point |
766 | to an integer holding the desired cache size. | 769 | to a @code{size_t} holding the desired cache size. |
770 | |||
771 | The @samp{GDBM_CACHESIZE} option is provided for compatibility with | ||
772 | earlier versions. | ||
773 | |||
774 | @kwindex GDBM_GETCACHESIZE | ||
775 | @item GDBM_GETCACHESIZE | ||
776 | Return the size of the internal bucket cache. The @var{value} should | ||
777 | point to a @code{size_t} variable, where the size will be stored. | ||
778 | |||
779 | @kwindex GDBM_GETFLAGS | ||
780 | @item GDBM_GETFLAGS | ||
781 | Return the flags describing the state of the database. The @var{value} should | ||
782 | point to a @code{int} variable where to store the flags. The return | ||
783 | is the same as the flags used when opening the database (@pxref{Open, | ||
784 | gdbm_open}), except that it reflects the current state (which may have | ||
785 | been 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 | |||
773 | disable it. | 792 | disable it. |
774 | 793 | ||
775 | This option is retained for compatibility with previous versions of | 794 | This 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 | ||
781 | Turn on or off file system synchronization operations. This | 802 | Turn on or off file system synchronization operations. This |
782 | setting defaults to off. The @var{value} should point | 803 | setting defaults to off. The @var{value} should point |
783 | to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to | 804 | to an integer: @samp{TRUE} to turn synchronization on, and @samp{FALSE} to |
784 | turn it off. | 805 | turn it off. |
785 | 806 | ||
786 | Note, that this option is a reverse of @code{GDBM_FASTMODE}, | 807 | Note, that this option is a reverse of @code{GDBM_FASTMODE}, |
787 | i.e. calling @code{GDBM_SYNCMODE} with @samp{TRUE} has the same effect | 808 | i.e. calling @code{GDBM_SETSYNCMODE} with @samp{TRUE} has the same effect |
788 | as calling @code{GDBM_FASTMODE} with @samp{FALSE}. | 809 | as calling @code{GDBM_FASTMODE} with @samp{FALSE}. |
789 | 810 | ||
811 | The @samp{GDBM_SYNCMODE} option is provided for compatibility with | ||
812 | earlier versions. | ||
813 | |||
814 | @kwindex GDBM_GETSYNCMODE | ||
815 | @item GDBM_GETSYNCMODE | ||
816 | Return the current synchronization status. The @var{value} should | ||
817 | point 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 | ||
794 | Set central free block pool to either on or off. The default is off, | 825 | Set 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 | |||
798 | more quickly. The @var{value} should point to an integer: @samp{TRUE} to | 829 | more quickly. The @var{value} should point to an integer: @samp{TRUE} to |
799 | turn central block pool on, and @samp{FALSE} to turn it off. | 830 | turn central block pool on, and @samp{FALSE} to turn it off. |
800 | 831 | ||
832 | The @samp{GDBM_CENTFREE} option is provided for compatibility with | ||
833 | earlier 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 | ||
805 | Set free block merging to either on or off. The default is off, which | 841 | Set 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 | |||
810 | to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to | 846 | to an integer: @samp{TRUE} to turn free block merging on, and @samp{FALSE} to |
811 | turn it off. | 847 | turn it off. |
812 | 848 | ||
849 | @kwindex GDBM_GETCOALESCEBLKS | ||
850 | @item GDBM_GETCOALESCEBLKS | ||
851 | Return the current status of free block merging. The @var{value} should | ||
852 | point 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 |
815 | Sets maximum size of the memory mapped region. The @var{value} should | 856 | Sets maximum size of a memory mapped region. The @var{value} should |
816 | point to a value of type @code{size_t}, @code{unsigned long} or | 857 | point 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 |
818 | boundary (the page size is obtained from | 859 | boundary (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 | ||
864 | Return the maximum size of a memory mapped region. The @var{value} should | ||
865 | point to a value of type @code{size_t} where to return the data. | ||
866 | |||
867 | @kwindex GDBM_SETMMAP | ||
868 | @item GDBM_SETMMAP | ||
869 | Enable or disable memory mapping mode. The @var{value} should point | ||
870 | to an integer: @samp{TRUE} to enable memory mapping or @samp{FALSE} to | ||
871 | disable it. | ||
872 | |||
873 | @kwindex GDBM_GETMMAP | ||
874 | @item GDBM_GETMMAP | ||
875 | Check whether memory mapping is enabled. The @var{value} should point | ||
876 | to an integer where to return the status. | ||
820 | @end table | 877 | @end table |
821 | 878 | ||
822 | The return value will be @samp{-1} upon failure, or @samp{0} upon | 879 | The 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 |