X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Fprivate.h;h=c57b3ba9283bc54d907e4ddd886945a1d880435d;hb=18db8f6ff7faf1fe5e831427bc6b524de139dcfe;hp=9abed97df08cdbe4b1fea9b9463adc8133ac72a2;hpb=7d6312518bd3a8e4cbad69b1f6b1800f7bcdf68c;p=ccan diff --git a/ccan/tdb2/private.h b/ccan/tdb2/private.h index 9abed97d..c57b3ba9 100644 --- a/ccan/tdb2/private.h +++ b/ccan/tdb2/private.h @@ -73,7 +73,6 @@ typedef uint64_t tdb_off_t; #define TDB_RECOVERY_MAGIC (0xf53bc0e7ad124589ULL) #define TDB_RECOVERY_INVALID_MAGIC (0x0ULL) -#define TDB_OFF_ERR ((tdb_off_t)-1) #define TDB_OFF_IS_ERR(off) unlikely(off >= (tdb_off_t)TDB_ERR_LAST) /* Packing errors into pointers and v.v. */ @@ -394,13 +393,13 @@ struct tdb_methods { /* hash.c: */ void tdb_hash_init(struct tdb_context *tdb); -int first_in_hash(struct tdb_context *tdb, - struct traverse_info *tinfo, - TDB_DATA *kbuf, size_t *dlen); +tdb_bool_err first_in_hash(struct tdb_context *tdb, + struct traverse_info *tinfo, + TDB_DATA *kbuf, size_t *dlen); -int next_in_hash(struct tdb_context *tdb, - struct traverse_info *tinfo, - TDB_DATA *kbuf, size_t *dlen); +tdb_bool_err next_in_hash(struct tdb_context *tdb, + struct traverse_info *tinfo, + TDB_DATA *kbuf, size_t *dlen); /* Hash random memory. */ uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len); @@ -416,45 +415,45 @@ tdb_off_t find_and_lock(struct tdb_context *tdb, struct tdb_used_record *rec, struct traverse_info *tinfo); -int replace_in_hash(struct tdb_context *tdb, - struct hash_info *h, - tdb_off_t new_off); +enum TDB_ERROR replace_in_hash(struct tdb_context *tdb, + struct hash_info *h, + tdb_off_t new_off); -int add_to_hash(struct tdb_context *tdb, struct hash_info *h, - tdb_off_t new_off); +enum TDB_ERROR add_to_hash(struct tdb_context *tdb, struct hash_info *h, + tdb_off_t new_off); -int delete_from_hash(struct tdb_context *tdb, struct hash_info *h); +enum TDB_ERROR delete_from_hash(struct tdb_context *tdb, struct hash_info *h); /* For tdb_check */ bool is_subhash(tdb_off_t val); /* free.c: */ -int tdb_ftable_init(struct tdb_context *tdb); +enum TDB_ERROR tdb_ftable_init(struct tdb_context *tdb); /* check.c needs these to iterate through free lists. */ tdb_off_t first_ftable(struct tdb_context *tdb); tdb_off_t next_ftable(struct tdb_context *tdb, tdb_off_t ftable); -/* This returns space or TDB_OFF_ERR. */ +/* This returns space or -ve error number. */ tdb_off_t alloc(struct tdb_context *tdb, size_t keylen, size_t datalen, uint64_t hash, unsigned magic, bool growing); /* Put this record in a free list. */ -int add_free_record(struct tdb_context *tdb, - tdb_off_t off, tdb_len_t len_with_header); +enum TDB_ERROR add_free_record(struct tdb_context *tdb, + tdb_off_t off, tdb_len_t len_with_header); /* Set up header for a used/ftable/htable/chain record. */ -int set_header(struct tdb_context *tdb, - struct tdb_used_record *rec, - unsigned magic, uint64_t keylen, uint64_t datalen, - uint64_t actuallen, unsigned hashlow); +enum TDB_ERROR set_header(struct tdb_context *tdb, + struct tdb_used_record *rec, + unsigned magic, uint64_t keylen, uint64_t datalen, + uint64_t actuallen, unsigned hashlow); /* Used by tdb_check to verify. */ unsigned int size_to_bucket(tdb_len_t data_len); tdb_off_t bucket_off(tdb_off_t ftable_off, unsigned bucket); /* Used by tdb_summary */ -size_t dead_space(struct tdb_context *tdb, tdb_off_t off); +tdb_off_t dead_space(struct tdb_context *tdb, tdb_off_t off); /* io.c: */ /* Initialize tdb->methods. */ @@ -561,8 +560,8 @@ bool tdb_has_expansion_lock(struct tdb_context *tdb); enum TDB_ERROR tdb_lock_and_recover(struct tdb_context *tdb); /* transaction.c: */ -int tdb_transaction_recover(struct tdb_context *tdb); -bool tdb_needs_recovery(struct tdb_context *tdb); +enum TDB_ERROR tdb_transaction_recover(struct tdb_context *tdb); +tdb_bool_err tdb_needs_recovery(struct tdb_context *tdb); /* tdb.c: */ enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,