Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
bmi_ib: rename assert

Avoid more namespace collision by renaming the bmi_ib assert.
  • Loading branch information
Pete Wyckoff committed Feb 22, 2008
1 parent 4a86321 commit 870ec99
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
38 changes: 20 additions & 18 deletions src/io/bmi/bmi_ib/ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,9 @@ static int ib_check_cq(void)
debug(3, "%s: sq %p %s", __func__, sq,
sq_state_name(sq->state.send));

assert(sq->state.send == SQ_WAITING_DATA_SEND_COMPLETION,
"%s: wrong send state %s", __func__,
sq_state_name(sq->state.send));
bmi_ib_assert(sq->state.send == SQ_WAITING_DATA_SEND_COMPLETION,
"%s: wrong send state %s", __func__,
sq_state_name(sq->state.send));

sq->state.send = SQ_WAITING_RTS_DONE_BUFFER;

Expand Down Expand Up @@ -212,9 +212,9 @@ static int ib_check_cq(void)
else if (state == SQ_WAITING_RTS_DONE_SEND_COMPLETION)
sq->state.send = SQ_WAITING_USER_TEST;
else
assert(0, "%s: unknown send state %s (%d) of sq %p",
__func__, sq_state_name(sq->state.send),
sq->state.send, sq);
bmi_ib_assert(0, "%s: unknown send state %s (%d) of sq %p",
__func__, sq_state_name(sq->state.send),
sq->state.send, sq);
debug(2, "%s: send to %s completed locally: sq %p -> %s",
__func__, bh->c->peername, sq,
sq_state_name(sq->state.send));
Expand All @@ -226,8 +226,8 @@ static int ib_check_cq(void)
if (state == RQ_RTS_WAITING_CTS_SEND_COMPLETION)
rq->state.recv = RQ_RTS_WAITING_RTS_DONE;
else
assert(0, "%s: unknown send state %s of rq %p",
__func__, rq_state_name(rq->state.recv), rq);
bmi_ib_assert(0, "%s: unknown send state %s of rq %p",
__func__, rq_state_name(rq->state.recv), rq);
debug(2, "%s: send to %s completed locally: rq %p -> %s",
__func__, bh->c->peername, rq,
rq_state_name(rq->state.recv));
Expand Down Expand Up @@ -264,8 +264,8 @@ static struct buf_head *get_eager_buf(ib_connection_t *c)
if (c->send_credit > 0) {
--c->send_credit;
bh = qlist_try_del_head(&c->eager_send_buf_free);
assert(bh, "%s: empty eager_send_buf_free list, peer %s", __func__,
c->peername);
bmi_ib_assert(bh, "%s: empty eager_send_buf_free list, peer %s",
__func__, c->peername);
}
return bh;
}
Expand All @@ -286,7 +286,7 @@ static void post_rr(ib_connection_t *c, struct buf_head *bh)
/* one credit saved back for just this situation, do not check */
--c->send_credit;
bh = qlist_try_del_head(&c->eager_send_buf_free);
assert(bh, "%s: empty eager_send_buf_free list", __func__);
bmi_ib_assert(bh, "%s: empty eager_send_buf_free list", __func__);
bh->sq = NULL;
debug(2, "%s: return %d credits to %s", __func__, c->return_credit,
c->peername);
Expand All @@ -306,8 +306,9 @@ static void encourage_send_waiting_buffer(struct ib_work *sq)
ib_connection_t *c = sq->c;

debug(3, "%s: sq %p", __func__, sq);
assert(sq->state.send == SQ_WAITING_BUFFER, "%s: wrong send state %s",
__func__, sq_state_name(sq->state.send));
bmi_ib_assert(sq->state.send == SQ_WAITING_BUFFER,
"%s: wrong send state %s", __func__,
sq_state_name(sq->state.send));

bh = get_eager_buf(c);
if (!bh) {
Expand Down Expand Up @@ -404,9 +405,10 @@ encourage_send_incoming_cts(struct buf_head *bh, u_int32_t byte_len)

debug(2, "%s: sq %p %s mopid %llx len %u", __func__, sq,
sq_state_name(sq->state.send), llu(mh_cts.rts_mop_id), byte_len);
assert(sq->state.send == SQ_WAITING_CTS
|| sq->state.send == SQ_WAITING_RTS_SEND_COMPLETION,
"%s: wrong send state %s", __func__, sq_state_name(sq->state.send));
bmi_ib_assert(sq->state.send == SQ_WAITING_CTS ||
sq->state.send == SQ_WAITING_RTS_SEND_COMPLETION,
"%s: wrong send state %s", __func__,
sq_state_name(sq->state.send));

/* message; cts content; list of buffers, lengths, and keys */
want = sizeof(mh_cts)
Expand Down Expand Up @@ -606,8 +608,8 @@ encourage_recv_incoming(struct buf_head *bh, msg_type_t type, u_int32_t byte_len
}
}

assert(rq, "%s: mop_id %llx in RTS_DONE message not found",
__func__, llu(mh_rts_done.mop_id));
bmi_ib_assert(rq, "%s: mop_id %llx in RTS_DONE message not found",
__func__, llu(mh_rts_done.mop_id));

#if MEMCACHE_BOUNCEBUF
memcpy_to_buflist(&rq->buflist, reg_recv_buflist_buf,
Expand Down
9 changes: 6 additions & 3 deletions src/io/bmi/bmi_ib/ib.h
Original file line number Diff line number Diff line change
Expand Up @@ -464,14 +464,17 @@ void memcache_cache_flush(void *md);
# define debug(lvl,fmt,...) do { } while (0)
#endif

/*
* Varargs form of assert().
*/
#if !defined(NDEBUG)
#define assert(cond,fmt,args...) \
#define bmi_ib_assert(cond, fmt, args...) \
do { \
if (bmi_ib_unlikely(!(cond))) \
error(fmt,##args); \
error(fmt, ##args); \
} while (0)
#else
# define assert(cond,fmt,...) do { } while (0)
# define bmi_ib_assert(cond, fmt, ...) do { } while (0)
#endif

#endif /* __ib_h */
4 changes: 2 additions & 2 deletions src/io/bmi/bmi_ib/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ memcache_memfree(void *md, void *buf, bmi_size_t len)
if (c) {
debug(4, "%s: cache free buf %p len %lld", __func__, c->buf,
lld(c->len));
assert(c->count == 1, "%s: buf %p len %lld count = %d, expected 1",
__func__, c->buf, lld(c->len), c->count);
bmi_ib_assert(c->count == 1, "%s: buf %p len %lld count %d, expected 1",
__func__, c->buf, lld(c->len), c->count);
/* cache it */
--c->count;
qlist_del(&c->list);
Expand Down
2 changes: 1 addition & 1 deletion src/io/bmi/bmi_ib/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void * __hidden
qlist_del_head(struct qlist_head *list)
{
struct qlist_head *h;
assert(!qlist_empty(list), "%s: empty list %p", __func__, list);
bmi_ib_assert(!qlist_empty(list), "%s: empty list %p", __func__, list);
h = list->next;
qlist_del(h);
return h;
Expand Down
12 changes: 6 additions & 6 deletions src/io/bmi/bmi_ib/vapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ static int vapi_new_connection(ib_connection_t *c, int sock, int is_server)

/* share connection information across TCP */
/* sanity check sizes of things (actually only 24 bits in qp_num) */
assert(sizeof(ch_in.lid) == sizeof(uint16_t),
"%s: connection_handshake.lid size %d expecting %d", __func__,
(int) sizeof(ch_in.lid), (int) sizeof(u_int16_t));
assert(sizeof(ch_in.qp_num) == sizeof(uint32_t),
"%s: connection_handshake.qp_num size %d expecting %d", __func__,
(int) sizeof(ch_in.qp_num), (int) sizeof(uint32_t));
bmi_ib_assert(sizeof(ch_in.lid) == sizeof(uint16_t),
"%s: connection_handshake.lid size %d expecting %d",
__func__, (int) sizeof(ch_in.lid), (int) sizeof(u_int16_t));
bmi_ib_assert(sizeof(ch_in.qp_num) == sizeof(uint32_t),
"%s: connection_handshake.qp_num size %d expecting %d",
__func__, (int) sizeof(ch_in.qp_num), (int) sizeof(uint32_t));

/* convert all to network order and back */
ch_out.lid = htobmi16(vd->nic_lid);
Expand Down

0 comments on commit 870ec99

Please sign in to comment.