Skip to content

Commit

Permalink
bmi_ib: Malloc rename
Browse files Browse the repository at this point in the history
Avoid exporting Malloc symbol; it may clash in the global namespace.
  • Loading branch information
Pete Wyckoff committed Feb 22, 2008
1 parent 0ec43ba commit 4a86321
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 26 deletions.
26 changes: 13 additions & 13 deletions src/io/bmi/bmi_ib/ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ find_matching_recv(rq_state_t statemask, const ib_connection_t *c,
static struct ib_work *
alloc_new_recv(ib_connection_t *c, struct buf_head *bh)
{
struct ib_work *rq = Malloc(sizeof(*rq));
struct ib_work *rq = bmi_ib_malloc(sizeof(*rq));
rq->type = BMI_RECV;
rq->c = c;
++rq->c->refcnt;
Expand Down Expand Up @@ -730,7 +730,7 @@ send_cts(struct ib_work *rq)
reg_recv_buflist.buf.recv = &reg_recv_buflist_buf;
reg_recv_buflist.len = &reg_recv_buflist_len;
reg_recv_buflist.tot_len = reg_recv_buflist_len;
reg_recv_buflist_buf = Malloc(reg_recv_buflist_len);
reg_recv_buflist_buf = bmi_ib_malloc(reg_recv_buflist_len);
memcache_register(ib_device->memcache, &reg_recv_buflist);
}
if (rq->buflist.tot_len > reg_recv_buflist_len)
Expand Down Expand Up @@ -818,7 +818,7 @@ post_send(bmi_op_id_t *id, struct bmi_method_addr *remote_map,
ibmap = remote_map->method_data;

/* alloc and build new sendq structure */
sq = Malloc(sizeof(*sq));
sq = bmi_ib_malloc(sizeof(*sq));
sq->type = BMI_SEND;
sq->state.send = SQ_WAITING_BUFFER;

Expand Down Expand Up @@ -869,7 +869,7 @@ post_send(bmi_op_id_t *id, struct bmi_method_addr *remote_map,
qlist_add_tail(&sq->list, &ib_device->sendq);

/* generate identifier used by caller to test for message later */
mop = Malloc(sizeof(*mop));
mop = bmi_ib_malloc(sizeof(*mop));
id_gen_fast_register(&mop->op_id, mop);
mop->addr = remote_map; /* set of function pointers, essentially */
mop->method_data = sq;
Expand Down Expand Up @@ -995,7 +995,7 @@ post_recv(bmi_op_id_t *id, struct bmi_method_addr *remote_map,
__func__, lld(tot_expected_len), lld(rq->buflist.tot_len));

/* generate identifier used by caller to test for message later */
mop = Malloc(sizeof(*mop));
mop = bmi_ib_malloc(sizeof(*mop));
id_gen_fast_register(&mop->op_id, mop);
mop->addr = remote_map; /* set of function pointers, essentially */
mop->method_data = rq;
Expand Down Expand Up @@ -1386,7 +1386,7 @@ BMI_ib_testunexpected(int incount __unused, int *outcount,
debug(2, "%s: found waiting testunexpected", __func__);
ui->error_code = 0;
ui->addr = c->remote_map; /* hand back permanent method_addr */
ui->buffer = Malloc((unsigned long) rq->actual_len);
ui->buffer = bmi_ib_malloc((unsigned long) rq->actual_len);
ui->size = rq->actual_len;
memcpy(ui->buffer,
(msg_header_eager_t *) rq->bh->buf + 1,
Expand Down Expand Up @@ -1575,7 +1575,7 @@ static struct bmi_method_addr *BMI_ib_method_addr_lookup(const char *id)
error("%s: no ':' found", __func__);

/* copy to permanent storage */
hostname = Malloc((unsigned long) (cp - s + 1));
hostname = bmi_ib_malloc((unsigned long) (cp - s + 1));
strncpy(hostname, s, (size_t) (cp-s));
hostname[cp-s] = '\0';

Expand Down Expand Up @@ -1623,19 +1623,19 @@ static ib_connection_t *ib_new_connection(int sock, const char *peername,
ib_connection_t *c;
int i, ret;

c = Malloc(sizeof(*c));
c = bmi_ib_malloc(sizeof(*c));
c->peername = strdup(peername);

/* fill send and recv free lists and buf heads */
c->eager_send_buf_contig = Malloc(ib_device->eager_buf_num
c->eager_send_buf_contig = bmi_ib_malloc(ib_device->eager_buf_num
* ib_device->eager_buf_size);
c->eager_recv_buf_contig = Malloc(ib_device->eager_buf_num
c->eager_recv_buf_contig = bmi_ib_malloc(ib_device->eager_buf_num
* ib_device->eager_buf_size);
INIT_QLIST_HEAD(&c->eager_send_buf_free);
INIT_QLIST_HEAD(&c->eager_recv_buf_free);
c->eager_send_buf_head_contig = Malloc(ib_device->eager_buf_num
c->eager_send_buf_head_contig = bmi_ib_malloc(ib_device->eager_buf_num
* sizeof(*c->eager_send_buf_head_contig));
c->eager_recv_buf_head_contig = Malloc(ib_device->eager_buf_num
c->eager_recv_buf_head_contig = bmi_ib_malloc(ib_device->eager_buf_num
* sizeof(*c->eager_recv_buf_head_contig));
for (i=0; i<ib_device->eager_buf_num; i++) {
struct buf_head *ebs = &c->eager_send_buf_head_contig[i];
Expand Down Expand Up @@ -1982,7 +1982,7 @@ static int BMI_ib_initialize(struct bmi_method_addr *listen_addr, int method_id,

bmi_ib_method_id = method_id;

ib_device = Malloc(sizeof(*ib_device));
ib_device = bmi_ib_malloc(sizeof(*ib_device));

/* try, in order, OpenIB then VAPI; set up function pointers */
ret = 1;
Expand Down
2 changes: 1 addition & 1 deletion src/io/bmi/bmi_ib/ib.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ void warning_errno(const char *fmt, ...) __attribute__((format(printf,1,2)));
void warning_xerrno(int errnum, const char *fmt, ...)
__attribute__((format(printf,2,3)));
void info(const char *fmt, ...) __attribute__((format(printf,1,2)));
void *Malloc(unsigned long n) __attribute__((malloc));
void *bmi_ib_malloc(unsigned long n) __attribute__((malloc));
void *qlist_del_head(struct qlist_head *list);
void *qlist_try_del_head(struct qlist_head *list);
const char *sq_state_name(sq_state_t num);
Expand Down
7 changes: 4 additions & 3 deletions src/io/bmi/bmi_ib/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ memcache_register(void *md, ib_buflist_t *buflist)
int i, ret;
memcache_device_t *memcache_device = md;

buflist->memcache = Malloc(buflist->num * sizeof(*buflist->memcache));
buflist->memcache = bmi_ib_malloc(buflist->num *
sizeof(*buflist->memcache));
gen_mutex_lock(&memcache_device->mutex);
for (i=0; i<buflist->num; i++) {
#if ENABLE_MEMCACHE
Expand Down Expand Up @@ -256,7 +257,7 @@ memcache_register(void *md, ib_buflist_t *buflist)
}
buflist->memcache[i] = c;
#else
memcache_entry_t cp = Malloc(sizeof(*cp));
memcache_entry_t cp = bmi_ib_malloc(sizeof(*cp));
cp->buf = buflist->buf.recv[i];
cp->len = buflist->len[i];
cp->type = type;
Expand Down Expand Up @@ -337,7 +338,7 @@ void *memcache_init(int (*mem_register)(memcache_entry_t *),
{
memcache_device_t *memcache_device;

memcache_device = Malloc(sizeof(*memcache_device));
memcache_device = bmi_ib_malloc(sizeof(*memcache_device));
INIT_QLIST_HEAD(&memcache_device->list);
gen_mutex_init(&memcache_device->mutex);
INIT_QLIST_HEAD(&memcache_device->free_chunk_list);
Expand Down
9 changes: 5 additions & 4 deletions src/io/bmi/bmi_ib/openib.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static int openib_new_connection(ib_connection_t *c, int sock, int is_server)
} ch_in, ch_out;

/* build new connection/context */
oc = Malloc(sizeof(*oc));
oc = bmi_ib_malloc(sizeof(*oc));
c->priv = oc;

/* register memory region, Recv side */
Expand Down Expand Up @@ -163,7 +163,8 @@ static int openib_new_connection(ib_connection_t *c, int sock, int is_server)
od->sg_max_len = att.cap.max_send_sge;
if (att.cap.max_recv_sge < od->sg_max_len)
od->sg_max_len = att.cap.max_recv_sge;
od->sg_tmp_array = Malloc(od->sg_max_len * sizeof(*od->sg_tmp_array));
od->sg_tmp_array = bmi_ib_malloc(od->sg_max_len *
sizeof(*od->sg_tmp_array));
} else {
if (att.cap.max_send_sge < od->sg_max_len)
error("%s: new conn has smaller send SG array size %d vs %d",
Expand Down Expand Up @@ -477,7 +478,7 @@ static void openib_post_sr_rdmaw(struct ib_work *sq, msg_header_cts_t *mh_cts,
reg_send_buflist.buf.recv = &reg_send_buflist_buf;
reg_send_buflist.len = &reg_send_buflist_len;
reg_send_buflist.tot_len = reg_send_buflist_len;
reg_send_buflist_buf = Malloc(reg_send_buflist_len);
reg_send_buflist_buf = bmi_ib_malloc(reg_send_buflist_len);
memcache_register(ib_device->memcache, &reg_send_buflist, BMI_SEND);
}
if (sq->buflist.tot_len > reg_send_buflist_len)
Expand Down Expand Up @@ -877,7 +878,7 @@ int openib_ib_initialize(void)
}
VALGRIND_MAKE_MEM_DEFINED(ctx, sizeof(*ctx));

od = Malloc(sizeof(*od));
od = bmi_ib_malloc(sizeof(*od));
ib_device->priv = od;

/* set the function pointers for openib */
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 @@ -94,7 +94,7 @@ warning_xerrno(int errnum, const char *fmt, ...)
}

void * __attribute__((malloc)) __hidden
Malloc(unsigned long n)
bmi_ib_malloc(unsigned long n)
{
char *x;

Expand Down
9 changes: 5 additions & 4 deletions src/io/bmi/bmi_ib/vapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ static int vapi_new_connection(ib_connection_t *c, int sock, int is_server)
VAPI_qp_num_t qp_num;
} ch_in, ch_out;

vc = Malloc(sizeof(*vc));
vc = bmi_ib_malloc(sizeof(*vc));
c->priv = vc;

/* register memory region, recv */
Expand Down Expand Up @@ -248,7 +248,8 @@ static void verify_prop_caps(VAPI_qp_cap_t *cap)
vd->sg_max_len = cap->max_sg_size_sq;
if (cap->max_sg_size_rq < vd->sg_max_len)
vd->sg_max_len = cap->max_sg_size_rq;
vd->sg_tmp_array = Malloc(vd->sg_max_len * sizeof(*vd->sg_tmp_array));
vd->sg_tmp_array = bmi_ib_malloc(vd->sg_max_len *
sizeof(*vd->sg_tmp_array));
} else {
if (cap->max_sg_size_sq < vd->sg_max_len)
error(
Expand Down Expand Up @@ -487,7 +488,7 @@ static void vapi_post_sr_rdmaw(struct ib_work *sq, msg_header_cts_t *mh_cts,
reg_send_buflist.buf.recv = &reg_send_buflist_buf;
reg_send_buflist.len = &reg_send_buflist_len;
reg_send_buflist.tot_len = reg_send_buflist_len;
reg_send_buflist_buf = Malloc(reg_send_buflist_len);
reg_send_buflist_buf = bmi_ib_malloc(reg_send_buflist_len);
memcache_register(ib_device->memcache, &reg_send_buflist);
}
if (sq->buflist.tot_len > reg_send_buflist_len)
Expand Down Expand Up @@ -897,7 +898,7 @@ int vapi_ib_initialize(void)
if (num_hcas > 1)
warning("%s: found %d HCAs, choosing the first", __func__, num_hcas);

vd = Malloc(sizeof(*vd));
vd = bmi_ib_malloc(sizeof(*vd));
ib_device->priv = vd;

/* set the function pointers for vapi */
Expand Down

0 comments on commit 4a86321

Please sign in to comment.