X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb%2Ftdb_private.h;h=33445fc5a14072d16c7f92d07ee806490c68ebaa;hp=2ccd2e788e4116529c68410e6e363833a3b87f3b;hb=acf1a21e440b2908df0ce57c48dab1aca9e23cad;hpb=03d4aa56b8bd381db449b36befa6928594cea994 diff --git a/ccan/tdb/tdb_private.h b/ccan/tdb/tdb_private.h index 2ccd2e78..33445fc5 100644 --- a/ccan/tdb/tdb_private.h +++ b/ccan/tdb/tdb_private.h @@ -52,6 +52,18 @@ /* #define TDB_TRACE 1 */ +#ifndef __STRING +#define __STRING(x) #x +#endif + +#ifndef __STRINGSTRING +#define __STRINGSTRING(x) __STRING(x) +#endif + +#ifndef __location__ +#define __location__ __FILE__ ":" __STRINGSTRING(__LINE__) +#endif + #if HAVE_GETPAGESIZE #define getpagesize() 0x2000 #endif @@ -69,6 +81,7 @@ typedef uint32_t tdb_off_t; #define TDB_FREE_MAGIC (~TDB_MAGIC) #define TDB_DEAD_MAGIC (0xFEE1DEAD) #define TDB_RECOVERY_MAGIC (0xf53bc0e7U) +#define TDB_RECOVERY_INVALID_MAGIC (0x0) #define TDB_ALIGNMENT 4 #define DEFAULT_HASH_SIZE 131 #define FREELIST_TOP (sizeof(struct tdb_header)) @@ -121,7 +134,7 @@ void tdb_trace_2rec_retrec(struct tdb_context *tdb, const char *op, #endif /* !TDB_TRACE */ /* lock offsets */ -#define GLOBAL_LOCK 0 +#define OPEN_LOCK 0 #define ACTIVE_LOCK 4 #define TRANSACTION_LOCK 8 @@ -170,7 +183,7 @@ struct tdb_header { }; struct tdb_lock_type { - int list; + uint32_t off; uint32_t count; uint32_t ltype; }; @@ -210,7 +223,7 @@ struct tdb_context { int read_only; /* opened read-only */ int traverse_read; /* read-only traversal */ int traverse_write; /* read-write traversal */ - struct tdb_lock_type global_lock; + struct tdb_lock_type allrecord_lock; int num_lockrecs; struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */ enum TDB_ERROR ecode; /* error code for last tdb error */ @@ -243,6 +256,10 @@ int tdb_munmap(struct tdb_context *tdb); void tdb_mmap(struct tdb_context *tdb); int tdb_lock(struct tdb_context *tdb, int list, int ltype); int tdb_lock_nonblock(struct tdb_context *tdb, int list, int ltype); +int tdb_nest_lock(struct tdb_context *tdb, uint32_t offset, int ltype, + enum tdb_lock_flags flags); +int tdb_nest_unlock(struct tdb_context *tdb, uint32_t offset, int ltype, + bool mark_lock); int tdb_unlock(struct tdb_context *tdb, int list, int ltype); int tdb_brlock(struct tdb_context *tdb, int rw_type, tdb_off_t offset, size_t len,