aboutsummaryrefslogtreecommitdiff
path: root/src/gdbmdefs.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/gdbmdefs.h')
-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
@@ -28,2 +28,18 @@
+/* The width in bits of the integer type or expression T. */
+#define TYPE_WIDTH(t) (sizeof (t) * CHAR_BIT)
+
+#define SIGNED_TYPE_MAXIMUM(t) \
+ ((t) ((((t) 1 << (TYPE_WIDTH (t) - 2)) - 1) * 2 + 1))
+
+/* Maximum value for off_t */
+#define OFF_T_MAX SIGNED_TYPE_MAXIMUM (off_t)
+
+/* Return true if A can be added to B without integer overflow */
+static inline off_t
+off_t_sum_ok (off_t a, off_t b)
+{
+ return OFF_T_MAX - a >= b;
+}
+
/* The type definitions are next. */
@@ -95,2 +111,3 @@ typedef struct
+extern int gdbm_bucket_element_valid_p (GDBM_FILE dbf, int elem_loc);

Return to:

Send suggestions and report system problems to the System administrator.