]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/private.h
tdb2: remove tailer
[ccan] / ccan / tdb2 / private.h
index 9b225521c74808d62bb9c559a08abd7bb18157df..5e71bc2da46e1af4ec97c37489e1142cb62f9fe8 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)
 #define TDB_FREE_MAGIC ((~(uint64_t)TDB_MAGIC) << 6)
+#define TDB_COALESCING_MAGIC (0xBAD1DEA2FEEDULL << 6)
 #define TDB_HASH_MAGIC (0xA1ABE11A01092008ULL)
 #define TDB_RECOVERY_MAGIC (0xf53bc0e7U)
 #define TDB_RECOVERY_INVALID_MAGIC (0x0)
@@ -113,6 +111,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)
@@ -330,6 +332,7 @@ struct tdb_methods {
        int (*write)(struct tdb_context *, tdb_off_t, const void *, tdb_len_t);
        int (*oob)(struct tdb_context *, tdb_off_t, bool);
        int (*expand_file)(struct tdb_context *, tdb_len_t);
+       void *(*direct)(struct tdb_context *, tdb_off_t, size_t);
 };
 
 /*
@@ -349,7 +352,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,
@@ -378,7 +382,7 @@ int add_free_record(struct tdb_context *tdb, unsigned int zone_bits,
 int set_header(struct tdb_context *tdb,
               struct tdb_used_record *rec,
               uint64_t keylen, uint64_t datalen,
-              uint64_t actuallen, uint64_t hash,
+              uint64_t actuallen, unsigned hashlow,
               unsigned int zone_bits);
 
 /* Used by tdb_check to verify. */