friend std::ostream& operator<<(std::ostream& out, const CompatSet& compat);
FeatureSet() : mask(1), names() {}
void insert(const Feature& f) {
- assert(f.id > 0);
- assert(f.id < 64);
+ ceph_assert(f.id > 0);
+ ceph_assert(f.id < 64);
mask |= ((uint64_t)1<<f.id);
names[f.id] = f.name;
}
*/
std::string get_name(uint64_t const f) const {
std::map<uint64_t, std::string>::const_iterator i = names.find(f);
- assert(i != names.end());
+ ceph_assert(i != names.end());
return i->second;
}
void sub_finish(ContextType* sub, int r) {
lock.Lock();
#ifdef DEBUG_GATHER
- assert(waitfor.count(sub));
+ ceph_assert(waitfor.count(sub));
waitfor.erase(sub);
#endif
--sub_existing_count;
}
void set_finisher(ContextType *onfinish_) {
Mutex::Locker l(lock);
- assert(!onfinish);
+ ceph_assert(!onfinish);
onfinish = onfinish_;
}
void activate() {
lock.Lock();
- assert(activated == false);
+ ceph_assert(activated == false);
activated = true;
if (sub_existing_count != 0) {
lock.Unlock();
}
ContextType *new_sub() {
Mutex::Locker l(lock);
- assert(activated == false);
+ ceph_assert(activated == false);
sub_created_count++;
sub_existing_count++;
ContextType *s = new C_GatherSub(this);
}
~C_GatherBuilderBase() {
if (c_gather) {
- assert(activated); // Don't forget to activate your C_Gather!
+ ceph_assert(activated); // Don't forget to activate your C_Gather!
}
else {
delete finisher;
void activate() {
if (!c_gather)
return;
- assert(finisher != NULL);
+ ceph_assert(finisher != NULL);
activated = true;
c_gather->activate();
}
return (c_gather != NULL);
}
int num_subs_created() {
- assert(!activated);
+ ceph_assert(!activated);
if (c_gather == NULL)
return 0;
return c_gather->get_sub_created_count();
}
int num_subs_remaining() {
- assert(!activated);
+ ceph_assert(!activated);
if (c_gather == NULL)
return 0;
return c_gather->get_sub_existing_count();
// modifiers
void set_offset(unsigned o) {
+#ifdef __CEPH__
+ ceph_assert(raw_length() >= o);
+#else
assert(raw_length() >= o);
+#endif
_off = o;
}
void set_length(unsigned l) {
+#ifdef __CEPH__
+ ceph_assert(raw_length() >= l);
+#else
assert(raw_length() >= l);
+#endif
_len = l;
}
it++) {
len += (*it).length();
}
+#ifdef __CEPH__
+ ceph_assert(len == _len);
+#else
assert(len == _len);
+#endif // __CEPH__
#endif
return _len;
}
int write_fd_zero_copy(int fd) const;
template<typename VectorT>
void prepare_iov(VectorT *piov) const {
- assert(_buffers.size() <= IOV_MAX);
+ ceph_assert(_buffers.size() <= IOV_MAX);
piov->resize(_buffers.size());
unsigned n = 0;
for (auto& p : _buffers) {
}
iterator erase (iterator p) {
if (map) {
- assert(this == p.map);
+ ceph_assert(this == p.map);
auto it = map->erase(p.it);
if (map->empty()) {
free_internal();
}
iterator erase (iterator p) {
if (set) {
- assert(this == p.set);
+ ceph_assert(this == p.set);
auto it = set->erase(p.it);
if (set->empty()) {
free_internal();
#ifndef UTIL_BTREE_BTREE_H__
#define UTIL_BTREE_BTREE_H__
-#include <assert.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <string>
#include <utility>
+#include "include/assert.h"
+
namespace btree {
// Inside a btree method, if we just call swap(), it will choose the
// be a leaf.
bool is_root() const { return parent()->leaf(); }
void make_root() {
- assert(parent()->is_root());
+ ceph_assert(parent()->is_root());
fields_.parent = fields_.parent->parent();
}
}
void delete_internal_node(node_type *node) {
node->destroy();
- assert(node != root());
+ ceph_assert(node != root());
mutable_internal_allocator()->deallocate(
reinterpret_cast<char*>(node), sizeof(internal_fields));
}
// btree_node methods
template <typename P>
inline void btree_node<P>::insert_value(int i, const value_type &x) {
- assert(i <= count());
+ ceph_assert(i <= count());
value_init(count(), x);
for (int j = count(); j > i; --j) {
value_swap(j, this, j - 1);
template <typename P>
inline void btree_node<P>::remove_value(int i) {
if (!leaf()) {
- assert(child(i + 1)->count() == 0);
+ ceph_assert(child(i + 1)->count() == 0);
for (int j = i + 1; j < count(); ++j) {
*mutable_child(j) = child(j + 1);
child(j)->set_position(j);
template <typename P>
void btree_node<P>::rebalance_right_to_left(btree_node *src, int to_move) {
- assert(parent() == src->parent());
- assert(position() + 1 == src->position());
- assert(src->count() >= count());
- assert(to_move >= 1);
- assert(to_move <= src->count());
+ ceph_assert(parent() == src->parent());
+ ceph_assert(position() + 1 == src->position());
+ ceph_assert(src->count() >= count());
+ ceph_assert(to_move >= 1);
+ ceph_assert(to_move <= src->count());
// Make room in the left node for the new values.
for (int i = 0; i < to_move; ++i) {
set_child(1 + count() + i, src->child(i));
}
for (int i = 0; i <= src->count() - to_move; ++i) {
- assert(i + to_move <= src->max_count());
+ ceph_assert(i + to_move <= src->max_count());
src->set_child(i, src->child(i + to_move));
*src->mutable_child(i + to_move) = NULL;
}
template <typename P>
void btree_node<P>::rebalance_left_to_right(btree_node *dest, int to_move) {
- assert(parent() == dest->parent());
- assert(position() + 1 == dest->position());
- assert(count() >= dest->count());
- assert(to_move >= 1);
- assert(to_move <= count());
+ ceph_assert(parent() == dest->parent());
+ ceph_assert(position() + 1 == dest->position());
+ ceph_assert(count() >= dest->count());
+ ceph_assert(to_move >= 1);
+ ceph_assert(to_move <= count());
// Make room in the right node for the new values.
for (int i = 0; i < to_move; ++i) {
template <typename P>
void btree_node<P>::split(btree_node *dest, int insert_position) {
- assert(dest->count() == 0);
+ ceph_assert(dest->count() == 0);
// We bias the split based on the position being inserted. If we're
// inserting at the beginning of the left node then bias the split to put
dest->set_count(count() / 2);
}
set_count(count() - dest->count());
- assert(count() >= 1);
+ ceph_assert(count() >= 1);
// Move values from the left sibling to the right sibling.
for (int i = 0; i < dest->count(); ++i) {
if (!leaf()) {
for (int i = 0; i <= dest->count(); ++i) {
- assert(child(count() + i + 1) != NULL);
+ ceph_assert(child(count() + i + 1) != NULL);
dest->set_child(i, child(count() + i + 1));
*mutable_child(count() + i + 1) = NULL;
}
template <typename P>
void btree_node<P>::merge(btree_node *src) {
- assert(parent() == src->parent());
- assert(position() + 1 == src->position());
+ ceph_assert(parent() == src->parent());
+ ceph_assert(position() + 1 == src->position());
// Move the delimiting value to the left node.
value_init(count());
template <typename P>
void btree_node<P>::swap(btree_node *x) {
- assert(leaf() == x->leaf());
+ ceph_assert(leaf() == x->leaf());
// Swap the values.
for (int i = count(); i < x->count(); ++i) {
template <typename N, typename R, typename P>
void btree_iterator<N, R, P>::increment_slow() {
if (node->leaf()) {
- assert(position >= node->count());
+ ceph_assert(position >= node->count());
self_type save(*this);
while (position == node->count() && !node->is_root()) {
- assert(node->parent()->child(node->position()) == node);
+ ceph_assert(node->parent()->child(node->position()) == node);
position = node->position();
node = node->parent();
}
*this = save;
}
} else {
- assert(position < node->count());
+ ceph_assert(position < node->count());
node = node->child(position + 1);
while (!node->leaf()) {
node = node->child(0);
template <typename N, typename R, typename P>
void btree_iterator<N, R, P>::decrement_slow() {
if (node->leaf()) {
- assert(position <= -1);
+ ceph_assert(position <= -1);
self_type save(*this);
while (position < 0 && !node->is_root()) {
- assert(node->parent()->child(node->position()) == node);
+ ceph_assert(node->parent()->child(node->position()) == node);
position = node->position() - 1;
node = node->parent();
}
*this = save;
}
} else {
- assert(position >= 0);
+ ceph_assert(position >= 0);
node = node->child(position);
while (!node->leaf()) {
node = node->child(node->count());
// Deletion of a value on an internal node. Swap the key with the largest
// value of our left child. This is easy, we just decrement iter.
iterator tmp_iter(iter--);
- assert(iter.node->leaf());
- assert(!compare_keys(tmp_iter.key(), iter.key()));
+ ceph_assert(iter.node->leaf());
+ ceph_assert(!compare_keys(tmp_iter.key(), iter.key()));
iter.node->value_swap(iter.position, tmp_iter.node, tmp_iter.position);
internal_delete = true;
--*mutable_size();
template <typename P>
void btree<P>::verify() const {
if (root() != NULL) {
- assert(size() == internal_verify(root(), NULL, NULL));
- assert(leftmost() == (++const_iterator(root(), -1)).node);
- assert(rightmost() == (--const_iterator(root(), root()->count())).node);
- assert(leftmost()->leaf());
- assert(rightmost()->leaf());
+ ceph_assert(size() == internal_verify(root(), NULL, NULL));
+ ceph_assert(leftmost() == (++const_iterator(root(), -1)).node);
+ ceph_assert(rightmost() == (--const_iterator(root(), root()->count())).node);
+ ceph_assert(leftmost()->leaf());
+ ceph_assert(rightmost()->leaf());
} else {
- assert(size() == 0);
- assert(leftmost() == NULL);
- assert(rightmost() == NULL);
+ ceph_assert(size() == 0);
+ ceph_assert(leftmost() == NULL);
+ ceph_assert(rightmost() == NULL);
}
}
void btree<P>::rebalance_or_split(iterator *iter) {
node_type *&node = iter->node;
int &insert_position = iter->position;
- assert(node->count() == node->max_count());
+ ceph_assert(node->count() == node->max_count());
// First try to make room on the node by rebalancing.
node_type *parent = node->parent();
((left->count() + to_move) < left->max_count())) {
left->rebalance_right_to_left(node, to_move);
- assert(node->max_count() - node->count() == to_move);
+ ceph_assert(node->max_count() - node->count() == to_move);
insert_position = insert_position - to_move;
if (insert_position < 0) {
insert_position = insert_position + left->count() + 1;
node = left;
}
- assert(node->count() < node->max_count());
+ ceph_assert(node->count() < node->max_count());
return;
}
}
node = right;
}
- assert(node->count() < node->max_count());
+ ceph_assert(node->count() < node->max_count());
return;
}
}
parent = new_internal_root_node();
parent->set_child(0, root());
*mutable_root() = parent;
- assert(*mutable_rightmost() == parent->child(0));
+ ceph_assert(*mutable_rightmost() == parent->child(0));
} else {
// The root node is an internal node. We do not want to create a new root
// node because the root node is special and holds the size of the tree
}
// Deleted the last item on the root node, shrink the height of the tree.
if (root()->leaf()) {
- assert(size() == 0);
+ ceph_assert(size() == 0);
delete_leaf_node(root());
*mutable_root() = NULL;
} else {
if (iter.node->max_count() < kNodeValues) {
// Insertion into the root where the root is smaller that the full node
// size. Simply grow the size of the root node.
- assert(iter.node == root());
+ ceph_assert(iter.node == root());
iter.node = new_leaf_root_node(
std::min<int>(kNodeValues, 2 * iter.node->max_count()));
iter.node->swap(root());
template <typename P>
int btree<P>::internal_verify(
const node_type *node, const key_type *lo, const key_type *hi) const {
- assert(node->count() > 0);
- assert(node->count() <= node->max_count());
+ ceph_assert(node->count() > 0);
+ ceph_assert(node->count() <= node->max_count());
if (lo) {
- assert(!compare_keys(node->key(0), *lo));
+ ceph_assert(!compare_keys(node->key(0), *lo));
}
if (hi) {
- assert(!compare_keys(*hi, node->key(node->count() - 1)));
+ ceph_assert(!compare_keys(*hi, node->key(node->count() - 1)));
}
for (int i = 1; i < node->count(); ++i) {
- assert(!compare_keys(node->key(i), node->key(i - 1)));
+ ceph_assert(!compare_keys(node->key(i), node->key(i - 1)));
}
int count = node->count();
if (!node->leaf()) {
for (int i = 0; i <= node->count(); ++i) {
- assert(node->child(i) != NULL);
- assert(node->child(i)->parent() == node);
- assert(node->child(i)->position() == i);
+ ceph_assert(node->child(i) != NULL);
+ ceph_assert(node->child(i)->parent() == node);
+ ceph_assert(node->child(i)->position() == i);
count += internal_verify(
node->child(i),
(i == 0) ? lo : &node->key(i - 1),
uint32_t *struct_len) { \
const char *pos = p.get_pos(); \
char *end = *start_pos + *struct_len; \
- assert(pos <= end); \
+ ceph_assert(pos <= end); \
if (pos < end) { \
p.advance(end - pos); \
} \
item(T i=0) : _prev(this), _next(this) {}
~item() {
- assert(!is_on_list());
+ ceph_assert(!is_on_list());
}
item(const item& other) = delete;
bool remove_myself() {
if (_next == this) {
- assert(_prev == this);
+ ceph_assert(_prev == this);
return false;
}
_next->_prev = _prev;
}
void insert_after(item *other) {
- assert(other->empty());
+ ceph_assert(other->empty());
other->_prev = this;
other->_next = _next;
_next->_prev = other;
_next = other;
}
void insert_before(item *other) {
- assert(other->empty());
+ ceph_assert(other->empty());
other->_next = this;
other->_prev = _prev;
_prev->_next = other;
}
T get_item(size_t offset) {
- assert(offset);
+ ceph_assert(offset);
return (T)(((char *)this) - offset);
}
};
elist(size_t o) : _head(NULL), item_offset(o) {}
~elist() {
- assert(_head.empty());
+ ceph_assert(_head.empty());
}
bool empty() const {
}
T front(size_t o=0) {
- assert(!_head.empty());
+ ceph_assert(!_head.empty());
return _head._next->get_item(o ? o : item_offset);
}
T back(size_t o=0) {
- assert(!_head.empty());
+ ceph_assert(!_head.empty());
return _head._prev->get_item(o ? o : item_offset);
}
void pop_front() {
- assert(!empty());
+ ceph_assert(!empty());
_head._next->remove_myself();
}
void pop_back() {
- assert(!empty());
+ ceph_assert(!empty());
_head._prev->remove_myself();
}
iterator(item *h, size_t o, mode_t m) :
head(h), cur(h->_next), next(cur->_next), item_offset(o),
mode(m) {
- assert(item_offset > 0);
+ ceph_assert(item_offset > 0);
}
T operator*() {
return cur->get_item(item_offset);
}
iterator& operator++() {
- assert(cur);
- assert(cur != head);
+ ceph_assert(cur);
+ ceph_assert(cur != head);
if (mode == MAGIC) {
// if 'cur' appears to be valid, use that. otherwise,
// use cached 'next'.
{
auto p = bl.begin();
decode(o, p);
- assert(p.end());
+ ceph_assert(p.end());
}
// boost optional
const string& last_dentry() const {
if (bits.empty() && path.length() > 0) parse_bits();
- assert(!bits.empty());
+ ceph_assert(!bits.empty());
return bits[ bits.size()-1 ];
}
rebuild_path();
}
void append(const filepath& a) {
- assert(a.pure_relative());
+ ceph_assert(a.pure_relative());
for (unsigned i=0; i<a.depth(); i++)
push_dentry(a[i]);
}
bool contains(frag_t sub) const { return ceph_frag_contains_frag(_enc, sub._enc); }
bool is_root() const { return bits() == 0; }
frag_t parent() const {
- assert(bits() > 0);
+ ceph_assert(bits() > 0);
return frag_t(ceph_frag_parent(_enc));
}
// splitting
frag_t make_child(int i, int nb) const {
- assert(i < (1<<nb));
+ ceph_assert(i < (1<<nb));
return frag_t(ceph_frag_make_child(_enc, nb, i));
}
void split(int nb, std::list<frag_t>& fragments) const {
- assert(nb > 0);
+ ceph_assert(nb > 0);
unsigned nway = 1 << nb;
for (unsigned i=0; i<nway; i++)
fragments.push_back(make_child(i, nb));
bool is_left() const { return ceph_frag_is_left_child(_enc); }
bool is_right() const { return ceph_frag_is_right_child(_enc); }
frag_t get_sibling() const {
- assert(!is_root());
+ ceph_assert(!is_root());
return frag_t(ceph_frag_sibling(_enc));
}
bool is_leftmost() const { return ceph_frag_is_leftmost(_enc); }
bool is_rightmost() const { return ceph_frag_is_rightmost(_enc); }
frag_t next() const {
- assert(!is_rightmost());
+ ceph_assert(!is_rightmost());
return frag_t(ceph_frag_next(_enc));
}
frag_t operator[](unsigned v) const {
frag_t t;
while (1) {
- assert(t.contains(v));
+ ceph_assert(t.contains(v));
int nb = get_split(t);
// is this a leaf?
break;
}
}
- assert(i < nway);
+ ceph_assert(i < nway);
}
}
// ---------------
// modifiers
void split(frag_t x, int b, bool simplify=true) {
- assert(is_leaf(x));
+ ceph_assert(is_leaf(x));
_splits[x] = b;
if (simplify)
try_assimilate_children(get_branch_above(x));
}
void merge(frag_t x, int b, bool simplify=true) {
- assert(!is_leaf(x));
- assert(_splits[x] == b);
+ ceph_assert(!is_leaf(x));
+ ceph_assert(_splits[x] == b);
_splits.erase(x);
if (simplify)
lgeneric_dout(cct, 10) << "force_to_leaf " << x << " on " << _splits << dendl;
frag_t parent = get_branch_or_leaf(x);
- assert(parent.bits() <= x.bits());
+ ceph_assert(parent.bits() <= x.bits());
lgeneric_dout(cct, 10) << "parent is " << parent << dendl;
// do we need to split from parent to x?
// easy: split parent (a leaf) by the difference
lgeneric_dout(cct, 10) << "splitting parent " << parent << " by spread " << spread << dendl;
split(parent, spread);
- assert(is_leaf(x));
+ ceph_assert(is_leaf(x));
return true;
}
- assert(nb > spread);
+ ceph_assert(nb > spread);
// add an intermediary split
merge(parent, nb, false);
}
lgeneric_dout(cct, 10) << "force_to_leaf done" << dendl;
- assert(is_leaf(x));
+ ceph_assert(is_leaf(x));
return true;
}
void intersection_size_asym(const interval_set &s, const interval_set &l) {
typename decltype(m)::const_iterator ps = s.m.begin(), pl;
- assert(ps != s.m.end());
+ ceph_assert(ps != s.m.end());
T offset = ps->first;
bool first = true;
typename decltype(m)::iterator mi = m.begin();
T start = std::max<T>(ps->first, pl->first);
T en = std::min<T>(ps->first + ps->second, offset);
- assert(en > start);
+ ceph_assert(en > start);
typename decltype(m)::value_type i{start, en - start};
mi = m.insert(mi, i);
_size += i.second;
if (p == m.end()) return false;
if (p->first > i) return false;
if (p->first+p->second <= i) return false;
- assert(p->first <= i && p->first+p->second > i);
+ ceph_assert(p->first <= i && p->first+p->second > i);
if (pstart)
*pstart = p->first;
if (plen)
if (p == m.end()) return false;
if (p->first > start) return false;
if (p->first+p->second <= start) return false;
- assert(p->first <= start && p->first+p->second > start);
+ ceph_assert(p->first <= start && p->first+p->second > start);
if (p->first+p->second < start+len) return false;
return true;
}
return m.empty();
}
T range_start() const {
- assert(!empty());
+ ceph_assert(!empty());
typename Map::const_iterator p = m.begin();
return p->first;
}
T range_end() const {
- assert(!empty());
+ ceph_assert(!empty());
typename Map::const_iterator p = m.end();
p--;
return p->first+p->second;
// interval start after p (where p not in set)
bool starts_after(T i) const {
- assert(!contains(i));
+ ceph_assert(!contains(i));
typename Map::const_iterator p = find_inc(i);
if (p == m.end()) return false;
return true;
}
T start_after(T i) const {
- assert(!contains(i));
+ ceph_assert(!contains(i));
typename Map::const_iterator p = find_inc(i);
return p->first;
}
// interval end that contains start
T end_after(T start) const {
- assert(contains(start));
+ ceph_assert(contains(start));
typename Map::const_iterator p = find_inc(start);
return p->first+p->second;
}
void insert(T start, T len, T *pstart=0, T *plen=0) {
//cout << "insert " << start << "~" << len << endl;
- assert(len > 0);
+ ceph_assert(len > 0);
_size += len;
typename Map::iterator p = find_adj_m(start);
if (p == m.end()) {
m.erase(p);
m[start] = len + psecond; // append to front
} else {
- assert(p->first > start+len);
+ ceph_assert(p->first > start+len);
if (pstart)
*pstart = start;
if (plen)
void erase(iterator &i) {
_size -= i.get_len();
- assert(_size >= 0);
+ ceph_assert(_size >= 0);
m.erase(i._iter);
}
typename Map::iterator p = find_inc_m(start);
_size -= len;
- assert(_size >= 0);
+ ceph_assert(_size >= 0);
- assert(p != m.end());
- assert(p->first <= start);
+ ceph_assert(p != m.end());
+ ceph_assert(p->first <= start);
T before = start - p->first;
- assert(p->second >= before+len);
+ ceph_assert(p->second >= before+len);
T after = p->second - before - len;
if (before) {
if (claim && claim(p->first, before)) {
void intersection_of(const interval_set &a, const interval_set &b) {
- assert(&a != this);
- assert(&b != this);
+ ceph_assert(&a != this);
+ ceph_assert(&b != this);
clear();
const interval_set *s, *l;
T start = std::max(pa->first, pb->first);
T en = std::min(pa->first+pa->second, pb->first+pb->second);
- assert(en > start);
+ ceph_assert(en > start);
typename decltype(m)::value_type i{start, en - start};
mi = m.insert(mi, i);
_size += i.second;
}
void union_of(const interval_set &a, const interval_set &b) {
- assert(&a != this);
- assert(&b != this);
+ ceph_assert(&a != this);
+ ceph_assert(&b != this);
clear();
//cout << "union_of" << endl;
while (!pintail.empty()) {
lru_remove(pintail.front());
}
- assert(num_pinned == 0);
+ ceph_assert(num_pinned == 0);
}
// insert at top of lru
void lru_insert_top(LRUObject *o) {
- assert(!o->lru);
+ ceph_assert(!o->lru);
o->lru = this;
top.push_front(&o->lru_link);
if (o->lru_pinned) num_pinned++;
// insert at mid point in lru
void lru_insert_mid(LRUObject *o) {
- assert(!o->lru);
+ ceph_assert(!o->lru);
o->lru = this;
bottom.push_front(&o->lru_link);
if (o->lru_pinned) num_pinned++;
// insert at bottom of lru
void lru_insert_bot(LRUObject *o) {
- assert(!o->lru);
+ ceph_assert(!o->lru);
o->lru = this;
bottom.push_back(&o->lru_link);
if (o->lru_pinned) num_pinned++;
LRUObject *lru_remove(LRUObject *o) {
if (!o->lru) return o;
auto list = o->lru_link.get_list();
- assert(list == &top || list == &bottom || list == &pintail);
+ ceph_assert(list == &top || list == &bottom || list == &pintail);
o->lru_link.remove_myself();
if (o->lru_pinned) num_pinned--;
o->lru = nullptr;
if (!o->lru) {
lru_insert_top(o);
} else {
- assert(o->lru == this);
+ ceph_assert(o->lru == this);
auto list = o->lru_link.get_list();
- assert(list == &top || list == &bottom || list == &pintail);
+ ceph_assert(list == &top || list == &bottom || list == &pintail);
top.push_front(&o->lru_link);
adjust();
}
if (!o->lru) {
lru_insert_mid(o);
} else {
- assert(o->lru == this);
+ ceph_assert(o->lru == this);
auto list = o->lru_link.get_list();
- assert(list == &top || list == &bottom || list == &pintail);
+ ceph_assert(list == &top || list == &bottom || list == &pintail);
if (list == &top) return false;
bottom.push_front(&o->lru_link);
adjust();
if (!o->lru) {
lru_insert_bot(o);
} else {
- assert(o->lru == this);
+ ceph_assert(o->lru == this);
auto list = o->lru_link.get_list();
- assert(list == &top || list == &bottom || list == &pintail);
+ ceph_assert(list == &top || list == &bottom || list == &pintail);
bottom.push_back(&o->lru_link);
adjust();
}
#define MEMPOOL_CLASS_HELPERS() \
void *operator new(size_t size); \
void *operator new[](size_t size) noexcept { \
- assert(0 == "no array new"); \
+ ceph_assert(0 == "no array new"); \
return nullptr; } \
void operator delete(void *); \
- void operator delete[](void *) { assert(0 == "no array delete"); }
+ void operator delete[](void *) { ceph_assert(0 == "no array delete"); }
// Use this in some particular .cc file to match each class with a
#define CEPH_ON_EXIT_H
#include <pthread.h>
-#include <assert.h>
#include <vector>
+#include "include/assert.h"
/*
* Create a static instance at the file level to get callbacks called when the
* process exits via main() or exit().
typedef void (*callback_t)(void *arg);
OnExitManager() {
- [[maybe_unused]] int ret = pthread_mutex_init(&lock_, NULL);
- assert(ret == 0);
+ int ret = pthread_mutex_init(&lock_, NULL);
+ ceph_assert(ret == 0);
}
~OnExitManager() {
// ...
bool contains(T val) {
if (theset.get_range_for(val) == theset.ranges.end()) return false;
- assert(!empty());
+ ceph_assert(!empty());
return true;
}
void insert(T val) {
- assert(!contains(val));
+ ceph_assert(!contains(val));
map_iterator left = theset.get_range_for(val-1);
map_iterator right = theset.get_range_for(val+1);
bool empty() {
if (theset.ranges.empty()) {
- assert(_size == 0);
+ ceph_assert(_size == 0);
return true;
}
- assert(_size>0);
+ ceph_assert(_size>0);
return false;
}
T first() {
- assert(!empty());
+ ceph_assert(!empty());
map_iterator it = theset.ranges.begin();
return it->first;
}
void erase(T val) {
- assert(contains(val));
+ ceph_assert(contains(val));
map_iterator it = theset.get_range_for(val);
- assert(it != theset.ranges.end());
+ ceph_assert(it != theset.ranges.end());
// entire range
if (val == it->first && val == it->second) {
{ }
void dump(Formatter *f) const {
- assert(f != NULL);
+ ceph_assert(f != NULL);
f->dump_int("total", byte_total);
f->dump_int("used", byte_used);
f->dump_int("avail", byte_avail);
#ifndef CEPH_XLIST_H
#define CEPH_XLIST_H
-#include "include/assert.h"
#include <iterator>
#include <cstdlib>
#include <ostream>
+#include "include/assert.h"
+
template<typename T>
class xlist {
public:
item(T i) : _item(i), _prev(0), _next(0), _list(0) {}
~item() {
- assert(!is_on_list());
+ ceph_assert(!is_on_list());
//remove_myself();
}
bool remove_myself() {
if (_list) {
_list->remove(this);
- assert(_list == 0);
+ ceph_assert(_list == 0);
return true;
} else
return false;
}
void move_to_front() {
- assert(_list);
+ ceph_assert(_list);
_list->push_front(this);
}
void move_to_back() {
- assert(_list);
+ ceph_assert(_list);
_list->push_back(this);
}
};
xlist() : _front(0), _back(0), _size(0) {}
~xlist() {
- assert(_size == 0);
- assert(_front == 0);
- assert(_back == 0);
+ ceph_assert(_size == 0);
+ ceph_assert(_front == 0);
+ ceph_assert(_back == 0);
}
size_t size() const {
- assert((bool)_front == (bool)_size);
+ ceph_assert((bool)_front == (bool)_size);
return _size;
}
bool empty() const {
- assert((bool)_front == (bool)_size);
+ ceph_assert((bool)_front == (bool)_size);
return _front == 0;
}
void clear() {
while (_front)
remove(_front);
- assert((bool)_front == (bool)_size);
+ ceph_assert((bool)_front == (bool)_size);
}
void push_front(item *i) {
_size++;
}
void remove(item *i) {
- assert(i->_list == this);
+ ceph_assert(i->_list == this);
if (i->_prev)
i->_prev->_next = i->_next;
i->_list = 0;
i->_next = i->_prev = 0;
- assert((bool)_front == (bool)_size);
+ ceph_assert((bool)_front == (bool)_size);
}
T front() { return static_cast<T>(_front->_item); }
const T back() const { return static_cast<const T>(_back->_item); }
void pop_front() {
- assert(!empty());
+ ceph_assert(!empty());
remove(_front);
}
void pop_back() {
- assert(!empty());
+ ceph_assert(!empty());
remove(_back);
}
iterator(item *i = 0) : cur(i) {}
T operator*() { return static_cast<T>(cur->_item); }
iterator& operator++() {
- assert(cur);
- assert(cur->_list);
+ ceph_assert(cur);
+ ceph_assert(cur->_list);
cur = cur->_next;
return *this;
}
const_iterator(item *i = 0) : cur(i) {}
const T operator*() { return static_cast<const T>(cur->_item); }
const_iterator& operator++() {
- assert(cur);
- assert(cur->_list);
+ ceph_assert(cur);
+ ceph_assert(cur->_list);
cur = cur->_next;
return *this;
}