-PRINTF_ATTRIBUTE(4, 5) static void
-null_log_fn(struct tdb_context *tdb,
- enum tdb_debug_level level, void *priv,
- const char *fmt, ...)
-{
-}
-
-/* We do a lot of work assuming our copy of the header volatile area
- * is uptodate, and usually it is. However, once we grab a lock, we have to
- * re-check it. */
-bool header_changed(struct tdb_context *tdb)
-{
- uint64_t gen;
-
- if (!(tdb->flags & TDB_NOLOCK) && tdb->header_uptodate) {
- tdb->log(tdb, TDB_DEBUG_WARNING, tdb->log_priv,
- "warning: header uptodate already\n");
- }
-
- /* We could get a partial update if we're not holding any locks. */
- assert((tdb->flags & TDB_NOLOCK) || tdb_has_locks(tdb));
-
- tdb->header_uptodate = true;
- gen = tdb_read_off(tdb, offsetof(struct tdb_header, v.generation));
- if (unlikely(gen != tdb->header.v.generation)) {
- tdb_read_convert(tdb, offsetof(struct tdb_header, v),
- &tdb->header.v, sizeof(tdb->header.v));
- return true;
- }
- return false;
-}
-
-int write_header(struct tdb_context *tdb)
-{
- assert(tdb_read_off(tdb, offsetof(struct tdb_header, v.generation))
- == tdb->header.v.generation);
- tdb->header.v.generation++;
- return tdb_write_convert(tdb, offsetof(struct tdb_header, v),
- &tdb->header.v, sizeof(tdb->header.v));
-}
-
-static uint64_t jenkins_hash(const void *key, size_t length, uint64_t seed,
- void *arg)
-{
- return hash64_stable((const unsigned char *)key, length, seed);
-}
-
-uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len)
-{
- return tdb->khash(ptr, len, tdb->header.hash_seed, tdb->hash_priv);
-}
-