summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/block/block_ext.c14
-rw-r--r--src/block/block_slvg.c12
-rw-r--r--src/btree/bt_cursor.c32
-rw-r--r--src/btree/bt_delete.c8
-rw-r--r--src/btree/bt_ovfl.c12
-rw-r--r--src/btree/bt_split.c10
-rw-r--r--src/cache/cache_las.c2
-rw-r--r--src/evict/evict_lru.c8
-rw-r--r--src/include/bitstring.i4
-rw-r--r--src/include/btree.i78
-rw-r--r--src/include/cache.i8
-rw-r--r--src/include/extern.h10
-rw-r--r--src/include/gcc.h4
-rw-r--r--src/include/lint.h12
-rw-r--r--src/include/msvc.h4
-rw-r--r--src/include/txn.i32
-rw-r--r--src/include/wt_internal.h1
-rw-r--r--src/lsm/lsm_cursor.c2
-rw-r--r--src/meta/meta_table.c10
-rw-r--r--src/os_posix/os_path.c4
-rw-r--r--src/os_win/os_path.c4
-rw-r--r--src/reconcile/rec_write.c30
-rw-r--r--src/support/pow.c2
23 files changed, 152 insertions, 151 deletions
diff --git a/src/block/block_ext.c b/src/block/block_ext.c
index cdef1682faf..018f6a20164 100644
--- a/src/block/block_ext.c
+++ b/src/block/block_ext.c
@@ -86,7 +86,7 @@ __block_off_srch(WT_EXT **head, wt_off_t off, WT_EXT ***stack, int skip_off)
* __block_first_srch --
* Search the skiplist for the first available slot.
*/
-static inline int
+static inline bool
__block_first_srch(WT_EXT **head, wt_off_t size, WT_EXT ***stack)
{
WT_EXT *ext;
@@ -99,11 +99,11 @@ __block_first_srch(WT_EXT **head, wt_off_t size, WT_EXT ***stack)
if (ext->size >= size)
break;
if (ext == NULL)
- return (0);
+ return (false);
/* Build a stack for the offset we want. */
__block_off_srch(head, ext->off, stack, 0);
- return (1);
+ return (true);
}
/*
@@ -251,7 +251,7 @@ __block_off_insert(
* Return if any part of a specified range appears on a specified extent
* list.
*/
-static int
+static bool
__block_off_match(WT_EXTLIST *el, wt_off_t off, wt_off_t size)
{
WT_EXT *before, *after;
@@ -261,10 +261,10 @@ __block_off_match(WT_EXTLIST *el, wt_off_t off, wt_off_t size)
/* If "before" or "after" overlaps, we have a winner. */
if (before != NULL && before->off + before->size > off)
- return (1);
+ return (true);
if (after != NULL && off + size > after->off)
- return (1);
- return (0);
+ return (true);
+ return (false);
}
/*
diff --git a/src/block/block_slvg.c b/src/block/block_slvg.c
index c78a6c39942..641bb8a42f7 100644
--- a/src/block/block_slvg.c
+++ b/src/block/block_slvg.c
@@ -73,19 +73,19 @@ __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block)
* __wt_block_offset_invalid --
* Return if the block offset is insane.
*/
-int
+bool
__wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size)
{
if (size == 0) /* < minimum page size */
- return (1);
+ return (true);
if (size % block->allocsize != 0) /* not allocation-size units */
- return (1);
+ return (true);
if (size > WT_BTREE_PAGE_SIZE_MAX) /* > maximum page size */
- return (1);
+ return (true);
/* past end-of-file */
if (offset + (wt_off_t)size > block->fh->size)
- return (1);
- return (0);
+ return (true);
+ return (false);
}
/*
diff --git a/src/btree/bt_cursor.c b/src/btree/bt_cursor.c
index ecb02941114..458a1985e28 100644
--- a/src/btree/bt_cursor.c
+++ b/src/btree/bt_cursor.c
@@ -70,7 +70,7 @@ __cursor_fix_implicit(WT_BTREE *btree, WT_CURSOR_BTREE *cbt)
* __cursor_valid --
* Return if the cursor references an valid key/value pair.
*/
-static inline int
+static inline bool
__cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
{
WT_BTREE *btree;
@@ -133,10 +133,10 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
if (cbt->ins != NULL &&
(upd = __wt_txn_read(session, cbt->ins->upd)) != NULL) {
if (WT_UPDATE_DELETED_ISSET(upd))
- return (0);
+ return (false);
if (updp != NULL)
*updp = upd;
- return (1);
+ return (true);
}
/*
@@ -155,7 +155,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
* keys, check for retrieval past the end of the page.
*/
if (cbt->recno >= page->pg_fix_recno + page->pg_fix_entries)
- return (0);
+ return (false);
/*
* Updates aren't stored on the page, an update would have
@@ -170,7 +170,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
* "slots", check if search returned a valid slot.
*/
if (cbt->slot >= page->pg_var_entries)
- return (0);
+ return (false);
/*
* Updates aren't stored on the page, an update would have
@@ -181,7 +181,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
cip = &page->pg_var_d[cbt->slot];
if ((cell = WT_COL_PTR(page, cip)) == NULL ||
__wt_cell_type(cell) == WT_CELL_DEL)
- return (0);
+ return (false);
break;
case BTREE_ROW:
/*
@@ -189,7 +189,7 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
* key as an on-page object, we're done.
*/
if (cbt->ins != NULL)
- return (0);
+ return (false);
/*
* Check if searched returned a valid slot (the failure mode is
@@ -198,19 +198,19 @@ __cursor_valid(WT_CURSOR_BTREE *cbt, WT_UPDATE **updp)
* mirrors the column-store test).
*/
if (cbt->slot >= page->pg_row_entries)
- return (0);
+ return (false);
/* Updates are stored on the page, check for a delete. */
if (page->pg_row_upd != NULL && (upd = __wt_txn_read(
session, page->pg_row_upd[cbt->slot])) != NULL) {
if (WT_UPDATE_DELETED_ISSET(upd))
- return (0);
+ return (false);
if (updp != NULL)
*updp = upd;
}
break;
}
- return (1);
+ return (true);
}
/*
@@ -911,7 +911,7 @@ __wt_btcur_compare(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *cmpp)
* __cursor_equals --
* Return if two cursors reference the same row.
*/
-static inline int
+static inline bool
__cursor_equals(WT_CURSOR_BTREE *a, WT_CURSOR_BTREE *b)
{
switch (a->btree->type) {
@@ -923,21 +923,21 @@ __cursor_equals(WT_CURSOR_BTREE *a, WT_CURSOR_BTREE *b)
* one being returned to the application.
*/
if (((WT_CURSOR *)a)->recno == ((WT_CURSOR *)b)->recno)
- return (1);
+ return (true);
break;
case BTREE_ROW:
if (a->ref != b->ref)
- return (0);
+ return (false);
if (a->ins != NULL || b->ins != NULL) {
if (a->ins == b->ins)
- return (1);
+ return (true);
break;
}
if (a->slot == b->slot)
- return (1);
+ return (true);
break;
}
- return (0);
+ return (false);
}
/*
diff --git a/src/btree/bt_delete.c b/src/btree/bt_delete.c
index b0d8ce850ae..0d512b13c5e 100644
--- a/src/btree/bt_delete.c
+++ b/src/btree/bt_delete.c
@@ -216,10 +216,10 @@ __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref)
* __wt_delete_page_skip --
* If iterating a cursor, skip deleted pages that are visible to us.
*/
-int
+bool
__wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref)
{
- int skip;
+ bool skip;
/*
* Deleted pages come from two sources: either it's a fast-delete as
@@ -240,10 +240,10 @@ __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref)
* the structure, just to be safe.
*/
if (ref->page_del == NULL)
- return (1);
+ return (true);
if (!__wt_atomic_casv32(&ref->state, WT_REF_DELETED, WT_REF_LOCKED))
- return (0);
+ return (false);
skip = (ref->page_del == NULL ||
__wt_txn_visible(session, ref->page_del->txnid));
diff --git a/src/btree/bt_ovfl.c b/src/btree/bt_ovfl.c
index d8456c5b61f..7104e702418 100644
--- a/src/btree/bt_ovfl.c
+++ b/src/btree/bt_ovfl.c
@@ -79,7 +79,7 @@ __wt_ovfl_read(WT_SESSION_IMPL *session,
* __ovfl_cache_col_visible --
* column-store: check for a globally visible update.
*/
-static int
+static bool
__ovfl_cache_col_visible(
WT_SESSION_IMPL *session, WT_UPDATE *upd, WT_CELL_UNPACK *unpack)
{
@@ -99,15 +99,15 @@ __ovfl_cache_col_visible(
if (__wt_cell_rle(unpack) == 1 &&
upd != NULL && /* Sanity: upd should always be set. */
__wt_txn_visible_all(session, upd->txnid))
- return (1);
- return (0);
+ return (true);
+ return (false);
}
/*
* __ovfl_cache_row_visible --
* row-store: check for a globally visible update.
*/
-static int
+static bool
__ovfl_cache_row_visible(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW *rip)
{
WT_UPDATE *upd;
@@ -115,9 +115,9 @@ __ovfl_cache_row_visible(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW *rip)
/* Check to see if there's a globally visible update. */
for (upd = WT_ROW_UPDATE(page, rip); upd != NULL; upd = upd->next)
if (__wt_txn_visible_all(session, upd->txnid))
- return (1);
+ return (true);
- return (0);
+ return (false);
}
/*
diff --git a/src/btree/bt_split.c b/src/btree/bt_split.c
index 58d90c70c51..8744ddfe497 100644
--- a/src/btree/bt_split.c
+++ b/src/btree/bt_split.c
@@ -173,7 +173,7 @@ __split_safe_free(WT_SESSION_IMPL *session,
* __split_should_deepen --
* Return if we should deepen the tree.
*/
-static int
+static bool
__split_should_deepen(WT_SESSION_IMPL *session, WT_REF *ref)
{
WT_BTREE *btree;
@@ -196,7 +196,7 @@ __split_should_deepen(WT_SESSION_IMPL *session, WT_REF *ref)
* pressure on the cache).
*/
if (page->memory_footprint < btree->maxmempage)
- return (0);
+ return (false);
/*
* Ensure the page has enough entries to make it worth splitting and
@@ -204,7 +204,7 @@ __split_should_deepen(WT_SESSION_IMPL *session, WT_REF *ref)
* splitting won't help).
*/
if (pindex->entries > btree->split_deepen_min_child)
- return (1);
+ return (true);
/*
* Don't allow a single page to put pressure on cache usage. The root
@@ -216,9 +216,9 @@ __split_should_deepen(WT_SESSION_IMPL *session, WT_REF *ref)
if (pindex->entries >= 100 &&
(__wt_ref_is_root(ref) ||
page->memory_footprint >= S2C(session)->cache_size / 4))
- return (1);
+ return (true);
- return (0);
+ return (false);
}
/*
diff --git a/src/cache/cache_las.c b/src/cache/cache_las.c
index 987c2b76ddd..da54d9cf4aa 100644
--- a/src/cache/cache_las.c
+++ b/src/cache/cache_las.c
@@ -169,7 +169,7 @@ __wt_las_set_written(WT_SESSION_IMPL *session)
* __wt_las_is_written --
* Return if the lookaside table has been written.
*/
-int
+bool
__wt_las_is_written(WT_SESSION_IMPL *session)
{
return (S2C(session)->las_written);
diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c
index d9f9f89e059..b16621d1e6f 100644
--- a/src/evict/evict_lru.c
+++ b/src/evict/evict_lru.c
@@ -418,7 +418,7 @@ err: WT_PANIC_MSG(session, ret, "cache eviction worker error");
* __evict_update_work --
* Configure eviction work state.
*/
-static int
+static bool
__evict_update_work(WT_SESSION_IMPL *session)
{
WT_CACHE *cache;
@@ -432,7 +432,7 @@ __evict_update_work(WT_SESSION_IMPL *session)
cache->state = 0;
if (!F_ISSET(conn, WT_CONN_EVICTION_RUN))
- return (0);
+ return (false);
/*
* Page eviction overrides the dirty target and other types of eviction,
@@ -466,11 +466,11 @@ __evict_update_work(WT_SESSION_IMPL *session)
F_CLR(cache, WT_CACHE_WOULD_BLOCK);
goto done;
}
- return (0);
+ return (false);
done: if (F_ISSET(cache, WT_CACHE_STUCK))
FLD_SET(cache->state, WT_EVICT_PASS_AGGRESSIVE);
- return (1);
+ return (true);
}
/*
diff --git a/src/include/bitstring.i b/src/include/bitstring.i
index c548c12761d..35abb0143ce 100644
--- a/src/include/bitstring.i
+++ b/src/include/bitstring.i
@@ -84,10 +84,10 @@ __bit_alloc(WT_SESSION_IMPL *session, uint64_t nbits, void *retp)
* __bit_test --
* Test one bit in name.
*/
-static inline int
+static inline bool
__bit_test(uint8_t *bitf, uint64_t bit)
{
- return (bitf[__bit_byte(bit)] & __bit_mask(bit) ? 1 : 0);
+ return (bitf[__bit_byte(bit)] & __bit_mask(bit));
}
/*
diff --git a/src/include/btree.i b/src/include/btree.i
index 9d63c797833..1de1d574821 100644
--- a/src/include/btree.i
+++ b/src/include/btree.i
@@ -10,17 +10,17 @@
* __wt_ref_is_root --
* Return if the page reference is for the root page.
*/
-static inline int
+static inline bool
__wt_ref_is_root(WT_REF *ref)
{
- return (ref->home == NULL ? 1 : 0);
+ return (ref->home == NULL);
}
/*
* __wt_page_is_empty --
* Return if the page is empty.
*/
-static inline int
+static inline bool
__wt_page_is_empty(WT_PAGE *page)
{
return (page->modify != NULL &&
@@ -31,10 +31,10 @@ __wt_page_is_empty(WT_PAGE *page)
* __wt_page_is_modified --
* Return if the page is dirty.
*/
-static inline int
+static inline bool
__wt_page_is_modified(WT_PAGE *page)
{
- return (page->modify != NULL && page->modify->write_gen != 0 ? 1 : 0);
+ return (page->modify != NULL && page->modify->write_gen != 0);
}
/*
@@ -458,7 +458,7 @@ __wt_page_parent_modify_set(
* __wt_off_page --
* Return if a pointer references off-page data.
*/
-static inline int
+static inline bool
__wt_off_page(WT_PAGE *page, const void *p)
{
/*
@@ -574,7 +574,7 @@ __wt_ref_key_clear(WT_REF *ref)
* had without unpacking a cell, and information about the cell, if the key
* isn't cheaply available.
*/
-static inline int
+static inline bool
__wt_row_leaf_key_info(WT_PAGE *page, void *copy,
WT_IKEY **ikeyp, WT_CELL **cellp, void *datap, size_t *sizep)
{
@@ -665,7 +665,7 @@ __wt_row_leaf_key_info(WT_PAGE *page, void *copy,
if (cellp != NULL)
*cellp =
WT_PAGE_REF_OFFSET(page, WT_CELL_DECODE_OFFSET(v));
- return (0);
+ return (false);
case WT_K_FLAG:
/* Encoded key: no instantiated key, no cell. */
if (cellp != NULL)
@@ -676,9 +676,9 @@ __wt_row_leaf_key_info(WT_PAGE *page, void *copy,
*(void **)datap =
WT_PAGE_REF_OFFSET(page, WT_K_DECODE_KEY_OFFSET(v));
*sizep = WT_K_DECODE_KEY_LEN(v);
- return (1);
+ return (true);
}
- return (0);
+ return (false);
case WT_KV_FLAG:
/* Encoded key/value pair: no instantiated key, no cell. */
if (cellp != NULL)
@@ -689,9 +689,9 @@ __wt_row_leaf_key_info(WT_PAGE *page, void *copy,
*(void **)datap = WT_PAGE_REF_OFFSET(
page, WT_KV_DECODE_KEY_OFFSET(v));
*sizep = WT_KV_DECODE_KEY_LEN(v);
- return (1);
+ return (true);
}
- return (0);
+ return (false);
}
@@ -704,9 +704,9 @@ __wt_row_leaf_key_info(WT_PAGE *page, void *copy,
if (datap != NULL) {
*(void **)datap = WT_IKEY_DATA(ikey);
*sizep = ikey->size;
- return (1);
+ return (true);
}
- return (0);
+ return (false);
}
/*
@@ -894,7 +894,7 @@ __wt_row_leaf_value_cell(WT_PAGE *page, WT_ROW *rip, WT_CELL_UNPACK *kpack)
* __wt_row_leaf_value --
* Return the value for a row-store leaf page encoded key/value pair.
*/
-static inline int
+static inline bool
__wt_row_leaf_value(WT_PAGE *page, WT_ROW *rip, WT_ITEM *value)
{
uintptr_t v;
@@ -910,9 +910,9 @@ __wt_row_leaf_value(WT_PAGE *page, WT_ROW *rip, WT_ITEM *value)
value->data =
WT_PAGE_REF_OFFSET(page, WT_KV_DECODE_VALUE_OFFSET(v));
value->size = WT_KV_DECODE_VALUE_LEN(v);
- return (1);
+ return (true);
}
- return (0);
+ return (false);
}
/*
@@ -971,7 +971,7 @@ __wt_ref_info(WT_SESSION_IMPL *session,
* __wt_page_can_split --
* Check whether a page can be split in memory.
*/
-static inline int
+static inline bool
__wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page)
{
WT_BTREE *btree;
@@ -986,7 +986,7 @@ __wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page)
* of the page could continually split without benefit.
*/
if (F_ISSET_ATOMIC(page, WT_PAGE_SPLIT_INSERT))
- return (0);
+ return (false);
/*
* Check for pages with append-only workloads. A common application
@@ -1000,11 +1000,11 @@ __wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page)
if (page->type != WT_PAGE_ROW_LEAF ||
page->memory_footprint < btree->maxmempage ||
!__wt_page_is_modified(page))
- return (0);
+ return (false);
/* Don't split a page that is pending a multi-block split. */
if (F_ISSET(page->modify, WT_PM_REC_MULTIBLOCK))
- return (0);
+ return (false);
/*
* There is no point splitting if the list is small, no deep items is
@@ -1018,22 +1018,22 @@ __wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page)
WT_ROW_INSERT_SMALLEST(page) :
WT_ROW_INSERT_SLOT(page, page->pg_row_entries - 1);
if (ins_head == NULL)
- return (0);
+ return (false);
for (i = 0, ins = ins_head->head[WT_MIN_SPLIT_SKIPLIST_DEPTH];
ins != NULL; ins = ins->next[WT_MIN_SPLIT_SKIPLIST_DEPTH])
if (++i == 4) {
WT_STAT_FAST_CONN_INCR(session, cache_inmem_splittable);
WT_STAT_FAST_DATA_INCR(session, cache_inmem_splittable);
- return (1);
+ return (true);
}
- return (0);
+ return (false);
}
/*
* __wt_page_can_evict --
* Check whether a page can be evicted.
*/
-static inline int
+static inline bool
__wt_page_can_evict(WT_SESSION_IMPL *session,
WT_PAGE *page, int check_splits, int *inmem_splitp)
{
@@ -1049,7 +1049,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session,
/* Pages that have never been modified can always be evicted. */
if (mod == NULL)
- return (1);
+ return (true);
/*
* Check for in-memory splits before other eviction tests. If the page
@@ -1060,7 +1060,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session,
if (__wt_page_can_split(session, page)) {
if (inmem_splitp != NULL)
*inmem_splitp = 1;
- return (1);
+ return (true);
}
/*
@@ -1074,7 +1074,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session,
*/
if (check_splits && WT_PAGE_IS_INTERNAL(page) &&
!__wt_txn_visible_all(session, mod->mod_split_txn))
- return (0);
+ return (false);
/*
* If the file is being checkpointed, we can't evict dirty pages:
@@ -1087,7 +1087,7 @@ __wt_page_can_evict(WT_SESSION_IMPL *session,
F_ISSET(mod, WT_PM_REC_MULTIBLOCK))) {
WT_STAT_FAST_CONN_INCR(session, cache_eviction_checkpoint);
WT_STAT_FAST_DATA_INCR(session, cache_eviction_checkpoint);
- return (0);
+ return (true);
}
/*
@@ -1099,10 +1099,10 @@ __wt_page_can_evict(WT_SESSION_IMPL *session,
if (check_splits) {
txn_global = &S2C(session)->txn_global;
if (WT_TXNID_LE(txn_global->oldest_id, mod->inmem_split_txn))
- return (0);
+ return (false);
}
- return (1);
+ return (true);
}
/*
@@ -1308,13 +1308,13 @@ __wt_skip_choose_depth(WT_SESSION_IMPL *session)
}
/*
- * __wt_btree_lsm_size --
+ * __wt_btree_lsm_over_size --
* Return if the size of an in-memory tree with a single leaf page is over
* a specified maximum. If called on anything other than a simple tree with a
* single leaf page, returns true so our LSM caller will switch to a new tree.
*/
-static inline int
-__wt_btree_lsm_size(WT_SESSION_IMPL *session, uint64_t maxsize)
+static inline bool
+__wt_btree_lsm_over_size(WT_SESSION_IMPL *session, uint64_t maxsize)
{
WT_BTREE *btree;
WT_PAGE *child, *root;
@@ -1326,20 +1326,20 @@ __wt_btree_lsm_size(WT_SESSION_IMPL *session, uint64_t maxsize)
/* Check for a non-existent tree. */
if (root == NULL)
- return (0);
+ return (false);
/* A tree that can be evicted always requires a switch. */
if (!F_ISSET(btree, WT_BTREE_NO_EVICTION))
- return (1);
+ return (true);
/* Check for a tree with a single leaf page. */
WT_INTL_INDEX_GET(session, root, pindex);
if (pindex->entries != 1) /* > 1 child page, switch */
- return (1);
+ return (true);
first = pindex->index[0];
if (first->state != WT_REF_MEM) /* no child page, ignore */
- return (0);
+ return (false);
/*
* We're reaching down into the page without a hazard pointer, but
@@ -1348,7 +1348,7 @@ __wt_btree_lsm_size(WT_SESSION_IMPL *session, uint64_t maxsize)
*/
child = first->page;
if (child->type != WT_PAGE_ROW_LEAF) /* not a single leaf page */
- return (1);
+ return (true);
return (child->memory_footprint > maxsize);
}
diff --git a/src/include/cache.i b/src/include/cache.i
index aa46fdd6d20..bc33f82d927 100644
--- a/src/include/cache.i
+++ b/src/include/cache.i
@@ -158,7 +158,7 @@ __wt_eviction_dirty_target(WT_SESSION_IMPL *session)
* Return if an application thread should do eviction, and the cache full
* percentage as a side-effect.
*/
-static inline int
+static inline bool
__wt_eviction_needed(WT_SESSION_IMPL *session, u_int *pct_fullp)
{
WT_CONNECTION_IMPL *conn;
@@ -184,13 +184,13 @@ __wt_eviction_needed(WT_SESSION_IMPL *session, u_int *pct_fullp)
if (pct_fullp != NULL)
*pct_fullp = pct_full;
if (pct_full > cache->eviction_trigger)
- return (1);
+ return (true);
/* Return if there are too many dirty bytes in cache. */
if (__wt_cache_dirty_inuse(cache) >
(cache->eviction_dirty_trigger * bytes_max) / 100)
- return (1);
- return (0);
+ return (true);
+ return (false);
}
/*
diff --git a/src/include/extern.h b/src/include/extern.h
index 399930e125c..7957b5ab01c 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -63,7 +63,7 @@ extern int __wt_block_ext_prealloc(WT_SESSION_IMPL *session, u_int max);
extern int __wt_block_ext_discard(WT_SESSION_IMPL *session, u_int max);
extern int __wt_block_salvage_start(WT_SESSION_IMPL *session, WT_BLOCK *block);
extern int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block);
-extern int __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size);
+extern bool __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size);
extern int __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, int *eofp);
extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, int valid);
extern int __wt_block_verify_start(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]);
@@ -116,7 +116,7 @@ extern int __wt_debug_tree(WT_SESSION_IMPL *session, WT_PAGE *page, const char *
extern int __wt_debug_page(WT_SESSION_IMPL *session, WT_PAGE *page, const char *ofile);
extern int __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp);
extern void __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref);
-extern int __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref);
+extern bool __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref);
extern int __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref);
extern void __wt_ref_out(WT_SESSION_IMPL *session, WT_REF *ref);
extern void __wt_page_out(WT_SESSION_IMPL *session, WT_PAGE **pagep);
@@ -185,7 +185,7 @@ extern void __wt_las_stats_update(WT_SESSION_IMPL *session);
extern int __wt_las_create(WT_SESSION_IMPL *session);
extern int __wt_las_destroy(WT_SESSION_IMPL *session);
extern void __wt_las_set_written(WT_SESSION_IMPL *session);
-extern int __wt_las_is_written(WT_SESSION_IMPL *session);
+extern bool __wt_las_is_written(WT_SESSION_IMPL *session);
extern int __wt_las_cursor( WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t *session_flags);
extern int __wt_las_cursor_close( WT_SESSION_IMPL *session, WT_CURSOR **cursorp, uint32_t session_flags);
extern int __wt_las_sweep(WT_SESSION_IMPL *session);
@@ -500,7 +500,7 @@ extern int __wt_rwlock_destroy(WT_SESSION_IMPL *session, WT_RWLOCK **rwlockp);
extern int __wt_once(void (*init_routine)(void));
extern int __wt_open(WT_SESSION_IMPL *session, const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp);
extern int __wt_close(WT_SESSION_IMPL *session, WT_FH **fhp);
-extern int __wt_absolute_path(const char *path);
+extern bool __wt_absolute_path(const char *path);
extern const char *__wt_path_separator(void);
extern int __wt_has_priv(void);
extern int __wt_remove(WT_SESSION_IMPL *session, const char *name);
@@ -652,7 +652,7 @@ extern int __wt_huffman_decode(WT_SESSION_IMPL *session, void *huffman_arg, cons
extern uint32_t __wt_nlpo2_round(uint32_t v);
extern uint32_t __wt_nlpo2(uint32_t v);
extern uint32_t __wt_log2_int(uint32_t n);
-extern int __wt_ispo2(uint32_t v);
+extern bool __wt_ispo2(uint32_t v);
extern uint32_t __wt_rduppo2(uint32_t n, uint32_t po2);
extern void __wt_random_init(WT_RAND_STATE volatile *rnd_state);
extern uint32_t __wt_random(WT_RAND_STATE volatile *rnd_state);
diff --git a/src/include/gcc.h b/src/include/gcc.h
index 3472985745e..01e33792d73 100644
--- a/src/include/gcc.h
+++ b/src/include/gcc.h
@@ -123,7 +123,7 @@ __wt_atomic_sub##name(type *vp, type v) \
{ \
return (__sync_sub_and_fetch(vp, v)); \
} \
-static inline int \
+static inline bool \
__wt_atomic_cas##name(type *vp, type old, type new) \
{ \
return (WT_ATOMIC_CAS(vp, old, new)); \
@@ -145,7 +145,7 @@ WT_ATOMIC_FUNC(size, size_t, size_t)
* __wt_atomic_cas_ptr --
* Pointer compare and swap.
*/
-static inline int
+static inline bool
__wt_atomic_cas_ptr(void *vp, void *old, void *new)
{
return (WT_ATOMIC_CAS((void **)vp, old, new));
diff --git a/src/include/lint.h b/src/include/lint.h
index eba4a1c3b3f..f288fb98683 100644
--- a/src/include/lint.h
+++ b/src/include/lint.h
@@ -49,14 +49,14 @@ __wt_atomic_sub##name(type *vp, type v) \
*vp -= v; \
return (*vp); \
} \
-static inline int \
+static inline bool \
__wt_atomic_cas##name(type *vp, type old, type new) \
{ \
if (*vp == old) { \
*vp = new; \
- return (1); \
+ return (true); \
} \
- return (0); \
+ return (false); \
}
WT_ATOMIC_FUNC(8, uint8_t, uint8_t)
@@ -75,13 +75,13 @@ WT_ATOMIC_FUNC(size, size_t, size_t)
* __wt_atomic_cas_ptr --
* Pointer compare and swap.
*/
-static inline int
+static inline bool
__wt_atomic_cas_ptr(void *vp, void *old, void *new) {
if (*(void **)vp == old) {
*(void **)vp = new;
- return (1);
+ return (true);
}
- return (0);
+ return (false);
}
static inline void WT_BARRIER(void) { return; }
diff --git a/src/include/msvc.h b/src/include/msvc.h
index f4d8ba52fc1..8f5aa9abde8 100644
--- a/src/include/msvc.h
+++ b/src/include/msvc.h
@@ -52,7 +52,7 @@ __wt_atomic_sub##name(type *vp, type v) \
{ \
return (_InterlockedExchangeAdd ## s((t *)(vp), - (t)v) - (v)); \
} \
-static inline int \
+static inline bool \
__wt_atomic_cas##name(type *vp, type old, type new) \
{ \
return (_InterlockedCompareExchange ## s \
@@ -75,7 +75,7 @@ WT_ATOMIC_FUNC(size, size_t, size_t, 64, __int64)
* __wt_atomic_cas_ptr --
* Pointer compare and swap.
*/
-static inline int
+static inline bool
__wt_atomic_cas_ptr(void *vp, void *old, void *new)
{
return (_InterlockedCompareExchange64(
diff --git a/src/include/txn.i b/src/include/txn.i
index 6fe35c38850..2b42990f5e5 100644
--- a/src/include/txn.i
+++ b/src/include/txn.i
@@ -143,10 +143,10 @@ __wt_txn_oldest_id(WT_SESSION_IMPL *session)
* __wt_txn_committed --
* Return if a transaction has been committed.
*/
-static inline int
+static inline bool
__wt_txn_committed(WT_SESSION_IMPL *session, uint64_t id)
{
- return (WT_TXNID_LT(id, S2C(session)->txn_global.last_running) ? 1 : 0);
+ return (WT_TXNID_LT(id, S2C(session)->txn_global.last_running));
}
/*
@@ -155,7 +155,7 @@ __wt_txn_committed(WT_SESSION_IMPL *session, uint64_t id)
* all sessions in the system will see the transaction ID including the
* ID that belongs to a running checkpoint.
*/
-static inline int
+static inline bool
__wt_txn_visible_all(WT_SESSION_IMPL *session, uint64_t id)
{
uint64_t oldest_id;
@@ -169,21 +169,21 @@ __wt_txn_visible_all(WT_SESSION_IMPL *session, uint64_t id)
* __wt_txn_visible --
* Can the current transaction see the given ID?
*/
-static inline int
+static inline bool
__wt_txn_visible(WT_SESSION_IMPL *session, uint64_t id)
{
WT_TXN *txn;
- int found;
+ bool found;
txn = &session->txn;
/* Changes with no associated transaction are always visible. */
if (id == WT_TXN_NONE)
- return (1);
+ return (true);
/* Nobody sees the results of aborted transactions. */
if (id == WT_TXN_ABORTED)
- return (0);
+ return (false);
/*
* Read-uncommitted transactions see all other changes.
@@ -197,11 +197,11 @@ __wt_txn_visible(WT_SESSION_IMPL *session, uint64_t id)
*/
if (txn->isolation == WT_ISO_READ_UNCOMMITTED ||
session->dhandle == session->meta_dhandle)
- return (1);
+ return (true);
/* Transactions see their own changes. */
if (id == txn->id)
- return (1);
+ return (true);
/*
* WT_ISO_SNAPSHOT, WT_ISO_READ_COMMITTED: the ID is visible if it is
@@ -213,9 +213,9 @@ __wt_txn_visible(WT_SESSION_IMPL *session, uint64_t id)
* snapshot is empty.
*/
if (WT_TXNID_LE(txn->snap_max, id))
- return (0);
+ return (false);
if (txn->snapshot_count == 0 || WT_TXNID_LT(id, txn->snap_min))
- return (1);
+ return (true);
WT_BINARY_SEARCH(id, txn->snapshot, txn->snapshot_count, found);
return (!found);
@@ -269,7 +269,7 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[])
}
F_SET(txn, WT_TXN_RUNNING);
- return (0);
+ return (false);
}
/*
@@ -480,7 +480,7 @@ __wt_txn_cursor_op(WT_SESSION_IMPL *session)
* __wt_txn_am_oldest --
* Am I the oldest transaction in the system?
*/
-static inline int
+static inline bool
__wt_txn_am_oldest(WT_SESSION_IMPL *session)
{
WT_CONNECTION_IMPL *conn;
@@ -495,12 +495,12 @@ __wt_txn_am_oldest(WT_SESSION_IMPL *session)
txn_global = &conn->txn_global;
if (txn->id == WT_TXN_NONE)
- return (0);
+ return (false);
WT_ORDERED_READ(session_cnt, conn->session_cnt);
for (i = 0, s = txn_global->states; i < session_cnt; i++, s++)
if ((id = s->id) != WT_TXN_NONE && WT_TXNID_LT(id, txn->id))
- return (0);
+ return (false);
- return (1);
+ return (true);
}
diff --git a/src/include/wt_internal.h b/src/include/wt_internal.h
index 4ae12c594db..4d46a25b63c 100644
--- a/src/include/wt_internal.h
+++ b/src/include/wt_internal.h
@@ -41,6 +41,7 @@ extern "C" {
#else
#include <pthread.h>
#endif
+#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <stdint.h>
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c
index 674b9e6d3a8..6068bb6c559 100644
--- a/src/lsm/lsm_cursor.c
+++ b/src/lsm/lsm_cursor.c
@@ -134,7 +134,7 @@ __clsm_enter_update(WT_CURSOR_LSM *clsm)
if (have_primary) {
WT_ENTER_PAGE_INDEX(session);
WT_WITH_BTREE(session, ((WT_CURSOR_BTREE *)primary)->btree,
- ovfl = __wt_btree_lsm_size(session, hard_limit ?
+ ovfl = __wt_btree_lsm_over_size(session, hard_limit ?
2 * lsm_tree->chunk_size : lsm_tree->chunk_size));
WT_LEAVE_PAGE_INDEX(session);
diff --git a/src/meta/meta_table.c b/src/meta/meta_table.c
index 1792d722939..8255f004dab 100644
--- a/src/meta/meta_table.c
+++ b/src/meta/meta_table.c
@@ -12,22 +12,22 @@
* __metadata_turtle --
* Return if a key's value should be taken from the turtle file.
*/
-static int
+static bool
__metadata_turtle(const char *key)
{
switch (key[0]) {
case 'f':
if (strcmp(key, WT_METAFILE_URI) == 0)
- return (1);
+ return (true);
break;
case 'W':
if (strcmp(key, "WiredTiger version") == 0)
- return (1);
+ return (true);
if (strcmp(key, "WiredTiger version string") == 0)
- return (1);
+ return (true);
break;
}
- return (0);
+ return (false);
}
/*
diff --git a/src/os_posix/os_path.c b/src/os_posix/os_path.c
index 07b14b55b44..af28e1b3b56 100644
--- a/src/os_posix/os_path.c
+++ b/src/os_posix/os_path.c
@@ -12,10 +12,10 @@
* __wt_absolute_path --
* Return if a filename is an absolute path.
*/
-int
+bool
__wt_absolute_path(const char *path)
{
- return (path[0] == '/' ? 1 : 0);
+ return (path[0] == '/');
}
/*
diff --git a/src/os_win/os_path.c b/src/os_win/os_path.c
index 89f05e238c4..9d001e50571 100644
--- a/src/os_win/os_path.c
+++ b/src/os_win/os_path.c
@@ -12,7 +12,7 @@
* __wt_absolute_path --
* Return if a filename is an absolute path.
*/
-int
+bool
__wt_absolute_path(const char *path)
{
/*
@@ -21,7 +21,7 @@ __wt_absolute_path(const char *path)
*/
if (strlen(path) >= 3 && isalpha(path[0]) && path[1] == ':')
path += 2;
- return (path[0] == '/' || path[0] == '\\' ? 1 : 0);
+ return (path[0] == '/' || path[0] == '\\');
}
/*
diff --git a/src/reconcile/rec_write.c b/src/reconcile/rec_write.c
index 48f0eeb833d..cfd1377bba5 100644
--- a/src/reconcile/rec_write.c
+++ b/src/reconcile/rec_write.c
@@ -485,7 +485,7 @@ __wt_reconcile(WT_SESSION_IMPL *session,
* __rec_las_checkpoint_test --
* Return if the lookaside table is going to collide with a checkpoint.
*/
-static inline int
+static inline bool
__rec_las_checkpoint_test(WT_SESSION_IMPL *session, WT_RECONCILE *r)
{
WT_CONNECTION_IMPL *conn;
@@ -508,14 +508,14 @@ __rec_las_checkpoint_test(WT_SESSION_IMPL *session, WT_RECONCILE *r)
* most workloads.
*/
if (!F_ISSET(r, WT_EVICT_LOOKASIDE))
- return (0);
+ return (false);
if (F_ISSET(btree, WT_BTREE_NO_CHECKPOINT))
- return (0);
+ return (false);
if (r->orig_btree_checkpoint_gen == btree->checkpoint_gen &&
r->orig_txn_checkpoint_gen == conn->txn_global.checkpoint_gen &&
r->orig_btree_checkpoint_gen == r->orig_txn_checkpoint_gen)
- return (0);
- return (1);
+ return (false);
+ return (true);
}
/*
@@ -689,7 +689,7 @@ err: __wt_page_out(session, &next);
* __rec_raw_compression_config --
* Configure raw compression.
*/
-static inline int
+static inline bool
__rec_raw_compression_config(
WT_SESSION_IMPL *session, WT_PAGE *page, WT_SALVAGE_COOKIE *salvage)
{
@@ -700,11 +700,11 @@ __rec_raw_compression_config(
/* Check if raw compression configured. */
if (btree->compressor == NULL ||
btree->compressor->compress_raw == NULL)
- return (0);
+ return (false);
/* Only for row-store and variable-length column-store objects. */
if (page->type == WT_PAGE_COL_FIX)
- return (0);
+ return (false);
/*
* Raw compression cannot support dictionary compression. (Technically,
@@ -714,11 +714,11 @@ __rec_raw_compression_config(
* that seems an unlikely use case.)
*/
if (btree->dictionary != 0)
- return (0);
+ return (false);
/* Raw compression cannot support prefix compression. */
if (btree->prefix_compression != 0)
- return (0);
+ return (false);
/*
* Raw compression is also turned off during salvage: we can't allow
@@ -726,9 +726,9 @@ __rec_raw_compression_config(
* can't manipulate the page size.
*/
if (salvage != NULL)
- return (0);
+ return (false);
- return (1);
+ return (true);
}
/*
@@ -2054,7 +2054,7 @@ __rec_split_init(WT_SESSION_IMPL *session,
* __rec_is_checkpoint --
* Return if we're writing a checkpoint.
*/
-static int
+static bool
__rec_is_checkpoint(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_BOUNDARY *bnd)
{
WT_BTREE *btree;
@@ -2080,9 +2080,9 @@ __rec_is_checkpoint(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_BOUNDARY *bnd)
bnd->addr.addr = NULL;
bnd->addr.size = 0;
bnd->addr.type = 0;
- return (1);
+ return (true);
}
- return (0);
+ return (false);
}
/*
diff --git a/src/support/pow.c b/src/support/pow.c
index 8e42113a2ee..0f50bfe56a1 100644
--- a/src/support/pow.c
+++ b/src/support/pow.c
@@ -100,7 +100,7 @@ __wt_log2_int(uint32_t n)
* __wt_ispo2 --
* Return if a number is a power-of-two.
*/
-int
+bool
__wt_ispo2(uint32_t v)
{
/*