From 39f55294799c6443c0ad7bef09f1c113cf89d295 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 31 Aug 2011 15:13:16 +0930 Subject: [PATCH 1/1] tdb2: remove _PUBLIC_ in tdb1 functions. They'll all be accessed via the tdb2 API. --- ccan/tdb2/tdb1_check.c | 2 +- ccan/tdb2/tdb1_hash.c | 2 +- ccan/tdb2/tdb1_lock.c | 16 ++++++++-------- ccan/tdb2/tdb1_open.c | 8 ++++---- ccan/tdb2/tdb1_private.h | 5 ----- ccan/tdb2/tdb1_summary.c | 2 +- ccan/tdb2/tdb1_tdb.c | 26 +++++++++++++------------- ccan/tdb2/tdb1_transaction.c | 8 ++++---- ccan/tdb2/tdb1_traverse.c | 8 ++++---- 9 files changed, 36 insertions(+), 41 deletions(-) diff --git a/ccan/tdb2/tdb1_check.c b/ccan/tdb2/tdb1_check.c index d62a4b92..306cd7e0 100644 --- a/ccan/tdb2/tdb1_check.c +++ b/ccan/tdb2/tdb1_check.c @@ -322,7 +322,7 @@ size_t tdb1_dead_space(struct tdb1_context *tdb, tdb1_off_t off) return len; } -_PUBLIC_ int tdb1_check(struct tdb1_context *tdb, +int tdb1_check(struct tdb1_context *tdb, int (*check)(TDB1_DATA key, TDB1_DATA data, void *private_data), void *private_data) { diff --git a/ccan/tdb2/tdb1_hash.c b/ccan/tdb2/tdb1_hash.c index 8a33e8a8..a8dd0655 100644 --- a/ccan/tdb2/tdb1_hash.c +++ b/ccan/tdb2/tdb1_hash.c @@ -339,7 +339,7 @@ static uint32_t hashlittle( const void *key, size_t length ) return c; } -_PUBLIC_ unsigned int tdb1_jenkins_hash(TDB1_DATA *key) +unsigned int tdb1_jenkins_hash(TDB1_DATA *key) { return hashlittle(key->dptr, key->dsize); } diff --git a/ccan/tdb2/tdb1_lock.c b/ccan/tdb2/tdb1_lock.c index e355bfa6..ee6aaf74 100644 --- a/ccan/tdb2/tdb1_lock.c +++ b/ccan/tdb2/tdb1_lock.c @@ -626,50 +626,50 @@ int tdb1_allrecord_unlock(struct tdb1_context *tdb, int ltype, bool mark_lock) } /* lock entire database with write lock */ -_PUBLIC_ int tdb1_lockall(struct tdb1_context *tdb) +int tdb1_lockall(struct tdb1_context *tdb) { return tdb1_allrecord_lock(tdb, F_WRLCK, TDB1_LOCK_WAIT, false); } /* unlock entire database with write lock */ -_PUBLIC_ int tdb1_unlockall(struct tdb1_context *tdb) +int tdb1_unlockall(struct tdb1_context *tdb) { return tdb1_allrecord_unlock(tdb, F_WRLCK, false); } /* lock entire database with read lock */ -_PUBLIC_ int tdb1_lockall_read(struct tdb1_context *tdb) +int tdb1_lockall_read(struct tdb1_context *tdb) { return tdb1_allrecord_lock(tdb, F_RDLCK, TDB1_LOCK_WAIT, false); } /* unlock entire database with read lock */ -_PUBLIC_ int tdb1_unlockall_read(struct tdb1_context *tdb) +int tdb1_unlockall_read(struct tdb1_context *tdb) { return tdb1_allrecord_unlock(tdb, F_RDLCK, false); } /* lock/unlock one hash chain. This is meant to be used to reduce contention - it cannot guarantee how many records will be locked */ -_PUBLIC_ int tdb1_chainlock(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_chainlock(struct tdb1_context *tdb, TDB1_DATA key) { int ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK); return ret; } -_PUBLIC_ int tdb1_chainunlock(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_chainunlock(struct tdb1_context *tdb, TDB1_DATA key) { return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_WRLCK); } -_PUBLIC_ int tdb1_chainlock_read(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_chainlock_read(struct tdb1_context *tdb, TDB1_DATA key) { int ret; ret = tdb1_lock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK); return ret; } -_PUBLIC_ int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_chainunlock_read(struct tdb1_context *tdb, TDB1_DATA key) { return tdb1_unlock(tdb, TDB1_BUCKET(tdb->hash_fn(&key)), F_RDLCK); } diff --git a/ccan/tdb2/tdb1_open.c b/ccan/tdb2/tdb1_open.c index 7b548c1d..7c5100e3 100644 --- a/ccan/tdb2/tdb1_open.c +++ b/ccan/tdb2/tdb1_open.c @@ -129,7 +129,7 @@ static int tdb1_already_open(dev_t device, try to call tdb1_error or tdb1_errname, just do strerror(errno). @param name may be NULL for internal databases. */ -_PUBLIC_ struct tdb1_context *tdb1_open(const char *name, int hash_size, int tdb1_flags, +struct tdb1_context *tdb1_open(const char *name, int hash_size, int tdb1_flags, int open_flags, mode_t mode) { return tdb1_open_ex(name, hash_size, tdb1_flags, open_flags, mode, NULL, NULL); @@ -162,7 +162,7 @@ static bool check_header_hash(struct tdb1_context *tdb, return check_header_hash(tdb, false, m1, m2); } -_PUBLIC_ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags, +struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int tdb1_flags, int open_flags, mode_t mode, const struct tdb1_logging_context *log_ctx, tdb1_hash_func hash_fn) @@ -450,7 +450,7 @@ _PUBLIC_ struct tdb1_context *tdb1_open_ex(const char *name, int hash_size, int * Set the maximum number of dead records per hash chain */ -_PUBLIC_ void tdb1_set_max_dead(struct tdb1_context *tdb, int max_dead) +void tdb1_set_max_dead(struct tdb1_context *tdb, int max_dead) { tdb->max_dead_records = max_dead; } @@ -460,7 +460,7 @@ _PUBLIC_ void tdb1_set_max_dead(struct tdb1_context *tdb, int max_dead) * * @returns -1 for error; 0 for success. **/ -_PUBLIC_ int tdb1_close(struct tdb1_context *tdb) +int tdb1_close(struct tdb1_context *tdb) { struct tdb1_context **i; int ret = 0; diff --git a/ccan/tdb2/tdb1_private.h b/ccan/tdb2/tdb1_private.h index b34d4dd1..ae2888c0 100644 --- a/ccan/tdb2/tdb1_private.h +++ b/ccan/tdb2/tdb1_private.h @@ -45,11 +45,6 @@ #include #include #include - -#ifndef _PUBLIC_ -#define _PUBLIC_ -#endif - #else #include "replace.h" #include "system/filesys.h" diff --git a/ccan/tdb2/tdb1_summary.c b/ccan/tdb2/tdb1_summary.c index 61e18535..a2d2ae8f 100644 --- a/ccan/tdb2/tdb1_summary.c +++ b/ccan/tdb2/tdb1_summary.c @@ -84,7 +84,7 @@ static size_t get_hash_length(struct tdb1_context *tdb, unsigned int i) return count; } -_PUBLIC_ char *tdb1_summary(struct tdb1_context *tdb) +char *tdb1_summary(struct tdb1_context *tdb) { tdb1_off_t off, rec_off; struct tally freet, keys, data, dead, extra, hash, uncoal; diff --git a/ccan/tdb2/tdb1_tdb.c b/ccan/tdb2/tdb1_tdb.c index 93d2132f..cc7e580f 100644 --- a/ccan/tdb2/tdb1_tdb.c +++ b/ccan/tdb2/tdb1_tdb.c @@ -27,13 +27,13 @@ #include "tdb1_private.h" -_PUBLIC_ TDB1_DATA tdb1_null; +TDB1_DATA tdb1_null; /* non-blocking increment of the tdb sequence number if the tdb has been opened using the TDB1_SEQNUM flag */ -_PUBLIC_ void tdb1_increment_seqnum_nonblock(struct tdb1_context *tdb) +void tdb1_increment_seqnum_nonblock(struct tdb1_context *tdb) { tdb1_off_t seqnum=0; @@ -199,7 +199,7 @@ static TDB1_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) return ret; } -_PUBLIC_ TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) +TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) { TDB1_DATA ret = _tdb1_fetch(tdb, key); @@ -224,7 +224,7 @@ _PUBLIC_ TDB1_DATA tdb1_fetch(struct tdb1_context *tdb, TDB1_DATA key) * Return -1 if the record was not found. */ -_PUBLIC_ int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key, +int tdb1_parse_record(struct tdb1_context *tdb, TDB1_DATA key, int (*parser)(TDB1_DATA key, TDB1_DATA data, void *private_data), void *private_data) @@ -267,7 +267,7 @@ static int tdb1_exists_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha return 1; } -_PUBLIC_ int tdb1_exists(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_exists(struct tdb1_context *tdb, TDB1_DATA key) { uint32_t hash = tdb->hash_fn(&key); int ret; @@ -425,7 +425,7 @@ static int tdb1_delete_hash(struct tdb1_context *tdb, TDB1_DATA key, uint32_t ha return ret; } -_PUBLIC_ int tdb1_delete(struct tdb1_context *tdb, TDB1_DATA key) +int tdb1_delete(struct tdb1_context *tdb, TDB1_DATA key) { uint32_t hash = tdb->hash_fn(&key); int ret; @@ -594,7 +594,7 @@ static int _tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, return 0 on success, -1 on failure */ -_PUBLIC_ int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag) +int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, int flag) { uint32_t hash; int ret; @@ -615,7 +615,7 @@ _PUBLIC_ int tdb1_store(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA dbuf, } /* Append to an entry. Create if not exist. */ -_PUBLIC_ int tdb1_append(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA new_dbuf) +int tdb1_append(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA new_dbuf) { uint32_t hash; TDB1_DATA dbuf; @@ -665,7 +665,7 @@ failed: return the current logging function useful for external tdb routines that wish to log tdb errors */ -_PUBLIC_ tdb1_log_func tdb1_log_fn(struct tdb1_context *tdb) +tdb1_log_func tdb1_log_fn(struct tdb1_context *tdb) { return tdb->log.log_fn; } @@ -681,7 +681,7 @@ _PUBLIC_ tdb1_log_func tdb1_log_fn(struct tdb1_context *tdb) The aim of this sequence number is to allow for a very lightweight test of a possible tdb change. */ -_PUBLIC_ int tdb1_get_seqnum(struct tdb1_context *tdb) +int tdb1_get_seqnum(struct tdb1_context *tdb) { tdb1_off_t seqnum=0; @@ -689,7 +689,7 @@ _PUBLIC_ int tdb1_get_seqnum(struct tdb1_context *tdb) return seqnum; } -_PUBLIC_ int tdb1_hash_size(struct tdb1_context *tdb) +int tdb1_hash_size(struct tdb1_context *tdb) { return tdb->header.hash_size; } @@ -726,7 +726,7 @@ static int tdb1_free_region(struct tdb1_context *tdb, tdb1_off_t offset, ssize_t This code carefully steps around the recovery area, leaving it alone */ -_PUBLIC_ int tdb1_wipe_all(struct tdb1_context *tdb) +int tdb1_wipe_all(struct tdb1_context *tdb) { int i; tdb1_off_t offset = 0; @@ -832,7 +832,7 @@ static int repack_traverse(struct tdb1_context *tdb, TDB1_DATA key, TDB1_DATA da /* repack a tdb */ -_PUBLIC_ int tdb1_repack(struct tdb1_context *tdb) +int tdb1_repack(struct tdb1_context *tdb) { struct tdb1_context *tmp_db; struct traverse_state state; diff --git a/ccan/tdb2/tdb1_transaction.c b/ccan/tdb2/tdb1_transaction.c index 3358e57a..43e99024 100644 --- a/ccan/tdb2/tdb1_transaction.c +++ b/ccan/tdb2/tdb1_transaction.c @@ -527,7 +527,7 @@ fail_allrecord_lock: return -1; } -_PUBLIC_ int tdb1_transaction_start(struct tdb1_context *tdb) +int tdb1_transaction_start(struct tdb1_context *tdb) { return _tdb1_transaction_start(tdb, TDB1_LOCK_WAIT); } @@ -618,7 +618,7 @@ static int _tdb1_transaction_cancel(struct tdb1_context *tdb) /* cancel the current transaction */ -_PUBLIC_ int tdb1_transaction_cancel(struct tdb1_context *tdb) +int tdb1_transaction_cancel(struct tdb1_context *tdb) { return _tdb1_transaction_cancel(tdb); } @@ -983,7 +983,7 @@ static int _tdb1_transaction_prepare_commit(struct tdb1_context *tdb) /* prepare to commit the current transaction */ -_PUBLIC_ int tdb1_transaction_prepare_commit(struct tdb1_context *tdb) +int tdb1_transaction_prepare_commit(struct tdb1_context *tdb) { return _tdb1_transaction_prepare_commit(tdb); } @@ -1013,7 +1013,7 @@ static bool repack_worthwhile(struct tdb1_context *tdb) /* commit the current transaction */ -_PUBLIC_ int tdb1_transaction_commit(struct tdb1_context *tdb) +int tdb1_transaction_commit(struct tdb1_context *tdb) { const struct tdb1_methods *methods; int i; diff --git a/ccan/tdb2/tdb1_traverse.c b/ccan/tdb2/tdb1_traverse.c index 515beb1f..ba150127 100644 --- a/ccan/tdb2/tdb1_traverse.c +++ b/ccan/tdb2/tdb1_traverse.c @@ -208,7 +208,7 @@ out: /* a write style traverse - temporarily marks the db read only */ -_PUBLIC_ int tdb1_traverse_read(struct tdb1_context *tdb, +int tdb1_traverse_read(struct tdb1_context *tdb, tdb1_traverse_func fn, void *private_data) { struct tdb1_traverse_lock tl = { NULL, 0, 0, F_RDLCK }; @@ -236,7 +236,7 @@ _PUBLIC_ int tdb1_traverse_read(struct tdb1_context *tdb, WARNING: The data buffer given to the callback fn does NOT meet the alignment restrictions malloc gives you. */ -_PUBLIC_ int tdb1_traverse(struct tdb1_context *tdb, +int tdb1_traverse(struct tdb1_context *tdb, tdb1_traverse_func fn, void *private_data) { struct tdb1_traverse_lock tl = { NULL, 0, 0, F_WRLCK }; @@ -261,7 +261,7 @@ _PUBLIC_ int tdb1_traverse(struct tdb1_context *tdb, /* find the first entry in the database and return its key */ -_PUBLIC_ TDB1_DATA tdb1_firstkey(struct tdb1_context *tdb) +TDB1_DATA tdb1_firstkey(struct tdb1_context *tdb) { TDB1_DATA key; struct tdb1_record rec; @@ -289,7 +289,7 @@ _PUBLIC_ TDB1_DATA tdb1_firstkey(struct tdb1_context *tdb) } /* find the next entry in the database, returning its key */ -_PUBLIC_ TDB1_DATA tdb1_nextkey(struct tdb1_context *tdb, TDB1_DATA oldkey) +TDB1_DATA tdb1_nextkey(struct tdb1_context *tdb, TDB1_DATA oldkey) { uint32_t oldhash; TDB1_DATA key = tdb1_null; -- 2.39.2