summaryrefslogtreecommitdiffabout
path: root/src/gdbmdefs.h
Unidiff
Diffstat (limited to 'src/gdbmdefs.h') (more/less context) (ignore whitespace changes)
-rw-r--r--src/gdbmdefs.h17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/gdbmdefs.h b/src/gdbmdefs.h
index 5305b0d..1bb519b 100644
--- a/src/gdbmdefs.h
+++ b/src/gdbmdefs.h
@@ -26,6 +26,22 @@
26#define _(s) gettext (s) 26#define _(s) gettext (s)
27#define N_(s) s 27#define N_(s) s
28 28
29/* The width in bits of the integer type or expression T. */
30#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
31
32#define SIGNED_TYPE_MAXIMUM(t) \
33 ((t) ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))
34
35/* Maximum value for off_t */
36#define OFF_T_MAX SIGNED_TYPE_MAXIMUM (off_t)
37
38/* Return true if A can be added to B without integer overflow */
39static inline off_t
40off_t_sum_ok (off_t a, off_t b)
41{
42 return OFF_T_MAX - a >= b;
43}
44
29/* The type definitions are next. */ 45/* The type definitions are next. */
30 46
31/* The available file space is stored in an "avail" table. The one with 47/* The available file space is stored in an "avail" table. The one with
@@ -93,6 +109,7 @@ typedef struct
93 int data_size; /* Size of associated data in the file. */ 109 int data_size; /* Size of associated data in the file. */
94} bucket_element; 110} bucket_element;
95 111
112extern int gdbm_bucket_element_valid_p (GDBM_FILE dbf, int elem_loc);
96 113
97/* A bucket is a small hash table. This one consists of a number of 114/* A bucket is a small hash table. This one consists of a number of
98 bucket elements plus some bookkeeping fields. The number of elements 115 bucket elements plus some bookkeeping fields. The number of elements

Return to:

Send suggestions and report system problems to the System administrator.