]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/private.h
tdb2: 64 bit fixes.
[ccan] / ccan / tdb2 / private.h
index 091928095eba3daaf50323302fc0f59a277a0e7f..6c727aff4a20a62dc800e5806079742cd32d7ec1 100644 (file)
@@ -23,6 +23,7 @@
 #include <stdint.h>
 #include <stdbool.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <sys/time.h>
 #include <sys/mman.h>
 #include <unistd.h>
 typedef uint64_t tdb_len_t;
 typedef uint64_t tdb_off_t;
 
-#ifndef offsetof
-#define offsetof(t,f) ((unsigned int)&((t *)0)->f)
-#endif
-
 #define TDB_MAGIC_FOOD "TDB file\n"
 #define TDB_VERSION ((uint64_t)(0x26011967 + 7))
 #define TDB_MAGIC ((uint64_t)0x1999)
@@ -113,6 +110,10 @@ typedef uint64_t tdb_off_t;
 #define TDB_OFF_MASK \
        (((1ULL << (64 - TDB_OFF_UPPER_STEAL)) - 1) - TDB_OFF_HASH_GROUP_MASK)
 
+/* We have to be able to fit a free record here. */
+#define TDB_MIN_DATA_LEN       \
+       (sizeof(struct tdb_free_record) - sizeof(struct tdb_used_record))
+
 /* We ensure buckets up to size 1 << (zone_bits - TDB_COMFORT_FACTOR_BITS). */
 /* FIXME: test this matches size_to_bucket! */
 #define BUCKETS_FOR_ZONE(zone_bits) ((zone_bits) + 2 - TDB_COMFORT_FACTOR_BITS)
@@ -282,9 +283,12 @@ struct tdb_context {
        /* How much space has been mapped (<= current file size) */
        tdb_len_t map_size;
 
-       /* Opened read-only? */
+       /* Operating read-only? (Opened O_RDONLY, or in traverse_read) */
        bool read_only;
 
+       /* mmap read only? */
+       int mmap_flags;
+
        /* Error code for last tdb error. */
        enum TDB_ERROR ecode; 
 
@@ -346,7 +350,8 @@ tdb_off_t find_and_lock(struct tdb_context *tdb,
                        struct tdb_data key,
                        int ltype,
                        struct hash_info *h,
-                       struct tdb_used_record *rec);
+                       struct tdb_used_record *rec,
+                       struct traverse_info *tinfo);
 
 int replace_in_hash(struct tdb_context *tdb,
                    struct hash_info *h,