A large commit:
Changing the object.h model to conform more to people's (C++-biased) expectations. See the comment at the top of src/lam/lfc/object.h for full details. Also a couple of tweaks to the datatype directory (but nothing working yet). This commit was SVN r674.
Этот коммит содержится в:
родитель
413d87586d
Коммит
00e50911b0
@ -10,3 +10,7 @@ doxygen
|
||||
bin
|
||||
lib
|
||||
include
|
||||
cscope.*
|
||||
etags
|
||||
|
||||
|
||||
|
@ -8,18 +8,21 @@
|
||||
|
||||
#define CHANNEL_CLS(chnl) ((lam_ctchannel_class_t *)(OBJECT(chnl)->obj_class))
|
||||
|
||||
lam_ctchannel_class_t lam_ctchannel_cls = {
|
||||
{"lam_ct_channel_t", &lam_object_cls,
|
||||
(class_init_t)lam_cth_init,
|
||||
(class_destroy_t)lam_obj_destroy},
|
||||
lam_ctchannel_class_t lam_ct_channel_t_class_info = {
|
||||
{
|
||||
"lam_ct_channel_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t)lam_cth_construct,
|
||||
(lam_destruct_t)lam_object_destruct
|
||||
},
|
||||
NULL, NULL, NULL, NULL,
|
||||
NULL, NULL
|
||||
};
|
||||
|
||||
|
||||
void lam_cth_init(lam_ctchannel_t *channel)
|
||||
void lam_cth_construct(lam_ctchannel_t *channel)
|
||||
{
|
||||
SUPER_INIT(channel, lam_ctchannel_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(channel, lam_object_t);
|
||||
channel->cth_status = CT_CHNL_CLOSED;
|
||||
channel->cth_id = 0;
|
||||
channel->cth_timeout_secs = 0;
|
||||
@ -88,10 +91,13 @@ uint32_t lam_cth_send_packed_msg(lam_ctchannel_t *channel, const uint8_t *packed
|
||||
*/
|
||||
|
||||
|
||||
lam_ctchannel_class_t lam_tcp_channel_cls = {
|
||||
{"lam_tcp_chnl_t", &lam_ctchannel_cls,
|
||||
(class_init_t)lam_tcpch_init,
|
||||
(class_destroy_t)lam_tcpch_destroy},
|
||||
lam_ctchannel_class_t lam_tcp_chnl_t_class_info = {
|
||||
{
|
||||
"lam_tcp_chnl_t",
|
||||
CLASS_INFO(lam_ctchannel_t),
|
||||
(lam_construct_t) lam_tcpch_construct,
|
||||
(lam_destruct_t) lam_tcpch_destruct
|
||||
},
|
||||
lam_tcpch_send,
|
||||
lam_tcpch_recv,
|
||||
lam_tcpch_get_msg,
|
||||
@ -100,17 +106,17 @@ lam_ctchannel_class_t lam_tcp_channel_cls = {
|
||||
lam_tcpch_send_packed_msg
|
||||
};
|
||||
|
||||
void lam_tcpch_init(lam_tcp_chnl_t *channel)
|
||||
void lam_tcpch_construct(lam_tcp_chnl_t *channel)
|
||||
{
|
||||
SUPER_INIT(channel, lam_tcp_channel_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(channel, lam_object_t);
|
||||
channel->tcp_sockfd = 0;
|
||||
memset(&(channel->tcp_addr), 0, sizeof(channel->tcp_addr));
|
||||
channel->tcp_blocking = 0;
|
||||
}
|
||||
|
||||
void lam_tcpch_destroy(lam_tcp_chnl_t *channel)
|
||||
void lam_tcpch_destruct(lam_tcp_chnl_t *channel)
|
||||
{
|
||||
SUPER_DESTROY(channel, lam_tcp_channel_cls.cls_parent);
|
||||
OBJ_DESTRUCT_SUPER(channel, lam_ct_channel_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ typedef struct lam_ctchannel_class
|
||||
} lam_ctchannel_class_t;
|
||||
|
||||
|
||||
extern lam_ctchannel_class_t lam_ctchannel_cls;
|
||||
extern lam_ctchannel_class_t lam_ct_channel_t_class_info;
|
||||
|
||||
typedef struct lam_ctchannel
|
||||
{
|
||||
@ -109,7 +109,7 @@ typedef struct lam_ctchannel
|
||||
} lam_ctchannel_t;
|
||||
|
||||
|
||||
void lam_cth_init(lam_ctchannel_t *channel);
|
||||
void lam_cth_construct(lam_ctchannel_t *channel);
|
||||
|
||||
/*
|
||||
*
|
||||
@ -189,10 +189,10 @@ typedef struct lam_tcp_channel
|
||||
int tcp_blocking;
|
||||
} lam_tcp_chnl_t;
|
||||
|
||||
extern lam_ctchannel_class_t lam_tcp_channel_cls;
|
||||
extern lam_ctchannel_class_t lam_tcp_chnl_t_class_info;
|
||||
|
||||
void lam_tcpch_init(lam_tcp_chnl_t *channel);
|
||||
void lam_tcpch_destroy(lam_tcp_chnl_t *channel);
|
||||
void lam_tcpch_construct(lam_tcp_chnl_t *channel);
|
||||
void lam_tcpch_destruct(lam_tcp_chnl_t *channel);
|
||||
|
||||
|
||||
uint32_t lam_tcpch_send(lam_tcp_chnl_t *channel, const uint8_t *data,
|
||||
|
@ -25,8 +25,8 @@ typedef struct lam_ctcontroller
|
||||
lam_ctnode_failed_fn ctl_node_failed_callback;
|
||||
} lam_ctctrl_t;
|
||||
|
||||
void lam_ctl_init(lam_ctctrl_t *ctrl);
|
||||
void lam_ctl_destroy(lam_ctctrl_t *ctrl);
|
||||
void lam_ctl_construct(lam_ctctrl_t *ctrl);
|
||||
void lam_ctl_destruct(lam_ctctrl_t *ctrl);
|
||||
|
||||
inline void lam_ctl_set_recvd_callback(lam_ctctrl_t *ctrl, lam_ctmsg_recvd_fn callback)
|
||||
{
|
||||
|
@ -6,20 +6,28 @@
|
||||
#include "lam/mem/malloc.h"
|
||||
|
||||
|
||||
lam_class_info_t lam_ctctrl_cls = {"lam_ct_ctrl_t", &lam_object_cls,
|
||||
(class_init_t) lam_ctc_init, (class_destroy_t)lam_ctc_destroy};
|
||||
lam_class_info_t lam_ct_ctrl_t_class_info = {
|
||||
"lam_ct_ctrl_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_ctc_construct,
|
||||
(lam_destruct_t) lam_ctc_destruct
|
||||
};
|
||||
|
||||
lam_class_info_t lam_ctmsg_cls = {"lam_ctmsg_t", &lam_object_cls,
|
||||
(class_init_t) lam_ctm_init, (class_destroy_t)lam_ctm_destroy};
|
||||
lam_class_info_t lam_ctmsg_t_class_info = {
|
||||
"lam_ctmsg_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_ctm_construct,
|
||||
(lam_destruct_t) lam_ctm_destruct
|
||||
};
|
||||
|
||||
|
||||
static const uint32_t ctrl_alloc_len = sizeof(lam_ct_ctrl_t) -
|
||||
sizeof(lam_object_t) -
|
||||
sizeof(ctrl->ctc_info);
|
||||
|
||||
void lam_ctc_init(lam_ct_ctrl_t *ctrl)
|
||||
void lam_ctc_construct(lam_ct_ctrl_t *ctrl)
|
||||
{
|
||||
SUPER_INIT(ctrl, lam_ctctrl_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(ctrl, lam_object_t);
|
||||
|
||||
ctrl->ctc_is_user_msg = 0;
|
||||
ctrl->ctc_routing_type = LAM_CT_PT2PT;
|
||||
@ -33,15 +41,15 @@ void lam_ctc_init(lam_ct_ctrl_t *ctrl)
|
||||
|
||||
|
||||
|
||||
void lam_ctc_destroy(lam_ct_ctrl_t *ctrl)
|
||||
void lam_ctc_destruct(lam_ct_ctrl_t *ctrl)
|
||||
{
|
||||
lam_free(ctrl->ctc_info);
|
||||
SUPER_DESTROY(ctrl, lam_ctctrl_cls.cls_parent);
|
||||
OBJ_DESTRUCT_SUPER(ctrl, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void lam_ctc_init_with(lam_ct_ctrl_t *ctrl, int routing_type,
|
||||
void lam_ctc_construct_with(lam_ct_ctrl_t *ctrl, int routing_type,
|
||||
uint32_t sender,
|
||||
uint32_t dest)
|
||||
{
|
||||
@ -89,7 +97,7 @@ lam_ct_ctrl_t *lam_ctc_unpack(uint8_t *buffer)
|
||||
<ctc_forwarding (uint32_t)><ctc_client_tag (uint32_t)>
|
||||
<ctc_info_len (uint32_t)><ctc_info (uint8_t *)>
|
||||
*/
|
||||
CREATE_OBJECT(ctrl, lam_ct_ctrl_t, &lam_ctctrl_cls);
|
||||
ctrl = OBJ_NEW(lam_ct_ctrl_t);
|
||||
if ( 0 == ctrl )
|
||||
{
|
||||
return 0;
|
||||
@ -192,23 +200,23 @@ void lam_pk_ctc_set_info(uint8_t *buffer, uint8_t *info)
|
||||
*/
|
||||
|
||||
|
||||
void lam_ctm_init(lam_ctmsg_t *msg)
|
||||
void lam_ctm_construct(lam_ctmsg_t *msg)
|
||||
{
|
||||
SUPER_INIT(msg, lam_ctmsg_cls.cls_parent);
|
||||
CREATE_OBJECT(msg->ctm_ctrl, lam_ct_ctrl_t, &lam_ctctrl_cls);
|
||||
OBJ_CONSTRUCT_SUPER(msg, lam_object_t);
|
||||
msg->ctm_ctrl = OBJ_NEW(lam_ct_ctrl_t);
|
||||
msg->ctm_len = 0;
|
||||
msg->ctm_data = 0;
|
||||
msg->ctm_should_free = 1;
|
||||
}
|
||||
|
||||
void lam_ctm_destroy(lam_ctmsg_t *msg)
|
||||
void lam_ctm_destruct(lam_ctmsg_t *msg)
|
||||
{
|
||||
if ( msg->ctm_should_free )
|
||||
{
|
||||
lam_free(msg->ctm_data);
|
||||
}
|
||||
OBJECT_RELEASE(msg->ctm_ctrl);
|
||||
SUPER_DESTROY(msg, lam_ctmsg_cls.cls_parent);
|
||||
OBJ_DESTRUCT_SUPER(msg, lam_object_t);
|
||||
}
|
||||
|
||||
lam_ctmsg_t *lam_ctm_create_with(int is_user_msg, int routing_type,
|
||||
@ -219,14 +227,14 @@ lam_ctmsg_t *lam_ctm_create_with(int is_user_msg, int routing_type,
|
||||
{
|
||||
lam_ctmsg_t *msg;
|
||||
|
||||
CREATE_OBJECT(msg, lam_ctmsg_t, &lam_ctmsg_cls);
|
||||
msg = OBJ_NEW(lam_ctmsg_t);
|
||||
if ( 0 == msg )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
STATIC_INIT(msg->ctm_ctrl, &lam_ctctrl_cls);
|
||||
lam_ctc_init_with(&(msg->ctm_ctrl), sender, dest);
|
||||
OBJ_CONSTRUCT(&msg->ctm_ctrl, lam_ct_ctrl_t);
|
||||
lam_ctc_construct_with(&(msg->ctm_ctrl), sender, dest);
|
||||
msg->ctm_should_free = should_free;
|
||||
msg->ctm_data = data;
|
||||
msg->ctm_len = data_len;
|
||||
|
@ -14,8 +14,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern lam_class_info_t lam_ctctrl_cls;
|
||||
extern lam_class_info_t lam_ctmsg_cls;
|
||||
extern lam_class_info_t lam_ct_ctrl_t_class_info;
|
||||
extern lam_class_info_t lam_ctmsg_t_class_info;
|
||||
|
||||
/*
|
||||
*
|
||||
@ -62,10 +62,10 @@ typedef struct lam_ct_ctrl
|
||||
} lam_ct_ctrl_t;
|
||||
|
||||
|
||||
void lam_ctc_init(lam_ct_ctrl_t *ctrl);
|
||||
void lam_ctc_destroy(lam_ct_ctrl_t *ctrl);
|
||||
void lam_ctc_construct(lam_ct_ctrl_t *ctrl);
|
||||
void lam_ctc_destruct(lam_ct_ctrl_t *ctrl);
|
||||
|
||||
void lam_ctc_init_with(lam_ct_ctrl_t *ctrl, int routing_type,
|
||||
void lam_ctc_construct_with(lam_ct_ctrl_t *ctrl, int routing_type,
|
||||
uint32_t sender,
|
||||
uint32_t dest);
|
||||
|
||||
@ -187,8 +187,8 @@ typedef struct lam_ctmsg
|
||||
} lam_ctmsg_t;
|
||||
|
||||
|
||||
void lam_ctm_init(lam_ctmsg_t *msg);
|
||||
void lam_ctm_destroy(lam_ctmsg_t *msg);
|
||||
void lam_ctm_construct(lam_ctmsg_t *msg);
|
||||
void lam_ctm_destruct(lam_ctmsg_t *msg);
|
||||
|
||||
lam_ctmsg_t *lam_ctm_create_with(int is_user_msg, int routing_type,
|
||||
uint32_t sender,
|
||||
|
@ -40,7 +40,7 @@ typedef struct lam_ctnode_class
|
||||
*/
|
||||
|
||||
|
||||
extern lam_ctnode_class_t hypercube_cls;
|
||||
extern lam_ctnode_class_t hypercube_t_class_info;
|
||||
|
||||
|
||||
|
||||
@ -64,8 +64,8 @@ typedef struct lam_ctnode
|
||||
} lam_ctnode_t;
|
||||
|
||||
|
||||
void lam_ctn_init(lam_ctnode_t *node);
|
||||
void lam_ctn_destroy(lam_ctnode_t *node);
|
||||
void lam_ctn_construct(lam_ctnode_t *node);
|
||||
void lam_ctn_destruct(lam_ctnode_t *node);
|
||||
|
||||
/*
|
||||
*
|
||||
@ -153,6 +153,6 @@ typedef struct lam_hcube
|
||||
unsigned int hc_hsize; /* hc_hsize = log2(# nodes in network) */
|
||||
} lam_hcube_t;
|
||||
|
||||
extern lam_class_info_t hcube_cls;
|
||||
extern lam_class_info_t hcube_t_class_info;
|
||||
|
||||
#endif /* LAM_CT_NODE_H */
|
||||
|
@ -9,8 +9,12 @@
|
||||
#define ARR_BLK_SZ 20
|
||||
|
||||
|
||||
lam_class_info_t lam_array_cls = {"lam_array_t", &lam_object_cls,
|
||||
(class_init_t) lam_arr_init, (class_destroy_t) lam_arr_destroy};
|
||||
lam_class_info_t lam_array_t_class_info = {
|
||||
"lam_array_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_arr_construct,
|
||||
(lam_destruct_t) lam_arr_destruct
|
||||
};
|
||||
|
||||
/*
|
||||
*
|
||||
@ -18,25 +22,25 @@ lam_class_info_t lam_array_cls = {"lam_array_t", &lam_object_cls,
|
||||
*
|
||||
*/
|
||||
|
||||
void lam_arr_init(lam_array_t *arr)
|
||||
void lam_arr_construct(lam_array_t *arr)
|
||||
{
|
||||
SUPER_INIT(arr, lam_array_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(arr, lam_object_t);
|
||||
arr->arr_items = NULL;
|
||||
arr->arr_size = 0;
|
||||
arr->arr_length = 0;
|
||||
}
|
||||
|
||||
void lam_arr_destroy(lam_array_t *arr)
|
||||
void lam_arr_destruct(lam_array_t *arr)
|
||||
{
|
||||
lam_arr_remove_all(arr);
|
||||
free(arr->arr_items);
|
||||
SUPER_DESTROY(arr, lam_array_cls.cls_parent);
|
||||
OBJ_DESTRUCT_SUPER(arr, lam_object_t);
|
||||
}
|
||||
|
||||
bool lam_arr_init_with(lam_array_t *arr, size_t length)
|
||||
bool lam_arr_construct_with(lam_array_t *arr, size_t length)
|
||||
{
|
||||
/* initializes array with fixed length.
|
||||
lam_arr_init() must have been called first. */
|
||||
lam_arr_construct() must have been called first. */
|
||||
if ( arr->arr_items )
|
||||
{
|
||||
lam_arr_remove_all(arr);
|
||||
|
@ -15,7 +15,7 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern lam_class_info_t lam_array_cls;
|
||||
extern lam_class_info_t lam_array_t_class_info;
|
||||
|
||||
|
||||
/*
|
||||
@ -39,13 +39,13 @@ typedef struct lam_array_t lam_array_t;
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
void lam_arr_init(lam_array_t *arr);
|
||||
void lam_arr_destroy(lam_array_t *arr);
|
||||
void lam_arr_construct(lam_array_t *arr);
|
||||
void lam_arr_destruct(lam_array_t *arr);
|
||||
|
||||
/* initializes array with fixed length.
|
||||
* lam_arr_init() must have been called first.
|
||||
* lam_arr_construct() must have been called first.
|
||||
*/
|
||||
bool lam_arr_init_with(lam_array_t *arr, size_t length);
|
||||
bool lam_arr_construct_with(lam_array_t *arr, size_t length);
|
||||
|
||||
bool lam_arr_append_item(lam_array_t *arr, lam_object_t *item);
|
||||
|
||||
|
@ -12,9 +12,11 @@
|
||||
|
||||
#define BUCKET_ALLOC_SZ 5
|
||||
|
||||
lam_class_info_t lam_fast_hash_cls = {
|
||||
"lam_fast_hash_t", &lam_object_cls, (class_init_t)lam_fh_init,
|
||||
(class_destroy_t)lam_fh_destroy
|
||||
lam_class_info_t lam_fast_hash_t_class_info = {
|
||||
"lam_fast_hash_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_fh_construct,
|
||||
(lam_destruct_t) lam_fh_destruct
|
||||
};
|
||||
|
||||
/*
|
||||
@ -44,7 +46,7 @@ static inline void *lam_fh_get_value_nkey(lam_fast_hash_t *htbl, void *key, uint
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
|
||||
buckets = htbl->fh_nodes[hval];
|
||||
@ -68,7 +70,7 @@ static inline void *lam_fh_get_value_ptrkey(lam_fast_hash_t *htbl, void *key, ui
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
|
||||
buckets = htbl->fh_nodes[hval];
|
||||
@ -93,7 +95,7 @@ static inline void lam_fh_remove_value_nkey(lam_fast_hash_t *htbl, void *key, ui
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
|
||||
buckets = htbl->fh_nodes[hval];
|
||||
@ -117,7 +119,7 @@ static inline void lam_fh_remove_value_ptrkey(lam_fast_hash_t *htbl, void *key,
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
|
||||
buckets = htbl->fh_nodes[hval];
|
||||
@ -145,7 +147,7 @@ static inline int lam_fh_find_empty_bucket(lam_fast_hash_t *htbl, uint32_t hval,
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
buckets = htbl->fh_nodes[hval];
|
||||
if ( !buckets )
|
||||
@ -203,7 +205,7 @@ static inline int lam_fh_set_value_ptrkey(lam_fast_hash_t *htbl, void *val,
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
|
||||
err = lam_fh_find_empty_bucket(htbl, hval, &bucket_idx);
|
||||
@ -238,7 +240,7 @@ static inline int lam_fh_set_value_nkey(lam_fast_hash_t *htbl, void *val,
|
||||
lam_fhnode_t *buckets;
|
||||
|
||||
/* ASSERT: table size is power of 2 and table
|
||||
has been initialized using lam_fh_init_with().
|
||||
has been initialized using lam_fh_construct_with().
|
||||
*/
|
||||
hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
|
||||
err = lam_fh_find_empty_bucket(htbl, hval, &bucket_idx);
|
||||
@ -287,9 +289,9 @@ static uint32_t lam_log2(unsigned int n)
|
||||
|
||||
#define DEFAULT_SIZE 128
|
||||
|
||||
void lam_fh_init(lam_fast_hash_t *htbl)
|
||||
void lam_fh_construct(lam_fast_hash_t *htbl)
|
||||
{
|
||||
SUPER_INIT(htbl, lam_fast_hash_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(htbl, lam_object_t);
|
||||
htbl->fh_nodes = 0;
|
||||
htbl->fh_count = 0;
|
||||
htbl->fh_size = 0;
|
||||
@ -298,7 +300,7 @@ void lam_fh_init(lam_fast_hash_t *htbl)
|
||||
lam_fh_resize(htbl, DEFAULT_SIZE);
|
||||
}
|
||||
|
||||
void lam_fh_destroy(lam_fast_hash_t *htbl)
|
||||
void lam_fh_destruct(lam_fast_hash_t *htbl)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -314,7 +316,7 @@ void lam_fh_destroy(lam_fast_hash_t *htbl)
|
||||
free(htbl->fh_bucket_cnt);
|
||||
}
|
||||
|
||||
SUPER_DESTROY(htbl, lam_fast_hash_cls.cls_parent);
|
||||
OBJ_DESTRUCT_SUPER(htbl, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct lam_fast_hash_t
|
||||
|
||||
typedef struct lam_fast_hash_t lam_fast_hash_t;
|
||||
|
||||
extern lam_class_info_t lam_fast_hash_cls;
|
||||
extern lam_class_info_t lam_fast_hash_t_class_info;
|
||||
|
||||
/*
|
||||
*
|
||||
@ -67,8 +67,8 @@ extern "C" {
|
||||
* This is a simple function that does not very much. It's just a test
|
||||
* so that I can show what Doxygen does.
|
||||
*/
|
||||
void lam_fh_init(lam_fast_hash_t *htbl);
|
||||
void lam_fh_destroy(lam_fast_hash_t *htbl);
|
||||
void lam_fh_construct(lam_fast_hash_t *htbl);
|
||||
void lam_fh_destruct(lam_fast_hash_t *htbl);
|
||||
|
||||
/* resize hash table to size */
|
||||
int lam_fh_resize(lam_fast_hash_t *htbl, uint32_t size);
|
||||
|
@ -9,10 +9,19 @@
|
||||
*/
|
||||
|
||||
|
||||
lam_class_info_t lam_list_item_cls = {"lam_list_item_t", &lam_object_cls,
|
||||
(class_init_t) lam_list_item_init, (class_destroy_t)lam_obj_destroy};
|
||||
lam_class_info_t lam_list_cls = {"lam_list_t", &lam_object_cls,
|
||||
(class_init_t)lam_list_init, (class_destroy_t)lam_list_destroy};
|
||||
lam_class_info_t lam_list_item_t_class_info = {
|
||||
"lam_list_item_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_list_item_construct,
|
||||
(lam_destruct_t) lam_object_destruct
|
||||
};
|
||||
|
||||
lam_class_info_t lam_list_t_class_info = {
|
||||
"lam_list_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_list_construct,
|
||||
(lam_destruct_t) lam_list_destruct
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
@ -21,9 +30,9 @@ lam_class_info_t lam_list_cls = {"lam_list_t", &lam_object_cls,
|
||||
*
|
||||
*/
|
||||
|
||||
void lam_list_item_init(lam_list_item_t *item)
|
||||
void lam_list_item_construct(lam_list_item_t *item)
|
||||
{
|
||||
SUPER_INIT(item, lam_list_item_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(item, lam_object_t);
|
||||
item->lam_list_next = item->lam_list_prev = NULL;
|
||||
item->lam_list_type = 0;
|
||||
}
|
||||
@ -35,9 +44,9 @@ void lam_list_item_init(lam_list_item_t *item)
|
||||
*
|
||||
*/
|
||||
|
||||
void lam_list_init(lam_list_t *list)
|
||||
void lam_list_construct(lam_list_t *list)
|
||||
{
|
||||
SUPER_INIT(list, lam_list_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(list, lam_object_t);
|
||||
list->lam_list_head.lam_list_prev = NULL;
|
||||
list->lam_list_head.lam_list_next = &list->lam_list_tail;
|
||||
list->lam_list_tail.lam_list_prev = &list->lam_list_head;
|
||||
@ -47,11 +56,11 @@ void lam_list_init(lam_list_t *list)
|
||||
}
|
||||
|
||||
|
||||
void lam_list_destroy(lam_list_t *list)
|
||||
void lam_list_destruct(lam_list_t *list)
|
||||
{
|
||||
/* release all items in list */
|
||||
lam_list_init(list);
|
||||
SUPER_DESTROY(list, lam_list_cls.cls_parent);
|
||||
lam_list_construct(list);
|
||||
OBJ_DESTRUCT_SUPER(list, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
extern lam_class_info_t lam_list_item_cls;
|
||||
extern lam_class_info_t lam_list_cls;
|
||||
extern lam_class_info_t lam_list_item_t_class_info;
|
||||
extern lam_class_info_t lam_list_t_class_info;
|
||||
typedef int lam_list_type_t;
|
||||
|
||||
|
||||
@ -37,8 +37,8 @@ typedef struct lam_list_item
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
void lam_list_item_init(lam_list_item_t *item);
|
||||
void lam_list_item_destroy(lam_list_item_t *item);
|
||||
void lam_list_item_construct(lam_list_item_t *item);
|
||||
void lam_list_item_destruct(lam_list_item_t *item);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
@ -68,8 +68,8 @@ typedef struct lam_list
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
void lam_list_init(lam_list_t *list);
|
||||
void lam_list_destroy(lam_list_t *list);
|
||||
void lam_list_construct(lam_list_t *list);
|
||||
void lam_list_destruct(lam_list_t *list);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -2,17 +2,30 @@
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file Implementation of lam_object_t, the base lam foundation class
|
||||
*/
|
||||
|
||||
#include "lam/lfc/object.h"
|
||||
|
||||
lam_class_info_t lam_object_cls = { "lam_object_t", 0, lam_obj_init, lam_obj_destroy };
|
||||
|
||||
void lam_obj_init(lam_object_t *obj)
|
||||
void lam_object_construct(lam_object_t * obj)
|
||||
{
|
||||
obj->obj_refcnt = 1;
|
||||
obj->obj_reference_count = 1;
|
||||
}
|
||||
|
||||
void lam_obj_destroy(lam_object_t *obj)
|
||||
|
||||
void lam_object_destruct(lam_object_t * obj)
|
||||
{
|
||||
/* Move along, nothing to see here! */
|
||||
}
|
||||
|
||||
|
||||
lam_class_info_t lam_object_t_class_info = {
|
||||
"lam_object_t",
|
||||
0,
|
||||
lam_object_construct,
|
||||
lam_object_destruct
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
@ -2,97 +2,167 @@
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file:
|
||||
*
|
||||
* Simple C-language object-oriented system with single inheritance
|
||||
* and ownership-based memory management using a retain/release model.
|
||||
*
|
||||
* A class consists of a struct and singly-instantiated "class info"
|
||||
* descriptor. The first element of the struct must be the parent
|
||||
* class. The class descriptor together with a single instance of a
|
||||
* class descriptor with a well-known name based upon the class struct
|
||||
* name: If the struct is sally_t, the class info descriptor should be
|
||||
* xxx_t_class_info
|
||||
*
|
||||
* (a) To define a class
|
||||
*
|
||||
* In a interface (.h) file, define the class. The first element
|
||||
* should always be the parent class, and be called "super",
|
||||
* for example
|
||||
*
|
||||
* typedef struct sally_t sally_t;
|
||||
* struct sally_t
|
||||
* {
|
||||
* parent_t super;
|
||||
* void *first_member;
|
||||
* ...
|
||||
* };
|
||||
*
|
||||
* extern lam_class_info_t sally_t_class_info;
|
||||
*
|
||||
* All classes must have a parent.
|
||||
*
|
||||
* In an implementation (.c) file, instantiate a class info descriptor
|
||||
* for this class, and should be the name of the class with
|
||||
* "_class_info" appended:
|
||||
*
|
||||
* lam_class_info_t sally_t_class_info = {
|
||||
* "sally_t",
|
||||
* CLASS_INFO(parent_t), // pointer to parent_t_class_info
|
||||
* sally_construct,
|
||||
* sally_destruct
|
||||
* };
|
||||
*
|
||||
* This variable should be publically advertised using the "extern"
|
||||
* statement in the interface file as shown above.
|
||||
*
|
||||
* sally_construct, and sally_destruct are function pointers to the
|
||||
* constructor and destructor for the class and are best defined as
|
||||
* static functions in the implementation file.
|
||||
*
|
||||
* The first thing sally_construct should do is run its parent's
|
||||
* constructor using the OBJ_CONSTRUCT_SUPER macro:
|
||||
*
|
||||
* OBJ_CONSTRUCT_SUPER(obj, type_of_parent);
|
||||
*
|
||||
* Similarly, the las thing sally_destruct should do is run its
|
||||
* parents' destructor.
|
||||
*
|
||||
* OBJ_DESTRUCT_SUPER(obj, type_of_parent);
|
||||
*
|
||||
* Other class methods may be added to the struct.
|
||||
*
|
||||
* (b) Class instantiation: dynamic
|
||||
*
|
||||
* To create a instance of a class (an object) use OBJ_NEW:
|
||||
*
|
||||
* sally_t *sally = OBJ_NEW(sally_t);
|
||||
*
|
||||
* which allocates memory of sizeof(sally_t) and runs the class's
|
||||
* "init" method.
|
||||
*
|
||||
* Use OBJ_RETAIN, OBJ_RELEASE to do reference-count-based
|
||||
* memory management:
|
||||
*
|
||||
* OBJ_RETAIN(sally);
|
||||
* OBJ_RELEASE(sally);
|
||||
* OBJ_RELEASE(sally);
|
||||
*
|
||||
* When the reference count reaches zero, the class's "fini" method
|
||||
* is run and the memory is freed.
|
||||
*
|
||||
* N.B. There is no explicit free/delete method for dynamic objects in
|
||||
* this model.
|
||||
*
|
||||
* (c) Class instantiation: static
|
||||
*
|
||||
* For an object with static (or stack) allocation, it is only
|
||||
* necessary to initialize the memory, which is done using
|
||||
* OBJ_CONSTRUCT:
|
||||
*
|
||||
* sally_t sally;
|
||||
*
|
||||
* OBJ_CONSTRUCT(&sally, sally_t);
|
||||
*
|
||||
* The retain/release model is not necessary here, but before the
|
||||
* object goes out of scope, OBJ_DESTRUCT should be run to release
|
||||
* initialized resources:
|
||||
*
|
||||
* OBJ_DESTRUCT(&sally);
|
||||
*/
|
||||
|
||||
#ifndef LAM_OBJECT_H
|
||||
#define LAM_OBJECT_H
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lam/types.h"
|
||||
#include "lam/atomic.h"
|
||||
#include "lam/mem/malloc.h"
|
||||
|
||||
/*
|
||||
*
|
||||
* Base data structures
|
||||
*
|
||||
* Class definition
|
||||
*/
|
||||
|
||||
struct lam_object;
|
||||
typedef struct lam_object_t lam_object_t;
|
||||
typedef struct lam_class_info_t lam_class_info_t;
|
||||
typedef void (*lam_construct_t) (lam_object_t *);
|
||||
typedef void (*lam_destruct_t) (lam_object_t *);
|
||||
|
||||
typedef void (*class_init_t)(struct lam_object *);
|
||||
typedef void (*class_destroy_t)(struct lam_object *);
|
||||
|
||||
typedef struct lam_class_info
|
||||
{
|
||||
struct lam_class_info_t {
|
||||
const char *cls_name;
|
||||
struct lam_class_info *cls_parent;
|
||||
class_init_t cls_init;
|
||||
class_destroy_t cls_destroy;
|
||||
} lam_class_info_t;
|
||||
lam_class_info_t *cls_parent;
|
||||
lam_construct_t cls_construct;
|
||||
lam_destruct_t cls_destruct;
|
||||
};
|
||||
|
||||
extern lam_class_info_t lam_object_t_class_info;
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Available Classes
|
||||
*
|
||||
/**
|
||||
* Base object for the class system. This is special and does not
|
||||
* follow the pattern for other classes.
|
||||
*/
|
||||
struct lam_object_t {
|
||||
lam_class_info_t *obj_class_info; /**< class information */
|
||||
int obj_reference_count; /**< reference count for the class */
|
||||
};
|
||||
|
||||
extern lam_class_info_t lam_object_cls;
|
||||
extern void lam_object_construct(lam_object_t *obj);
|
||||
extern void lam_object_destruct(lam_object_t *obj);
|
||||
|
||||
/*
|
||||
|
||||
/* Inline functions and prototypes *******************************/
|
||||
|
||||
/**
|
||||
* Create new object: dynamically allocate storage and run the class
|
||||
* constructor.
|
||||
*
|
||||
* Helpful macros
|
||||
* Do not use this function directly: use OBJ_NEW() instead.
|
||||
*
|
||||
* @param size Size of the object
|
||||
* @param size Pointer to the class info struct for this class
|
||||
* @return Pointer to the object
|
||||
*/
|
||||
|
||||
#define SUPER(obj) (&((obj)->super))
|
||||
|
||||
/* Use STATIC_INIT to initialize objects that are not
|
||||
dynamically allocated. */
|
||||
#define STATIC_INIT(obj, cls_ptr) \
|
||||
do { \
|
||||
OBJECT(&(obj))->obj_class = cls_ptr; \
|
||||
OBJECT(&(obj))->obj_class->cls_init(OBJECT(&(obj))); \
|
||||
} while (0)
|
||||
|
||||
/* Use STATIC_DESTROY to destroy an object that is not
|
||||
dynamically allocated. */
|
||||
#define STATIC_DESTROY(obj) \
|
||||
do { \
|
||||
OBJECT(&(obj))->obj_class->cls_destroy(OBJECT(&(obj))); \
|
||||
} while (0)
|
||||
|
||||
/* super_cls should be the pointer to the obj's parent
|
||||
class info struct. */
|
||||
#define SUPER_INIT(obj, super_cls) \
|
||||
do { \
|
||||
(super_cls)->cls_init(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
#define SUPER_DESTROY(obj, super_cls) (super_cls)->cls_destroy(OBJECT(obj))
|
||||
#define OBJECT(obj) ((lam_object_t *)(obj))
|
||||
#define OBJ_RETAIN(obj) if ( obj ) lam_obj_retain(OBJECT(obj))
|
||||
#define OBJ_RELEASE(obj) if ( obj ) lam_obj_release(OBJECT(obj))
|
||||
|
||||
#define OBJ_CREATE(obj_type, class_info) \
|
||||
((obj_type*)lam_create_object(sizeof(obj_type), class_info))
|
||||
|
||||
|
||||
typedef struct lam_object
|
||||
{
|
||||
lam_class_info_t *obj_class;
|
||||
int obj_refcnt;
|
||||
} lam_object_t;
|
||||
|
||||
void lam_obj_init(lam_object_t *obj);
|
||||
void lam_obj_destroy(lam_object_t *obj);
|
||||
|
||||
|
||||
static inline lam_object_t* lam_create_object(size_t size, lam_class_info_t* class_info)
|
||||
static inline lam_object_t *lam_new(size_t size,
|
||||
lam_class_info_t *
|
||||
class_info)
|
||||
{
|
||||
lam_object_t *obj = (lam_object_t *) malloc(size);
|
||||
if ( NULL != obj ) {
|
||||
obj->obj_class = class_info;
|
||||
obj->obj_class->cls_init(obj);
|
||||
if (NULL != obj) {
|
||||
obj->obj_class_info = class_info;
|
||||
obj->obj_class_info->cls_construct(obj);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
@ -104,29 +174,188 @@ static inline lam_object_t* lam_create_object(size_t size, lam_class_info_t* cla
|
||||
*/
|
||||
static inline int fetchNadd(volatile int *addr, int inc);
|
||||
|
||||
/*
|
||||
returns 1 if object's class is derived from cls, otherwise 0.
|
||||
/**
|
||||
* Test if object inherits from class
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @param class Class to query
|
||||
* @return 1 if the object is of, or derived from, typ
|
||||
*
|
||||
*/
|
||||
int lam_obj_is_kind_of(lam_object_t *obj, lam_class_info_t *cls);
|
||||
#define OBJ_IS_KIND_OF(obj, class) lam_obj_is_kind_of(obj, class ## _class_info)
|
||||
|
||||
|
||||
/**
|
||||
* Test if object inherits from class.
|
||||
*
|
||||
* Do not use this function directly: use OBJ_IS_KIND_OF instead.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @param class Class to query
|
||||
* @return 1 if the object is of, or derived from, this class
|
||||
*/
|
||||
static inline int lam_obj_is_kind_of(lam_object_t *obj,
|
||||
lam_class_info_t *class_info)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the reference count of this object.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @return The reference count value
|
||||
*/
|
||||
static inline int lam_obj_get_ref_count(lam_object_t *obj)
|
||||
{
|
||||
return obj->obj_refcnt;
|
||||
return obj->obj_reference_count;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retain an object (by incrementing its reference count)
|
||||
*
|
||||
* Do not use this function directly: use OBJ_RETAIN instead.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
*/
|
||||
static inline void lam_obj_retain(lam_object_t *obj)
|
||||
{
|
||||
fetchNadd(&obj->obj_refcnt, 1);
|
||||
fetchNadd(&obj->obj_reference_count, 1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Release an object (by decrementing its reference count). If the
|
||||
* reference count reaches zero, destruct (finalize) the object and
|
||||
* free its storage.
|
||||
*
|
||||
* Do not use this function directly: use OBJ_RELEASE instead.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
*/
|
||||
static inline void lam_obj_release(lam_object_t *obj)
|
||||
{
|
||||
if ( fetchNadd(&obj->obj_refcnt, -1) == 1 )
|
||||
{
|
||||
obj->obj_class->cls_destroy(obj);
|
||||
if (fetchNadd(&obj->obj_reference_count, -1) == 1) {
|
||||
obj->obj_class_info->cls_destruct(obj);
|
||||
free(obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* LAM_OBJECT_H */
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a pointer to the object cast to the base object type
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @return Cast pointer to the object
|
||||
*/
|
||||
#define OBJECT(obj) ((lam_object_t *)(obj))
|
||||
|
||||
|
||||
/**
|
||||
* Return a pointer to the class info descriptor associated with a
|
||||
* class type.
|
||||
*
|
||||
* @param type Name of class
|
||||
* @return Pointer to class info descriptor
|
||||
*/
|
||||
#define CLASS_INFO(type) (&(type ## _class_info))
|
||||
|
||||
|
||||
/**
|
||||
* Return a pointer to the parent of the object
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @return Pointer to the parent object
|
||||
*/
|
||||
#define OBJ_SUPER(obj) (&((obj)->super))
|
||||
|
||||
|
||||
/**
|
||||
* Create an object: dynamically allocate storage and run the class
|
||||
* constructor.
|
||||
*
|
||||
* @param type Type (class) of the object
|
||||
* @return Pointer to the object
|
||||
*/
|
||||
#define OBJ_NEW(type) \
|
||||
((type *) lam_new(sizeof(type), CLASS_INFO(type)))
|
||||
|
||||
|
||||
/**
|
||||
* Retain an object (by incrementing its reference count)
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
*/
|
||||
#define OBJ_RETAIN(obj) \
|
||||
do { \
|
||||
if (obj) lam_obj_retain(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Release an object (by decrementing its reference count). If the
|
||||
* reference count reaches zero, destruct (finalize) the object and
|
||||
* free its storage.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
*/
|
||||
#define OBJ_RELEASE(obj) \
|
||||
do { \
|
||||
if (obj) lam_obj_release(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Construct (initialize) objects that are not dynamically allocated.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @param type The object type
|
||||
*/
|
||||
#define OBJ_CONSTRUCT(obj, type) \
|
||||
do { \
|
||||
OBJECT(obj)->obj_class_info = CLASS_INFO(type); \
|
||||
OBJECT(obj)->obj_class_info->cls_construct(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Destruct (finalize) an object that is not dynamically allocated.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
*/
|
||||
#define OBJ_DESTRUCT(obj) \
|
||||
do { \
|
||||
OBJECT(obj)->obj_class_info->cls_destruct(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Construct (initialize) the parent object
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @param super_type Type of the parent object
|
||||
*/
|
||||
#define OBJ_CONSTRUCT_SUPER(obj, super_type) \
|
||||
do { \
|
||||
CLASS_INFO(super_type)->cls_construct(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
|
||||
/**
|
||||
* Destruct (finalize) the parent object.
|
||||
*
|
||||
* @param obj Pointer to the object
|
||||
* @param super_type Type of the parent object
|
||||
*/
|
||||
#define OBJ_DESTRUCT_SUPER(obj, super_type) \
|
||||
do { \
|
||||
CLASS_INFO(super_type)->cls_destruct(OBJECT(obj)); \
|
||||
} while (0)
|
||||
|
||||
#endif /* LAM_OBJECT_H */
|
||||
|
@ -8,12 +8,17 @@
|
||||
void *lam_allocator_malloc(lam_allocator_t *allocator, size_t chunk_size);
|
||||
void lam_allocator_default_free(lam_allocator_t *allocator, void *base_ptr);
|
||||
|
||||
lam_class_info_t allocator_cls = {"lam_allocator_t", &lam_object_cls,
|
||||
(class_init_t)lam_allocator_init, (class_destroy_t)lam_obj_destroy};
|
||||
lam_class_info_t lam_allocator_t_class_info = {
|
||||
"lam_allocator_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_allocator_construct,
|
||||
(lam_destruct_t) lam_object_destruct
|
||||
};
|
||||
|
||||
void lam_allocator_init(lam_allocator_t *allocator)
|
||||
|
||||
void lam_allocator_construct(lam_allocator_t *allocator)
|
||||
{
|
||||
SUPER_INIT(allocator, &lam_object_cls);
|
||||
OBJ_CONSTRUCT_SUPER(allocator, lam_object_t);
|
||||
allocator->alc_alloc_fn = lam_allocator_malloc;
|
||||
allocator->alc_free_fn = lam_allocator_free;
|
||||
allocator->alc_is_shared = 0;
|
||||
|
@ -31,9 +31,9 @@ typedef struct lam_allocator
|
||||
void (*alc_free_fn)(struct lam_allocator *, void *);
|
||||
} lam_allocator_t;
|
||||
|
||||
extern lam_class_info_t allocator_cls;
|
||||
extern lam_class_info_t lam_allocator_t_class_info;
|
||||
|
||||
void lam_allocator_init(lam_allocator_t *allocator);
|
||||
void lam_allocator_construct(lam_allocator_t *allocator);
|
||||
|
||||
void *lam_alg_get_chunk(size_t chunk_size, int is_shared,
|
||||
int mem_protect);
|
||||
|
@ -5,25 +5,25 @@
|
||||
#include "lam/mem/free_list.h"
|
||||
|
||||
|
||||
lam_class_info_t lam_free_list_cls = {
|
||||
lam_class_info_t lam_free_list_t_class_info = {
|
||||
"lam_free_list_t",
|
||||
&lam_list_cls,
|
||||
(class_init_t)lam_free_list_init,
|
||||
(class_destroy_t)lam_free_list_destroy
|
||||
CLASS_INFO(lam_list_t),
|
||||
(lam_construct_t)lam_free_list_construct,
|
||||
(lam_destruct_t)lam_free_list_destruct
|
||||
};
|
||||
|
||||
|
||||
void lam_free_list_init(lam_free_list_t* fl)
|
||||
void lam_free_list_construct(lam_free_list_t* fl)
|
||||
{
|
||||
SUPER_INIT(fl, &lam_list_cls);
|
||||
OBJ_CONSTRUCT_SUPER(fl, lam_list_t);
|
||||
}
|
||||
|
||||
void lam_free_list_destroy(lam_free_list_t* fl)
|
||||
void lam_free_list_destruct(lam_free_list_t* fl)
|
||||
{
|
||||
SUPER_DESTROY(fl, &lam_list_cls);
|
||||
OBJ_DESTRUCT_SUPER(fl, lam_object_t);
|
||||
}
|
||||
|
||||
int lam_free_list_init_with(
|
||||
int lam_free_list_construct_with(
|
||||
lam_free_list_t *flist,
|
||||
size_t elem_size,
|
||||
lam_class_info_t* elem_class,
|
||||
@ -58,8 +58,11 @@ int lam_free_list_grow(lam_free_list_t* flist, size_t num_elements)
|
||||
|
||||
for(i=0; i<num_elements; i++) {
|
||||
lam_list_item_t* item = (lam_list_item_t*)ptr;
|
||||
if (NULL != flist->fl_elem_class)
|
||||
STATIC_INIT((*item), flist->fl_elem_class);
|
||||
if (NULL != flist->fl_elem_class) {
|
||||
/* by-pass OBJ_CONSTRUCT() in this case */
|
||||
OBJECT(item)->obj_class_info = flist->fl_elem_class;
|
||||
OBJECT(item)->obj_class_info->cls_construct(OBJECT(item));
|
||||
}
|
||||
lam_list_append(&flist->super, item);
|
||||
ptr += flist->fl_elem_size;
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "lam/mem/seg_list.h"
|
||||
#include "lam/mem/mem_pool.h"
|
||||
|
||||
extern lam_class_info_t lam_free_list_cls;
|
||||
extern lam_class_info_t lam_free_list_t_class_info;
|
||||
|
||||
|
||||
struct lam_free_list_t
|
||||
@ -28,12 +28,12 @@ struct lam_free_list_t
|
||||
typedef struct lam_free_list_t lam_free_list_t;
|
||||
|
||||
|
||||
void lam_free_list_init(lam_free_list_t *flist);
|
||||
void lam_free_list_destroy(lam_free_list_t *flist);
|
||||
void lam_free_list_construct(lam_free_list_t *flist);
|
||||
void lam_free_list_destruct(lam_free_list_t *flist);
|
||||
int lam_free_list_grow(lam_free_list_t* flist, size_t num_elements);
|
||||
|
||||
|
||||
int lam_free_list_init_with(
|
||||
int lam_free_list_construct_with(
|
||||
lam_free_list_t *flist,
|
||||
size_t element_size,
|
||||
lam_class_info_t* element_class,
|
||||
|
@ -25,19 +25,23 @@ static int lam_free_lists_create_more_elts(lam_free_lists_t *flist, int pool_idx
|
||||
|
||||
static void *lam_free_lists_get_mem_chunk(lam_free_lists_t *flist, int index, size_t *len, int *err);
|
||||
|
||||
static int lam_free_lists_mem_pool_init(lam_free_lists_t *flist, int nlists, long pages_per_list, ssize_t chunk_size,
|
||||
static int lam_free_lists_mem_pool_construct(lam_free_lists_t *flist, int nlists, long pages_per_list, ssize_t chunk_size,
|
||||
size_t page_size, long min_pages_per_list,
|
||||
long default_min_pages_per_list, long default_pages_per_list,
|
||||
long max_pages_per_list, ssize_t max_mem_in_pool);
|
||||
|
||||
lam_class_info_t lam_free_lists_cls = {"lam_free_lists_t", &lam_object_cls,
|
||||
(class_init_t)lam_free_lists_init, (class_destroy_t)lam_free_lists_destroy};
|
||||
lam_class_info_t lam_free_lists_t_class_info = {
|
||||
"lam_free_lists_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_free_lists_construct,
|
||||
(lam_destruct_t) lam_free_lists_destruct
|
||||
};
|
||||
|
||||
|
||||
void lam_free_lists_init(lam_free_lists_t *flist)
|
||||
void lam_free_lists_construct(lam_free_lists_t *flist)
|
||||
{
|
||||
SUPER_INIT(flist, lam_free_lists_cls.cls_parent);
|
||||
lam_mutex_init(&flist->fl_lock);
|
||||
OBJ_CONSTRUCT_SUPER(flist, lam_object_t);
|
||||
lam_mutex_construct(&flist->fl_lock);
|
||||
flist->fl_pool = NULL;
|
||||
flist->fl_elt_cls = NULL;
|
||||
flist->fl_description = NULL;
|
||||
@ -62,7 +66,7 @@ void lam_free_lists_init(lam_free_lists_t *flist)
|
||||
}
|
||||
|
||||
|
||||
void lam_free_lists_destroy(lam_free_lists_t *flist)
|
||||
void lam_free_lists_destruct(lam_free_lists_t *flist)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -93,11 +97,11 @@ void lam_free_lists_destroy(lam_free_lists_t *flist)
|
||||
free(flist->fl_chunks_returned);
|
||||
#endif
|
||||
|
||||
SUPER_DESTROY(flist, lam_free_lists_cls.cls_parent);
|
||||
OBJ_DESTRUCT_SUPER(flist, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
int lam_free_lists_init_with(
|
||||
int lam_free_lists_construct_with(
|
||||
lam_free_lists_t *flist,
|
||||
int nlists,
|
||||
int pages_per_list,
|
||||
@ -113,7 +117,7 @@ int lam_free_lists_init_with(
|
||||
bool enforce_affinity,
|
||||
lam_mem_pool_t *mem_pool)
|
||||
{
|
||||
/* lam_free_lists_init must have been called prior to calling this function */
|
||||
/* lam_free_lists_construct must have been called prior to calling this function */
|
||||
size_t max_mem_in_pool;
|
||||
size_t initial_mem_per_list;
|
||||
long max_mem_per_list;
|
||||
@ -133,7 +137,7 @@ int lam_free_lists_init_with(
|
||||
{
|
||||
/* instantiate memory pool */
|
||||
max_mem_in_pool = max_pages_per_list * page_size;
|
||||
err = lam_free_lists_mem_pool_init(
|
||||
err = lam_free_lists_mem_pool_construct(
|
||||
flist,
|
||||
nlists,
|
||||
pages_per_list,
|
||||
@ -205,7 +209,7 @@ int lam_free_lists_init_with(
|
||||
lam_abort(1, "Error: Out of memory");
|
||||
}
|
||||
|
||||
STATIC_INIT(flist->fl_free_lists[list], &lam_seg_list_cls);
|
||||
OBJ_CONSTRUCT(&flist->fl_free_lists[list], lam_seg_list_t);
|
||||
|
||||
lam_sgl_set_min_bytes_pushed(flist->fl_free_lists[list],
|
||||
initial_mem_per_list);
|
||||
@ -264,7 +268,7 @@ int lam_free_lists_init_with(
|
||||
}
|
||||
|
||||
|
||||
static int lam_free_lists_mem_pool_init(lam_free_lists_t *flist,
|
||||
static int lam_free_lists_mem_pool_construct(lam_free_lists_t *flist,
|
||||
int nlists, long pages_per_list, ssize_t chunk_size,
|
||||
size_t page_size, long min_pages_per_list,
|
||||
long default_min_pages_per_list, long default_pages_per_list,
|
||||
@ -297,14 +301,15 @@ static int lam_free_lists_mem_pool_init(lam_free_lists_t *flist,
|
||||
(lam_mem_pool_t *)lam_fmp_get_mem_segment(&lam_shmem_pools,
|
||||
to_alloc,
|
||||
CACHE_ALIGNMENT, 0);
|
||||
if ( flist->fl_pool )
|
||||
STATIC_INIT(flist->fl_pool, &shmem_pool_cls);
|
||||
if ( flist->fl_pool ) {
|
||||
OBJ_CONSTRUCT(&flist->fl_pool, shmem_pool_t);
|
||||
}
|
||||
} else {
|
||||
/* process private memory allocation */
|
||||
flist->fl_pool = OBJ_CREATE(lam_mem_pool_t, &mem_pool_cls);
|
||||
flist->fl_pool = OBJ_NEW(lam_mem_pool_t);
|
||||
}
|
||||
|
||||
err = lam_mp_init_with(
|
||||
err = lam_mp_construct_with(
|
||||
flist->fl_pool,
|
||||
mem_in_pool,
|
||||
max_mem_in_pool,
|
||||
@ -449,7 +454,9 @@ static int lam_free_lists_create_more_elts(lam_free_lists_t *flist, int pool_idx
|
||||
current_loc = (char *) ptr;
|
||||
for (desc = 0; desc < flist->fl_elt_per_chunk; desc++)
|
||||
{
|
||||
STATIC_INIT(*(lam_list_item_t *)current_loc, flist->fl_elt_cls);
|
||||
/* bypass OBJ_CONSTRUCT() */
|
||||
OBJECT(current_loc)->obj_class_info = flist->fl_elt_cls;
|
||||
OBJECT(current_loc)->obj_class_info->cls_construct(OBJECT(current_loc));
|
||||
current_loc += flist->fl_elt_size;
|
||||
}
|
||||
|
||||
|
@ -49,13 +49,13 @@ struct lam_free_lists_t
|
||||
typedef struct lam_free_lists_t lam_free_lists_t;
|
||||
|
||||
|
||||
extern lam_class_info_t lam_free_lists_cls;
|
||||
extern lam_class_info_t lam_free_lists_t_class_info;
|
||||
|
||||
void lam_free_lists_init(lam_free_lists_t *flist);
|
||||
void lam_free_lists_destroy(lam_free_lists_t *flist);
|
||||
void lam_free_lists_construct(lam_free_lists_t *flist);
|
||||
void lam_free_lists_destruct(lam_free_lists_t *flist);
|
||||
|
||||
/* lam_frl_init must have been called prior to calling this function */
|
||||
int lam_free_lists_init_with(lam_free_lists_t *flist,
|
||||
/* lam_frl_construct must have been called prior to calling this function */
|
||||
int lam_free_lists_construct_with(lam_free_lists_t *flist,
|
||||
int nlists,
|
||||
int pages_per_list,
|
||||
size_t chunk_size,
|
||||
|
@ -18,8 +18,8 @@ int lam_setup_per_proc_shmem_pools(int npools)
|
||||
ssize_t min_alloc_size = 4 * getpagesize();
|
||||
int n_array_elts_add = 10;
|
||||
|
||||
STATIC_INIT(lam_per_proc_shmem_pools, &fixed_mem_pool_cls);
|
||||
lam_fmp_init_with(&lam_per_proc_shmem_pools,
|
||||
OBJ_CONSTRUCT(&lam_per_proc_shmem_pools, lam_fixed_mpool_t);
|
||||
lam_fmp_construct_with(&lam_per_proc_shmem_pools,
|
||||
initial_alloc, min_alloc_size,
|
||||
npools, n_array_elts_add, 1);
|
||||
|
||||
|
@ -16,43 +16,51 @@
|
||||
#include "lam/util/output.h"
|
||||
#include "lam/os/numa.h"
|
||||
|
||||
lam_class_info_t mem_pool_cls = {"lam_mem_pool_t", &lam_object_cls,
|
||||
(class_init_t)lam_mp_init, (class_destroy_t)lam_mp_destroy};
|
||||
lam_class_info_t lam_mem_pool_t_class_info = {
|
||||
"lam_mem_pool_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_mp_construct,
|
||||
(lam_destruct_t) lam_mp_destruct
|
||||
};
|
||||
|
||||
/* process-shared mem pool class */
|
||||
lam_class_info_t shmem_pool_cls = {"shmem_pool_t", &lam_object_cls,
|
||||
(class_init_t)lam_mp_shared_init, (class_destroy_t)lam_mp_destroy};
|
||||
lam_class_info_t shmem_pool_t_class_info = {
|
||||
"shmem_pool_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_mp_shared_construct,
|
||||
(lam_destruct_t) lam_mp_destruct
|
||||
};
|
||||
|
||||
void lam_mp_init(lam_mem_pool_t *pool)
|
||||
void lam_mp_construct(lam_mem_pool_t *pool)
|
||||
{
|
||||
SUPER_INIT(pool, mem_pool_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(pool, lam_object_t);
|
||||
|
||||
pool->mp_private_alloc = OBJ_CREATE(lam_allocator_t, &allocator_cls);
|
||||
lam_mutex_init(&(pool->mp_lock));
|
||||
pool->mp_private_alloc = OBJ_NEW(lam_allocator_t);
|
||||
lam_mutex_construct(&(pool->mp_lock));
|
||||
pool->mp_dev_alloc = NULL;
|
||||
}
|
||||
|
||||
void lam_mp_shared_init(lam_mem_pool_t *pool)
|
||||
void lam_mp_shared_construct(lam_mem_pool_t *pool)
|
||||
{
|
||||
SUPER_INIT(pool, shmem_pool_cls.cls_parent);
|
||||
OBJ_CONSTRUCT_SUPER(pool, lam_object_t);
|
||||
|
||||
pool->mp_private_alloc = OBJ_CREATE(lam_allocator_t, &allocator_cls);
|
||||
lam_mutex_init(&(pool->mp_lock));
|
||||
pool->mp_private_alloc = OBJ_NEW(lam_allocator_t);
|
||||
lam_mutex_construct(&(pool->mp_lock));
|
||||
lam_allocator_set_is_shared(pool->mp_private_alloc, 1);
|
||||
lam_allocator_set_mem_prot(pool->mp_private_alloc, MMAP_SHARED_PROT);
|
||||
pool->mp_dev_alloc = NULL;
|
||||
}
|
||||
|
||||
void lam_mp_destroy(lam_mem_pool_t *pool)
|
||||
void lam_mp_destruct(lam_mem_pool_t *pool)
|
||||
{
|
||||
if ( pool->mp_dev_alloc )
|
||||
OBJ_RELEASE(pool->mp_dev_alloc);
|
||||
OBJ_RELEASE(pool->mp_private_alloc);
|
||||
|
||||
SUPER_DESTROY(pool, &lam_object_cls);
|
||||
OBJ_DESTRUCT_SUPER(pool, lam_object_t);
|
||||
}
|
||||
|
||||
int lam_mp_init_with(lam_mem_pool_t *pool, uint64_t pool_size,
|
||||
int lam_mp_construct_with(lam_mem_pool_t *pool, uint64_t pool_size,
|
||||
uint64_t max_len,
|
||||
uint64_t chunk_size, size_t page_size)
|
||||
{
|
||||
@ -269,14 +277,18 @@ void *lam_mp_request_chunk(lam_mem_pool_t *pool, int pool_index)
|
||||
*/
|
||||
|
||||
|
||||
lam_class_info_t fixed_mem_pool_cls = {"lam_fixed_mpool_t", &lam_object_cls,
|
||||
(class_init_t)lam_fmp_init, (class_destroy_t)lam_fmp_destroy};
|
||||
lam_class_info_t lam_fixed_mpool_t_class_info = {
|
||||
"lam_fixed_mpool_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_fmp_construct,
|
||||
(lam_destruct_t) lam_fmp_destruct
|
||||
};
|
||||
|
||||
void lam_fmp_init(lam_fixed_mpool_t *pool)
|
||||
void lam_fmp_construct(lam_fixed_mpool_t *pool)
|
||||
{
|
||||
SUPER_INIT(pool, &lam_object_cls);
|
||||
OBJ_CONSTRUCT_SUPER(pool, lam_object_t);
|
||||
|
||||
pool->fmp_private_alloc = OBJ_CREATE(lam_allocator_t, &allocator_cls);
|
||||
pool->fmp_private_alloc = OBJ_NEW(lam_allocator_t);
|
||||
lam_allocator_set_is_shared(pool->fmp_private_alloc, 1);
|
||||
lam_allocator_set_mem_prot(pool->fmp_private_alloc, MMAP_SHARED_PROT);
|
||||
|
||||
@ -290,7 +302,7 @@ void lam_fmp_init(lam_fixed_mpool_t *pool)
|
||||
pool->fmp_apply_affinity = 0;
|
||||
}
|
||||
|
||||
void lam_fmp_destroy(lam_fixed_mpool_t *pool)
|
||||
void lam_fmp_destruct(lam_fixed_mpool_t *pool)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -307,12 +319,12 @@ void lam_fmp_destroy(lam_fixed_mpool_t *pool)
|
||||
if ( pool->fmp_n_segs_in_array )
|
||||
free(pool->fmp_n_segs_in_array);
|
||||
|
||||
SUPER_DESTROY(pool, &lam_object_cls);
|
||||
OBJ_DESTRUCT_SUPER(pool, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
||||
int lam_fmp_init_with(lam_fixed_mpool_t *pool, ssize_t initial_allocation,
|
||||
int lam_fmp_construct_with(lam_fixed_mpool_t *pool, ssize_t initial_allocation,
|
||||
ssize_t min_allocation_size,
|
||||
int n_pools, int n_array_elements_to_add, int apply_mem_affinity)
|
||||
{
|
||||
|
@ -18,10 +18,10 @@
|
||||
|
||||
/*
|
||||
To create a process-private pool, use
|
||||
CREATE_OBJECT(pool, lam_mem_pool_t, &mem_pool_cls);
|
||||
pool = OBJ_NEW(lam_mem_pool_t);
|
||||
|
||||
To create a process-shared pool, use
|
||||
CREATE_OBJECT(pool, lam_mem_pool_t, &shmem_pool_cls);
|
||||
pool = OBJ_NEW(lam_shmem_pool_t);
|
||||
*/
|
||||
|
||||
typedef struct lam_chunk_desc
|
||||
@ -46,16 +46,16 @@ typedef struct lam_mem_pool
|
||||
} lam_mem_pool_t;
|
||||
|
||||
/* process-private mem pool class */
|
||||
extern lam_class_info_t mem_pool_cls;
|
||||
extern lam_class_info_t lam_mem_pool_t_class_info;
|
||||
|
||||
/* process-shared mem pool class */
|
||||
extern lam_class_info_t shmem_pool_cls;
|
||||
extern lam_class_info_t shmem_pool_t_class_info;
|
||||
|
||||
void lam_mp_init(lam_mem_pool_t *pool);
|
||||
void lam_mp_shared_init(lam_mem_pool_t *pool);
|
||||
void lam_mp_destroy(lam_mem_pool_t *pool);
|
||||
void lam_mp_construct(lam_mem_pool_t *pool);
|
||||
void lam_mp_shared_construct(lam_mem_pool_t *pool);
|
||||
void lam_mp_destruct(lam_mem_pool_t *pool);
|
||||
|
||||
int lam_mp_init_with(lam_mem_pool_t *pool, uint64_t pool_size,
|
||||
int lam_mp_construct_with(lam_mem_pool_t *pool, uint64_t pool_size,
|
||||
uint64_t max_len,
|
||||
uint64_t chunk_size, size_t pg_size);
|
||||
|
||||
@ -121,11 +121,11 @@ typedef struct lam_fixed_mpool
|
||||
int fmp_apply_affinity;
|
||||
} lam_fixed_mpool_t;
|
||||
|
||||
extern lam_class_info_t fixed_mem_pool_cls;
|
||||
extern lam_class_info_t lam_fixed_mpool_t_class_info;
|
||||
|
||||
void lam_fmp_init(lam_fixed_mpool_t *pool);
|
||||
void lam_fmp_destroy(lam_fixed_mpool_t *pool);
|
||||
int lam_fmp_init_with(lam_fixed_mpool_t *pool, ssize_t initial_allocation,
|
||||
void lam_fmp_construct(lam_fixed_mpool_t *pool);
|
||||
void lam_fmp_destruct(lam_fixed_mpool_t *pool);
|
||||
int lam_fmp_construct_with(lam_fixed_mpool_t *pool, ssize_t initial_allocation,
|
||||
ssize_t min_allocation_size,
|
||||
int n_pools, int n_array_elements_to_add, int apply_mem_affinity);
|
||||
void *lam_fmp_get_mem_segment(lam_fixed_mpool_t *pool,
|
||||
|
@ -8,14 +8,18 @@
|
||||
/*
|
||||
* Public variable
|
||||
*/
|
||||
lam_class_info_t lam_seg_list_cls = {"lam_seg_list_t", &lam_object_cls,
|
||||
(class_init_t)lam_sgl_init, (class_destroy_t)lam_sgl_destroy};
|
||||
lam_class_info_t lam_seg_list_t_class_info = {
|
||||
"lam_seg_list_t",
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_sgl_construct,
|
||||
(lam_destruct_t) lam_sgl_destruct
|
||||
};
|
||||
|
||||
void lam_sgl_init(lam_seg_list_t *slist)
|
||||
void lam_sgl_construct(lam_seg_list_t *slist)
|
||||
{
|
||||
SUPER_INIT(slist, lam_seg_list_cls.cls_parent);
|
||||
STATIC_INIT(slist->sgl_list, &lam_list_cls);
|
||||
lam_mutex_init(&slist->sgl_lock);
|
||||
OBJ_CONSTRUCT_SUPER(slist, lam_object_t);
|
||||
OBJ_CONSTRUCT(&slist->sgl_list, lam_list_t);
|
||||
lam_mutex_construct(&slist->sgl_lock);
|
||||
slist->sgl_min_bytes_pushed = 0;
|
||||
slist->sgl_max_bytes_pushed = 0;
|
||||
slist->sgl_bytes_pushed = 0;
|
||||
@ -23,10 +27,10 @@ void lam_sgl_init(lam_seg_list_t *slist)
|
||||
slist->sgl_consec_fail = 0;
|
||||
}
|
||||
|
||||
void lam_sgl_destroy(lam_seg_list_t *slist)
|
||||
void lam_sgl_destruct(lam_seg_list_t *slist)
|
||||
{
|
||||
lam_list_destroy(&(slist->sgl_list));
|
||||
SUPER_DESTROY(slist, lam_seg_list_cls.cls_parent);
|
||||
lam_list_destruct(&(slist->sgl_list));
|
||||
OBJ_DESTRUCT_SUPER(slist, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,10 +22,10 @@ struct lam_seg_list_t
|
||||
};
|
||||
typedef struct lam_seg_list_t lam_seg_list_t;
|
||||
|
||||
extern lam_class_info_t lam_seg_list_cls;
|
||||
extern lam_class_info_t lam_seg_list_t_class_info;
|
||||
|
||||
void lam_sgl_init(lam_seg_list_t *slist);
|
||||
void lam_sgl_destroy(lam_seg_list_t *slist);
|
||||
void lam_sgl_construct(lam_seg_list_t *slist);
|
||||
void lam_sgl_destruct(lam_seg_list_t *slist);
|
||||
void lam_sgl_append_elt_chunk(
|
||||
lam_seg_list_t *slist,
|
||||
void *chunk,
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include "lam/os/atomic.h"
|
||||
typedef lam_lock_data_t lam_mutex_t;
|
||||
|
||||
#define lam_mutex_init(m) spinunlock(m)
|
||||
#define lam_mutex_destroy(m)
|
||||
#define lam_mutex_construct(m) spinunlock(m)
|
||||
#define lam_mutex_destruct(m)
|
||||
#define lam_mutex_lock(m) spinlock(m)
|
||||
#define lam_mutex_trylock(m) spintrylock(m)
|
||||
#define lam_mutex_unlock(m) spinunlock(m)
|
||||
|
@ -22,7 +22,7 @@ struct lam_mutex_t {
|
||||
struct lam_mutex_t lam_mutex_t;
|
||||
|
||||
|
||||
static inline void lam_mutex_init(lam_mutex_t* m)
|
||||
static inline void lam_mutex_construct(lam_mutex_t* m)
|
||||
{
|
||||
m->mutex_spinlock = 0;
|
||||
m->mutex_waiting = 0;
|
||||
@ -30,7 +30,7 @@ static inline void lam_mutex_init(lam_mutex_t* m)
|
||||
pthread_cond_init(&m->mutex_cond, 0);
|
||||
}
|
||||
|
||||
static inline void lam_mutex_destroy(lam_mutex_t* m)
|
||||
static inline void lam_mutex_destruct(lam_mutex_t* m)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ typedef struct lam_thread
|
||||
} lam_thread_t;
|
||||
|
||||
|
||||
void lam_thr_init(lam_thread_t *a_thread);
|
||||
void lam_thr_construct(lam_thread_t *a_thread);
|
||||
lam_thread_t *lam_thr_create(lam_object_t *arg);
|
||||
|
||||
#endif /* LAM_THREAD_H */
|
||||
|
@ -106,12 +106,12 @@ lam_cmd_line_t *lam_cmd_line_create(void)
|
||||
only thread that has this instance), there's no need to lock it
|
||||
right now. */
|
||||
|
||||
lam_mutex_init(&cmd->lcl_mutex);
|
||||
lam_mutex_construct(&cmd->lcl_mutex);
|
||||
|
||||
/* Initialize the lists */
|
||||
|
||||
lam_list_init(&cmd->lcl_options);
|
||||
lam_list_init(&cmd->lcl_params);
|
||||
lam_list_construct(&cmd->lcl_options);
|
||||
lam_list_construct(&cmd->lcl_params);
|
||||
|
||||
/* Initialize the argc/argv pairs */
|
||||
|
||||
@ -225,7 +225,7 @@ int lam_cmd_line_make_opt(lam_cmd_line_t *cmd, char short_name,
|
||||
option = malloc(sizeof(cmd_line_option_t));
|
||||
if (NULL == option)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
lam_list_item_init((lam_list_item_t *) option);
|
||||
lam_list_item_construct((lam_list_item_t *) option);
|
||||
|
||||
option->clo_short_name = short_name;
|
||||
if (NULL != long_name) {
|
||||
@ -393,7 +393,7 @@ int lam_cmd_line_parse(lam_cmd_line_t *cmd, bool ignore_unknown,
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
item = (lam_list_item_t *) param;
|
||||
lam_list_item_init(item);
|
||||
lam_list_item_construct(item);
|
||||
param->clp_arg = cmd->lcl_argv[i];
|
||||
param->clp_option = option;
|
||||
param->clp_argc = 0;
|
||||
|
@ -66,15 +66,15 @@ static int lam_ifinit(void)
|
||||
close(sd);
|
||||
return LAM_ERROR;
|
||||
}
|
||||
STATIC_INIT(lam_if_list, &lam_list_cls);
|
||||
OBJ_CONSTRUCT(&lam_if_list, lam_list_t);
|
||||
|
||||
for(ptr = buff; ptr < buff + ifconf.ifc_len; ) {
|
||||
struct ifreq* ifr = (struct ifreq*)ptr;
|
||||
lam_if_t intf;
|
||||
lam_if_t *intf_ptr;
|
||||
lam_list_item_init(&intf.if_item);
|
||||
lam_list_item_construct(&intf.if_item);
|
||||
|
||||
STATIC_INIT(intf, &lam_list_item_cls);
|
||||
OBJ_CONSTRUCT(&intf, lam_list_item_t);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
ptr += (sizeof(ifr->ifr_name) +
|
||||
|
@ -115,7 +115,7 @@ bool lam_output_init(void)
|
||||
|
||||
/* Initialize the mutex that protects the output */
|
||||
|
||||
lam_mutex_init(&mutex);
|
||||
lam_mutex_construct(&mutex);
|
||||
initialized = true;
|
||||
|
||||
/* Open the default verbose stream */
|
||||
|
@ -23,30 +23,30 @@ const int LAM_REACTOR_NOTIFY_ALL = 7;
|
||||
#define MAX_DESCRIPTOR_POOL_SIZE 256
|
||||
|
||||
|
||||
lam_class_info_t lam_reactor_cls = {
|
||||
lam_class_info_t lam_reactor_t_class_info = {
|
||||
"lam_reactor_t",
|
||||
&lam_object_cls,
|
||||
(class_init_t)lam_reactor_init,
|
||||
(class_destroy_t)lam_reactor_destroy
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t)lam_reactor_construct,
|
||||
(lam_destruct_t)lam_reactor_destruct
|
||||
};
|
||||
|
||||
lam_class_info_t lam_reactor_descriptor_cls = {
|
||||
"lam_reactor_t",
|
||||
&lam_list_item_cls,
|
||||
(class_init_t)lam_reactor_descriptor_init,
|
||||
(class_destroy_t)lam_reactor_descriptor_destroy
|
||||
lam_class_info_t lam_reactor_descriptor_t_class_info = {
|
||||
"lam_reactor_descriptor_t",
|
||||
CLASS_INFO(lam_list_item_t),
|
||||
(lam_construct_t)lam_reactor_descriptor_construct,
|
||||
(lam_destruct_t)lam_reactor_descriptor_destruct
|
||||
};
|
||||
|
||||
|
||||
void lam_reactor_descriptor_init(lam_reactor_descriptor_t* rd)
|
||||
void lam_reactor_descriptor_construct(lam_reactor_descriptor_t* rd)
|
||||
{
|
||||
SUPER_INIT(rd, &lam_list_item_cls);
|
||||
OBJ_CONSTRUCT_SUPER(rd, lam_list_item_t);
|
||||
}
|
||||
|
||||
|
||||
void lam_reactor_descriptor_destroy(lam_reactor_descriptor_t* rd)
|
||||
void lam_reactor_descriptor_destruct(lam_reactor_descriptor_t* rd)
|
||||
{
|
||||
SUPER_DESTROY(rd, &lam_list_item_cls);
|
||||
OBJ_DESTRUCT_SUPER(rd, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ static inline lam_reactor_descriptor_t* lam_reactor_get_descriptor(lam_reactor_t
|
||||
if(lam_list_get_size(&r->r_free)) {
|
||||
descriptor = (lam_reactor_descriptor_t*)lam_list_remove_first(&r->r_free);
|
||||
} else {
|
||||
descriptor = OBJ_CREATE(lam_reactor_descriptor_t, &lam_reactor_descriptor_cls);
|
||||
descriptor = OBJ_NEW(lam_reactor_descriptor_t);
|
||||
}
|
||||
if (NULL == descriptor) {
|
||||
return 0;
|
||||
@ -70,15 +70,15 @@ static inline lam_reactor_descriptor_t* lam_reactor_get_descriptor(lam_reactor_t
|
||||
}
|
||||
|
||||
|
||||
void lam_reactor_init(lam_reactor_t* r)
|
||||
void lam_reactor_construct(lam_reactor_t* r)
|
||||
{
|
||||
SUPER_INIT(r, &lam_object_cls);
|
||||
OBJ_CONSTRUCT_SUPER(r, lam_object_t);
|
||||
|
||||
lam_mutex_init(&r->r_mutex);
|
||||
lam_list_init(&r->r_active);
|
||||
lam_list_init(&r->r_free);
|
||||
lam_list_init(&r->r_pending);
|
||||
lam_fh_init(&r->r_hash);
|
||||
lam_mutex_construct(&r->r_mutex);
|
||||
lam_list_construct(&r->r_active);
|
||||
lam_list_construct(&r->r_free);
|
||||
lam_list_construct(&r->r_pending);
|
||||
lam_fh_construct(&r->r_hash);
|
||||
lam_fh_resize(&r->r_hash, 1024);
|
||||
|
||||
r->r_max = -1;
|
||||
@ -91,13 +91,13 @@ void lam_reactor_init(lam_reactor_t* r)
|
||||
}
|
||||
|
||||
|
||||
void lam_reactor_destroy(lam_reactor_t* r)
|
||||
void lam_reactor_destruct(lam_reactor_t* r)
|
||||
{
|
||||
lam_list_destroy(&r->r_active);
|
||||
lam_list_destroy(&r->r_free);
|
||||
lam_list_destroy(&r->r_pending);
|
||||
lam_fh_destroy(&r->r_hash);
|
||||
SUPER_DESTROY(r, &lam_object_cls);
|
||||
lam_list_destruct(&r->r_active);
|
||||
lam_list_destruct(&r->r_free);
|
||||
lam_list_destruct(&r->r_pending);
|
||||
lam_fh_destruct(&r->r_hash);
|
||||
OBJ_DESTRUCT_SUPER(r, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
@ -225,7 +225,7 @@ void lam_reactor_dispatch(lam_reactor_t* r, int cnt, lam_fd_set_t* rset, lam_fd_
|
||||
if(lam_list_get_size(&r->r_free) < MAX_DESCRIPTOR_POOL_SIZE) {
|
||||
lam_list_append(&r->r_free, &descriptor->super);
|
||||
} else {
|
||||
lam_reactor_descriptor_destroy(descriptor);
|
||||
lam_reactor_descriptor_destruct(descriptor);
|
||||
free(descriptor);
|
||||
}
|
||||
}
|
||||
@ -240,7 +240,7 @@ void lam_reactor_dispatch(lam_reactor_t* r, int cnt, lam_fd_set_t* rset, lam_fd_
|
||||
if(lam_list_get_size(&r->r_free) < MAX_DESCRIPTOR_POOL_SIZE) {
|
||||
lam_list_append(&r->r_free, &descriptor->super);
|
||||
} else {
|
||||
lam_reactor_descriptor_destroy(descriptor);
|
||||
lam_reactor_descriptor_destruct(descriptor);
|
||||
free(descriptor);
|
||||
}
|
||||
} else {
|
||||
|
@ -15,7 +15,7 @@ extern const int LAM_REACTOR_NOTIFY_RECV;
|
||||
extern const int LAM_REACTOR_NOTIFY_SEND;
|
||||
extern const int LAM_REACTOR_NOTIFY_EXCEPT;
|
||||
|
||||
extern lam_class_info_t lam_reactor_cls;
|
||||
extern lam_class_info_t lam_reactor_descriptor_t_class_info;
|
||||
|
||||
|
||||
/*
|
||||
@ -52,8 +52,8 @@ struct lam_reactor_descriptor_t {
|
||||
typedef struct lam_reactor_descriptor_t lam_reactor_descriptor_t;
|
||||
|
||||
|
||||
void lam_reactor_descriptor_init(lam_reactor_descriptor_t*);
|
||||
void lam_reactor_descriptor_destroy(lam_reactor_descriptor_t*);
|
||||
void lam_reactor_descriptor_construct(lam_reactor_descriptor_t*);
|
||||
void lam_reactor_descriptor_destruct(lam_reactor_descriptor_t*);
|
||||
|
||||
|
||||
struct lam_reactor_t {
|
||||
@ -73,8 +73,8 @@ struct lam_reactor_t {
|
||||
typedef struct lam_reactor_t lam_reactor_t;
|
||||
|
||||
|
||||
void lam_reactor_init(lam_reactor_t*);
|
||||
void lam_reactor_destroy(lam_reactor_t*);
|
||||
void lam_reactor_construct(lam_reactor_t*);
|
||||
void lam_reactor_destruct(lam_reactor_t*);
|
||||
|
||||
int lam_reactor_insert(lam_reactor_t*, int sd, lam_reactor_listener_t*, void* user, int flags);
|
||||
int lam_reactor_remove(lam_reactor_t*, int sd, int flags);
|
||||
|
@ -78,7 +78,7 @@ extern "C" {
|
||||
|
||||
/* mca_base_module_register.c */
|
||||
|
||||
int mca_base_module_registry_init(void);
|
||||
int mca_base_module_registry_construct(void);
|
||||
int mca_base_module_registry_retain(char *type, lt_dlhandle module_handle,
|
||||
const mca_base_module_t *module_struct);
|
||||
int mca_base_module_registry_link(const char *src_type,
|
||||
|
@ -100,13 +100,13 @@ int mca_base_module_find(const char *directory, const char *type,
|
||||
|
||||
/* Find all the modules that were statically linked in */
|
||||
|
||||
lam_list_init(found_modules);
|
||||
lam_list_construct(found_modules);
|
||||
for (i = 0; NULL != static_modules[i]; ++i) {
|
||||
mli = malloc(sizeof(mca_base_module_list_item_t));
|
||||
if (NULL == mli) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
lam_list_item_init((lam_list_item_t *) mli);
|
||||
lam_list_item_construct((lam_list_item_t *) mli);
|
||||
mli->mli_module = static_modules[i];
|
||||
lam_list_append(found_modules, (lam_list_item_t *) mli);
|
||||
}
|
||||
@ -172,7 +172,7 @@ static void find_dyn_modules(const char *path, const char *type_name,
|
||||
make a master array of all the matching filenames that we
|
||||
find. */
|
||||
|
||||
lam_list_init(&found_files);
|
||||
lam_list_construct(&found_files);
|
||||
dir = path_to_use;
|
||||
do {
|
||||
end = strchr(dir, ':');
|
||||
@ -217,7 +217,7 @@ static void find_dyn_modules(const char *path, const char *type_name,
|
||||
}
|
||||
/* JMS This list memory management may change */
|
||||
#if 0
|
||||
lam_list_destroy(&found_files);
|
||||
lam_list_destruct(&found_files);
|
||||
#endif
|
||||
free(path_to_use);
|
||||
}
|
||||
@ -269,7 +269,7 @@ static int save_filename(const char *filename, lt_ptr data)
|
||||
if (NULL == module_file) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
lam_list_item_init((lam_list_item_t *) module_file);
|
||||
lam_list_item_construct((lam_list_item_t *) module_file);
|
||||
strcpy(module_file->type, params->type);
|
||||
strcpy(module_file->name, basename + prefix_len);
|
||||
strcpy(module_file->basename, basename);
|
||||
@ -332,7 +332,7 @@ static int open_module(module_file_item_t *target_file,
|
||||
them. If we can't load them, then this module must also fail to
|
||||
load. */
|
||||
|
||||
lam_list_init(&dependencies);
|
||||
lam_list_construct(&dependencies);
|
||||
if (0 != check_laminfo(target_file, &dependencies, found_modules)) {
|
||||
target_file->status = FAILED_TO_LOAD;
|
||||
free_dependency_list(&dependencies);
|
||||
@ -372,7 +372,7 @@ static int open_module(module_file_item_t *target_file,
|
||||
free_dependency_list(&dependencies);
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
lam_list_item_init((lam_list_item_t *) mitem);
|
||||
lam_list_item_construct((lam_list_item_t *) mitem);
|
||||
|
||||
module_struct = lt_dlsym(module_handle, struct_name);
|
||||
if (NULL == module_struct) {
|
||||
@ -408,7 +408,7 @@ static int open_module(module_file_item_t *target_file,
|
||||
ditem->di_module_file_item->name);
|
||||
free(ditem);
|
||||
}
|
||||
lam_list_destroy(&dependencies);
|
||||
lam_list_destruct(&dependencies);
|
||||
|
||||
lam_output_verbose(0, 40, " opened dynamic %s MCA module \"%s\"",
|
||||
target_file->type, target_file->name, NULL);
|
||||
@ -626,7 +626,7 @@ static int check_dependency(char *line, module_file_item_t *target_file,
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
cur = (lam_list_item_t *) ditem;
|
||||
lam_list_item_init(cur);
|
||||
lam_list_item_construct(cur);
|
||||
lam_list_append(dependencies, cur);
|
||||
|
||||
/* All done -- all depenencies satisfied */
|
||||
@ -647,5 +647,5 @@ static void free_dependency_list(lam_list_t *dependencies)
|
||||
item = lam_list_remove_first(dependencies)) {
|
||||
free(item);
|
||||
}
|
||||
lam_list_destroy(dependencies);
|
||||
lam_list_destruct(dependencies);
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ static void release_registry_item(registry_item_t *ri);
|
||||
/*
|
||||
* Initialize the registry
|
||||
*/
|
||||
int mca_base_module_registry_init(void)
|
||||
int mca_base_module_registry_construct(void)
|
||||
{
|
||||
/* Setup internal structures */
|
||||
|
||||
@ -69,7 +69,7 @@ int mca_base_module_registry_init(void)
|
||||
if (lt_dlinit() != 0)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
|
||||
lam_list_init(®istry);
|
||||
lam_list_construct(®istry);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@ -96,12 +96,12 @@ int mca_base_module_registry_retain(char *type, lt_dlhandle module_handle,
|
||||
|
||||
/* Initialize the registry item */
|
||||
|
||||
lam_list_item_init((lam_list_item_t *) ri);
|
||||
lam_list_item_construct((lam_list_item_t *) ri);
|
||||
strcpy(ri->ri_type, type);
|
||||
ri->ri_dlhandle = module_handle;
|
||||
ri->ri_module_struct = module_struct;
|
||||
ri->ri_refcount = 1;
|
||||
lam_list_init(&ri->ri_dependencies);
|
||||
lam_list_construct(&ri->ri_dependencies);
|
||||
|
||||
/* Append the new item to the registry */
|
||||
|
||||
@ -234,7 +234,7 @@ static int link_items(registry_item_t *src, registry_item_t *depend)
|
||||
|
||||
/* Initialize the new dependency item */
|
||||
|
||||
lam_list_item_init((lam_list_item_t *) di);
|
||||
lam_list_item_construct((lam_list_item_t *) di);
|
||||
di->di_registry_entry = depend;
|
||||
|
||||
/* Add it to the dependency list on the source registry entry */
|
||||
@ -283,7 +283,7 @@ static void release_registry_item(registry_item_t *ri)
|
||||
pointer is no longer valid because it has [potentially] been
|
||||
unloaded from memory. So don't try to use it. :-) */
|
||||
|
||||
lam_list_destroy(&di->di_registry_entry->ri_dependencies);
|
||||
lam_list_destruct(&di->di_registry_entry->ri_dependencies);
|
||||
lam_list_remove_item(®istry, (lam_list_item_t *) ri);
|
||||
free(ri);
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ static int open_modules(const char *type_name, int output_id,
|
||||
|
||||
/* Traverse the list of found modules */
|
||||
|
||||
lam_list_init(modules_available);
|
||||
lam_list_construct(modules_available);
|
||||
for (item = lam_list_get_first(modules_found);
|
||||
lam_list_get_end(modules_found) != item;
|
||||
item = lam_list_get_next(item)) {
|
||||
@ -254,7 +254,7 @@ static int open_modules(const char *type_name, int output_id,
|
||||
if (NULL == mli) {
|
||||
return LAM_ERROR;
|
||||
}
|
||||
lam_list_item_init(&mli->super);
|
||||
lam_list_item_construct(&mli->super);
|
||||
mli->mli_module = module;
|
||||
lam_list_append(modules_available, (lam_list_item_t *) mli);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ int mca_base_open(void)
|
||||
|
||||
/* Open up the module registry */
|
||||
|
||||
return mca_base_module_registry_init();
|
||||
return mca_base_module_registry_construct();
|
||||
}
|
||||
|
||||
|
||||
|
@ -279,7 +279,7 @@ static int param_register(const char *type_name, const char *module_name,
|
||||
/* Initialize the array if it has never been initialized */
|
||||
|
||||
if (!initialized) {
|
||||
lam_arr_init(&mca_base_params);
|
||||
lam_arr_construct(&mca_base_params);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
@ -290,7 +290,7 @@ static int param_register(const char *type_name, const char *module_name,
|
||||
if (NULL == param) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
SUPER_INIT(&(param->super), &lam_object_cls);
|
||||
OBJ_CONSTRUCT_SUPER(&(param->super), lam_object_t);
|
||||
param->mbp_type = type;
|
||||
param->mbp_keyval = -1;
|
||||
|
||||
|
@ -259,7 +259,7 @@ int mca_base_param_finalize(void)
|
||||
for (i = 0; i < size; ++i)
|
||||
param_free(array[i]);
|
||||
|
||||
lam_arr_destroy(&mca_base_params);
|
||||
lam_arr_destruct(&mca_base_params);
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
@ -281,7 +281,7 @@ param_register(const char *type_name, const char *module_name, const char *param
|
||||
/* Initialize the array if it has never been initialized */
|
||||
|
||||
if (!initialized) {
|
||||
lam_arr_init(&mca_base_params);
|
||||
lam_arr_construct(&mca_base_params);
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ int mca_mpi_init_select_modules(int requested,
|
||||
allow_multi_user_threads |= user_threads;
|
||||
have_hidden_threads |= hidden_threads;
|
||||
|
||||
lam_list_init(&colls);
|
||||
lam_list_construct(&colls);
|
||||
if (LAM_SUCCESS != mca_coll_base_select(&colls, &user_threads,
|
||||
&hidden_threads)) {
|
||||
return LAM_ERROR;
|
||||
|
@ -5,20 +5,20 @@
|
||||
|
||||
#include "mca/mpi/pml/base/pml_base_request.h"
|
||||
|
||||
lam_class_info_t mca_pml_base_request_cls = {
|
||||
lam_class_info_t mca_pml_base_request_t_class_info = {
|
||||
"mca_pml_base_request_t",
|
||||
&lam_request_cls,
|
||||
(class_init_t) mca_pml_base_request_init,
|
||||
(class_destroy_t) mca_pml_base_request_destroy
|
||||
CLASS_INFO(lam_request_t),
|
||||
(lam_construct_t) mca_pml_base_request_construct,
|
||||
(lam_destruct_t) mca_pml_base_request_destruct
|
||||
};
|
||||
|
||||
void mca_pml_base_request_init(mca_pml_base_request_t* req)
|
||||
void mca_pml_base_request_construct(mca_pml_base_request_t* req)
|
||||
{
|
||||
SUPER_INIT(req, &lam_request_cls);
|
||||
OBJ_CONSTRUCT_SUPER(req, lam_request_t);
|
||||
}
|
||||
|
||||
void mca_pml_base_request_destroy(mca_pml_base_request_t* req)
|
||||
void mca_pml_base_request_destruct(mca_pml_base_request_t* req)
|
||||
{
|
||||
SUPER_DESTROY(req, &lam_request_cls);
|
||||
OBJ_DESTRUCT_SUPER(req, lam_request_t);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mpi/datatype/datatype.h"
|
||||
#include "mpi/communicator/communicator.h"
|
||||
|
||||
extern lam_class_info_t mca_pml_base_request_cls;
|
||||
extern lam_class_info_t mca_pml_base_request_t_class_info;
|
||||
|
||||
/* MPI request status */
|
||||
typedef enum {
|
||||
@ -58,8 +58,8 @@ typedef struct {
|
||||
} mca_pml_base_request_t;
|
||||
|
||||
|
||||
void mca_pml_base_request_init(mca_pml_base_request_t*);
|
||||
void mca_pml_base_request_destroy(mca_pml_base_request_t*);
|
||||
void mca_pml_base_request_construct(mca_pml_base_request_t*);
|
||||
void mca_pml_base_request_destruct(mca_pml_base_request_t*);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -47,7 +47,7 @@ int mca_pml_base_select(mca_pml_t *selected, bool *allow_multi_user_threads,
|
||||
|
||||
best_priority = -1;
|
||||
best_module = NULL;
|
||||
lam_list_init(&opened);
|
||||
lam_list_construct(&opened);
|
||||
for (item = lam_list_get_first(&mca_pml_base_modules_available);
|
||||
lam_list_get_end(&mca_pml_base_modules_available) != item;
|
||||
item = lam_list_get_next(item)) {
|
||||
@ -81,7 +81,7 @@ int mca_pml_base_select(mca_pml_t *selected, bool *allow_multi_user_threads,
|
||||
if (NULL == om) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
lam_list_item_init((lam_list_item_t *) om);
|
||||
lam_list_item_construct((lam_list_item_t *) om);
|
||||
om->om_module = module;
|
||||
lam_list_append(&opened, (lam_list_item_t*) om);
|
||||
}
|
||||
|
@ -6,17 +6,17 @@
|
||||
#include "pml_ptl_array.h"
|
||||
|
||||
|
||||
lam_class_info_t mca_pml_teg_array_cls = {
|
||||
lam_class_info_t mca_pml_teg_array_t_class_info = {
|
||||
"mca_ptl_array_t",
|
||||
&lam_object_cls,
|
||||
(class_init_t) mca_ptl_array_init,
|
||||
(class_destroy_t) mca_ptl_array_destroy
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) mca_ptl_array_construct,
|
||||
(lam_destruct_t) mca_ptl_array_destruct
|
||||
};
|
||||
|
||||
|
||||
void mca_ptl_array_init(mca_ptl_array_t* array)
|
||||
void mca_ptl_array_construct(mca_ptl_array_t* array)
|
||||
{
|
||||
SUPER_INIT(array, &lam_object_cls);
|
||||
OBJ_CONSTRUCT_SUPER(array, lam_object_t);
|
||||
array->ptl_procs = 0;
|
||||
array->ptl_size = 0;
|
||||
array->ptl_index = 0;
|
||||
@ -24,11 +24,11 @@ void mca_ptl_array_init(mca_ptl_array_t* array)
|
||||
}
|
||||
|
||||
|
||||
void mca_ptl_array_destroy(mca_ptl_array_t* array)
|
||||
void mca_ptl_array_destruct(mca_ptl_array_t* array)
|
||||
{
|
||||
if (array->ptl_procs != 0)
|
||||
if(array->ptl_procs != 0)
|
||||
free(array->ptl_procs);
|
||||
SUPER_DESTROY(array, &lam_object_cls);
|
||||
OBJ_DESTRUCT_SUPER(array, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "lam/util/output.h"
|
||||
#include "mca/mpi/ptl/ptl.h"
|
||||
|
||||
extern lam_class_info_t mca_ptl_array_cls;
|
||||
extern lam_class_info_t mca_ptl_array_t_class_info;
|
||||
|
||||
struct mca_ptl_proc_t {
|
||||
double ptl_weight; /* PTL weight for scheduling */
|
||||
@ -27,8 +27,8 @@ struct mca_ptl_array_t {
|
||||
typedef struct mca_ptl_array_t mca_ptl_array_t;
|
||||
|
||||
|
||||
void mca_ptl_array_init(mca_ptl_array_t*);
|
||||
void mca_ptl_array_destroy(mca_ptl_array_t*);
|
||||
void mca_ptl_array_construct(mca_ptl_array_t*);
|
||||
void mca_ptl_array_destruct(mca_ptl_array_t*);
|
||||
int mca_ptl_array_reserve(mca_ptl_array_t*, size_t);
|
||||
|
||||
static inline size_t mca_ptl_array_get_size(mca_ptl_array_t* array)
|
||||
|
@ -35,7 +35,7 @@ mca_pml_teg_t mca_pml_teg = {
|
||||
int mca_pml_teg_add_comm(lam_communicator_t* comm)
|
||||
{
|
||||
/* allocate pml specific comm data */
|
||||
mca_pml_comm_t* pml_comm = OBJ_CREATE(mca_pml_comm_t, &mca_pml_ptl_comm_cls);
|
||||
mca_pml_comm_t* pml_comm = OBJ_NEW(mca_pml_comm_t);
|
||||
if (NULL == pml_comm) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
@ -249,14 +249,14 @@ int mca_pml_teg_del_procs(lam_proc_t** procs, size_t nprocs)
|
||||
}
|
||||
|
||||
/* do any required cleanup */
|
||||
mca_pml_teg_proc_destroy(proc_pml);
|
||||
mca_pml_teg_proc_destruct(proc_pml);
|
||||
free(proc_pml);
|
||||
proc->proc_pml = 0;
|
||||
}
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
||||
int mca_pml_teg_module_fini(void)
|
||||
int mca_pml_teg_module_destruct(void)
|
||||
{
|
||||
/* FIX */
|
||||
return LAM_SUCCESS;
|
||||
|
@ -58,8 +58,8 @@ static inline int mca_pml_teg_param_register_int(
|
||||
|
||||
int mca_pml_teg_module_open(void)
|
||||
{
|
||||
STATIC_INIT(mca_pml_teg.teg_recv_requests, &lam_free_list_cls);
|
||||
STATIC_INIT(mca_pml_teg.teg_procs, &lam_list_cls);
|
||||
OBJ_CONSTRUCT(&mca_pml_teg.teg_recv_requests, lam_free_list_t);
|
||||
OBJ_CONSTRUCT(&mca_pml_teg.teg_procs, lam_list_t);
|
||||
mca_pml_teg.teg_free_list_num =
|
||||
mca_pml_teg_param_register_int("free_list_num", 256);
|
||||
mca_pml_teg.teg_free_list_max =
|
||||
@ -76,8 +76,8 @@ int mca_pml_teg_module_close(void)
|
||||
free(mca_pml_teg.teg_ptl_modules);
|
||||
if(NULL != mca_pml_teg.teg_ptls)
|
||||
free(mca_pml_teg.teg_ptls);
|
||||
STATIC_DESTROY(mca_pml_teg.teg_recv_requests);
|
||||
STATIC_DESTROY(mca_pml_teg.teg_procs);
|
||||
OBJ_DESTRUCT(&mca_pml_teg.teg_recv_requests);
|
||||
OBJ_DESTRUCT(&mca_pml_teg.teg_procs);
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -95,16 +95,16 @@ mca_pml_t* mca_pml_teg_module_init(int* priority,
|
||||
mca_pml_teg.teg_ptls = NULL;
|
||||
mca_pml_teg.teg_num_ptls = 0;
|
||||
|
||||
lam_free_list_init_with(
|
||||
lam_free_list_construct_with(
|
||||
&mca_pml_teg.teg_recv_requests,
|
||||
sizeof(mca_ptl_base_recv_request_t),
|
||||
&mca_ptl_base_recv_request_cls,
|
||||
CLASS_INFO(mca_ptl_base_recv_request_t),
|
||||
mca_pml_teg.teg_free_list_num,
|
||||
mca_pml_teg.teg_free_list_max,
|
||||
mca_pml_teg.teg_free_list_inc,
|
||||
NULL);
|
||||
|
||||
lam_mutex_init(&mca_pml_teg.teg_lock);
|
||||
lam_mutex_construct(&mca_pml_teg.teg_lock);
|
||||
mca_pml_teg.teg_recv_sequence = 0;
|
||||
return &mca_pml_teg.super;
|
||||
}
|
||||
|
@ -7,19 +7,19 @@
|
||||
#include "pml_teg_proc.h"
|
||||
#include "pml_ptl_array.h"
|
||||
|
||||
lam_class_info_t mca_pml_teg_proc_cls = {
|
||||
lam_class_info_t mca_pml_teg_proc_t_class_info = {
|
||||
"mca_pml_teg_proc_t",
|
||||
&lam_list_item_cls,
|
||||
(class_init_t) mca_pml_teg_proc_init,
|
||||
(class_destroy_t) mca_pml_teg_proc_destroy
|
||||
CLASS_INFO(lam_list_item_t),
|
||||
(lam_construct_t) mca_pml_teg_proc_construct,
|
||||
(lam_destruct_t) mca_pml_teg_proc_destruct
|
||||
};
|
||||
|
||||
|
||||
void mca_pml_teg_proc_init(mca_pml_proc_t* proc)
|
||||
void mca_pml_teg_proc_construct(mca_pml_proc_t* proc)
|
||||
{
|
||||
SUPER_INIT(proc, &lam_list_item_cls);
|
||||
mca_ptl_array_init(&proc->proc_ptl_first);
|
||||
mca_ptl_array_init(&proc->proc_ptl_next);
|
||||
OBJ_CONSTRUCT_SUPER(proc, lam_list_item_t);
|
||||
mca_ptl_array_construct(&proc->proc_ptl_first);
|
||||
mca_ptl_array_construct(&proc->proc_ptl_next);
|
||||
|
||||
THREAD_LOCK(&mca_pml_teg.teg_lock);
|
||||
lam_list_append(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc);
|
||||
@ -27,12 +27,12 @@ void mca_pml_teg_proc_init(mca_pml_proc_t* proc)
|
||||
}
|
||||
|
||||
|
||||
void mca_pml_teg_proc_destroy(mca_pml_proc_t* proc)
|
||||
void mca_pml_teg_proc_destruct(mca_pml_proc_t* proc)
|
||||
{
|
||||
THREAD_LOCK(&mca_pml_teg.teg_lock);
|
||||
lam_list_remove_item(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc);
|
||||
THREAD_UNLOCK(&mca_pml_teg.teg_lock);
|
||||
|
||||
SUPER_DESTROY(proc, &lam_list_item_cls);
|
||||
OBJ_DESTRUCT_SUPER(proc, lam_list_item_t);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mpi/proc/proc.h"
|
||||
#include "pml_ptl_array.h"
|
||||
|
||||
extern lam_class_info_t mca_pml_teg_proc_cls;
|
||||
extern lam_class_info_t mca_pml_teg_proc_t_class_info;
|
||||
|
||||
/*
|
||||
* Structure associated w/ lam_proc_t that contains data specific
|
||||
@ -28,8 +28,8 @@ struct mca_pml_proc_t {
|
||||
typedef struct mca_pml_proc_t mca_pml_proc_t;
|
||||
|
||||
|
||||
void mca_pml_teg_proc_init(mca_pml_proc_t*);
|
||||
void mca_pml_teg_proc_destroy(mca_pml_proc_t*);
|
||||
void mca_pml_teg_proc_construct(mca_pml_proc_t*);
|
||||
void mca_pml_teg_proc_destruct(mca_pml_proc_t*);
|
||||
|
||||
static inline mca_pml_proc_t* mca_pml_teg_proc_lookup_local(lam_communicator_t* comm, int rank)
|
||||
{
|
||||
|
@ -4,25 +4,26 @@
|
||||
|
||||
#include "ptl_base_comm.h"
|
||||
|
||||
static void mca_pml_ptl_comm_init(mca_pml_comm_t* comm);
|
||||
static void mca_pml_ptl_comm_destroy(mca_pml_comm_t* comm);
|
||||
static void mca_pml_ptl_comm_construct(mca_pml_comm_t* comm);
|
||||
static void mca_pml_ptl_comm_destruct(mca_pml_comm_t* comm);
|
||||
|
||||
|
||||
lam_class_info_t mca_pml_ptl_comm_cls = {
|
||||
lam_class_info_t mca_pml_ptl_comm_t_class_info = {
|
||||
"mca_pml_comm_t",
|
||||
&lam_object_cls,
|
||||
(class_init_t)mca_pml_ptl_comm_init,
|
||||
(class_destroy_t)mca_pml_ptl_comm_destroy
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t)mca_pml_ptl_comm_construct,
|
||||
(lam_destruct_t)mca_pml_ptl_comm_destruct
|
||||
};
|
||||
|
||||
static void mca_pml_ptl_comm_init(mca_pml_comm_t* comm)
|
||||
|
||||
static void mca_pml_ptl_comm_construct(mca_pml_comm_t* comm)
|
||||
{
|
||||
SUPER_INIT(comm, &lam_object_cls);
|
||||
STATIC_INIT(comm->c_wild_receives, &lam_list_cls);
|
||||
lam_mutex_init(&comm->c_wild_lock);
|
||||
OBJ_CONSTRUCT_SUPER(comm, lam_object_t);
|
||||
OBJ_CONSTRUCT(&comm->c_wild_receives, lam_list_t);
|
||||
lam_mutex_construct(&comm->c_wild_lock);
|
||||
}
|
||||
|
||||
static void mca_pml_ptl_comm_destroy(mca_pml_comm_t* comm)
|
||||
static void mca_pml_ptl_comm_destruct(mca_pml_comm_t* comm)
|
||||
{
|
||||
free(comm->c_msg_seq);
|
||||
free(comm->c_next_msg_seq);
|
||||
@ -31,8 +32,8 @@ static void mca_pml_ptl_comm_destroy(mca_pml_comm_t* comm)
|
||||
free(comm->c_unexpected_frags_lock);
|
||||
free(comm->c_frags_cant_match);
|
||||
free(comm->c_specific_receives);
|
||||
lam_list_destroy(&comm->c_wild_receives);
|
||||
SUPER_DESTROY(comm, &lam_object_cls);
|
||||
lam_list_destruct(&comm->c_wild_receives);
|
||||
OBJ_DESTRUCT_SUPER(comm, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
@ -55,35 +56,35 @@ int mca_pml_ptl_comm_init_size(mca_pml_comm_t* comm, size_t size)
|
||||
if(NULL == comm->c_matching_lock)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
for(i=0; i<size; i++)
|
||||
lam_mutex_init(comm->c_matching_lock+i);
|
||||
lam_mutex_construct(comm->c_matching_lock+i);
|
||||
|
||||
/* unexpected fragments queues */
|
||||
comm->c_unexpected_frags = malloc(sizeof(lam_list_t) * size);
|
||||
if(NULL == comm->c_unexpected_frags)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
for(i=0; i<size; i++)
|
||||
lam_list_init(comm->c_unexpected_frags+i);
|
||||
lam_list_construct(comm->c_unexpected_frags+i);
|
||||
|
||||
/* these locks are needed to avoid a probe interfering with a match */
|
||||
comm->c_unexpected_frags_lock = malloc(sizeof(lam_mutex_t) * size);
|
||||
if(NULL == comm->c_unexpected_frags_lock)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
for(i=0; i<size; i++)
|
||||
lam_mutex_init(comm->c_unexpected_frags_lock+i);
|
||||
lam_mutex_construct(comm->c_unexpected_frags_lock+i);
|
||||
|
||||
/* out-of-order fragments queues */
|
||||
comm->c_frags_cant_match = malloc(sizeof(lam_list_t) * size);
|
||||
if(NULL == comm->c_frags_cant_match)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
for(i=0; i<size; i++)
|
||||
lam_list_init(comm->c_frags_cant_match+i);
|
||||
lam_list_construct(comm->c_frags_cant_match+i);
|
||||
|
||||
/* queues of unmatched specific (source process specified) receives */
|
||||
comm->c_specific_receives = malloc(sizeof(lam_list_t) * size);
|
||||
if(NULL == comm->c_specific_receives)
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
for(i=0; i<size; i++)
|
||||
lam_list_init(comm->c_specific_receives+i);
|
||||
lam_list_construct(comm->c_specific_receives+i);
|
||||
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
* specific to the PML.
|
||||
*/
|
||||
|
||||
extern lam_class_info_t mca_pml_ptl_comm_cls;
|
||||
extern lam_class_info_t mca_pml_ptl_comm_t_class_info;
|
||||
|
||||
struct mca_pml_comm_t {
|
||||
lam_object_t super;
|
||||
|
@ -6,24 +6,24 @@
|
||||
#include "lam/lfc/list.h"
|
||||
#include "mca/mpi/ptl/base/ptl_base_fragment.h"
|
||||
|
||||
static void mca_ptl_base_frag_init(mca_ptl_base_frag_t* frag);
|
||||
static void mca_ptl_base_frag_destroy(mca_ptl_base_frag_t* frag);
|
||||
static void mca_ptl_base_frag_construct(mca_ptl_base_frag_t* frag);
|
||||
static void mca_ptl_base_frag_destruct(mca_ptl_base_frag_t* frag);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_base_frag_cls = {
|
||||
lam_class_info_t mca_ptl_base_frag_t_class_info = {
|
||||
"mca_ptl_base_frag_t",
|
||||
&lam_list_item_cls,
|
||||
(class_init_t) mca_ptl_base_frag_init,
|
||||
(class_destroy_t) mca_ptl_base_frag_destroy
|
||||
CLASS_INFO(lam_list_item_t),
|
||||
(lam_construct_t) mca_ptl_base_frag_construct,
|
||||
(lam_destruct_t) mca_ptl_base_frag_destruct
|
||||
};
|
||||
|
||||
static void mca_ptl_base_frag_init(mca_ptl_base_frag_t* frag)
|
||||
static void mca_ptl_base_frag_construct(mca_ptl_base_frag_t* frag)
|
||||
{
|
||||
SUPER_INIT(frag, &lam_list_item_cls);
|
||||
OBJ_CONSTRUCT_SUPER(frag, lam_list_item_t);
|
||||
}
|
||||
|
||||
static void mca_ptl_base_frag_destroy(mca_ptl_base_frag_t* frag)
|
||||
static void mca_ptl_base_frag_destruct(mca_ptl_base_frag_t* frag)
|
||||
{
|
||||
SUPER_DESTROY(frag, &lam_list_item_cls);
|
||||
OBJ_DESTRUCT_SUPER(frag, lam_list_item_t);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mca/mpi/ptl/base/ptl_base_header.h"
|
||||
|
||||
|
||||
extern lam_class_info_t mca_ptl_base_frag_cls;
|
||||
extern lam_class_info_t mca_ptl_base_frag_t_class_info;
|
||||
|
||||
struct mca_ptl_base_frag_t {
|
||||
lam_list_item_t super;
|
||||
|
@ -584,7 +584,7 @@ static void mca_ptl_base_check_cantmatch_for_match(lam_list_t *additional_matche
|
||||
*/
|
||||
if(0 == lam_list_get_size(additional_matches))
|
||||
{
|
||||
lam_list_init(additional_matches);
|
||||
lam_list_construct(additional_matches);
|
||||
}
|
||||
|
||||
/* We're now expecting the next sequence number. */
|
||||
|
@ -47,7 +47,7 @@ int mca_ptl_base_open(void)
|
||||
iterate over it (even if it's empty, as in the case of
|
||||
laminfo) */
|
||||
|
||||
lam_list_init(&mca_ptl_base_modules_initialized);
|
||||
lam_list_construct(&mca_ptl_base_modules_initialized);
|
||||
|
||||
/* All done */
|
||||
|
||||
|
@ -7,25 +7,25 @@
|
||||
#include "mca/mpi/ptl/base/ptl_base_recvfrag.h"
|
||||
#include "mca/mpi/ptl/base/ptl_base_match.h"
|
||||
|
||||
static void mca_ptl_base_recv_frag_init(mca_ptl_base_recv_frag_t* frag);
|
||||
static void mca_ptl_base_recv_frag_destroy(mca_ptl_base_recv_frag_t* frag);
|
||||
static void mca_ptl_base_recv_frag_construct(mca_ptl_base_recv_frag_t* frag);
|
||||
static void mca_ptl_base_recv_frag_destruct(mca_ptl_base_recv_frag_t* frag);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_base_recv_frag_cls = {
|
||||
lam_class_info_t mca_ptl_base_recv_frag_t_class_info = {
|
||||
"mca_ptl_base_recv_frag_t",
|
||||
&mca_ptl_base_frag_cls,
|
||||
(class_init_t) mca_ptl_base_recv_frag_init,
|
||||
(class_destroy_t) mca_ptl_base_recv_frag_destroy
|
||||
CLASS_INFO(mca_ptl_base_frag_t),
|
||||
(lam_construct_t) mca_ptl_base_recv_frag_construct,
|
||||
(lam_destruct_t) mca_ptl_base_recv_frag_destruct
|
||||
};
|
||||
|
||||
|
||||
void mca_ptl_base_recv_frag_init(mca_ptl_base_recv_frag_t* frag)
|
||||
void mca_ptl_base_recv_frag_construct(mca_ptl_base_recv_frag_t* frag)
|
||||
{
|
||||
SUPER_INIT(frag, &mca_ptl_base_frag_cls);
|
||||
OBJ_CONSTRUCT_SUPER(frag, mca_ptl_base_frag_t);
|
||||
}
|
||||
|
||||
void mca_ptl_base_recv_frag_destroy(mca_ptl_base_recv_frag_t* frag)
|
||||
void mca_ptl_base_recv_frag_destruct(mca_ptl_base_recv_frag_t* frag)
|
||||
{
|
||||
SUPER_DESTROY(frag, &mca_ptl_base_frag_cls);
|
||||
OBJ_DESTRUCT_SUPER(frag, mca_ptl_base_frag_t);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mca/mpi/ptl/base/ptl_base_recvreq.h"
|
||||
#include "mca/mpi/ptl/base/ptl_base_match.h"
|
||||
|
||||
extern lam_class_info_t mca_ptl_base_recv_frag_cls;
|
||||
extern lam_class_info_t mca_ptl_base_recv_frag_t_class_info;
|
||||
|
||||
|
||||
struct mca_ptl_base_recv_frag_t {
|
||||
|
@ -9,28 +9,28 @@
|
||||
#include "mca/mpi/ptl/base/ptl_base_recvfrag.h"
|
||||
|
||||
|
||||
static void mca_ptl_base_recv_request_init(mca_ptl_base_recv_request_t*);
|
||||
static void mca_ptl_base_recv_request_destroy(mca_ptl_base_recv_request_t*);
|
||||
static void mca_ptl_base_recv_request_construct(mca_ptl_base_recv_request_t*);
|
||||
static void mca_ptl_base_recv_request_destruct(mca_ptl_base_recv_request_t*);
|
||||
static bool mca_ptl_base_recv_request_match_specific_proc(mca_ptl_base_recv_request_t*, int);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_base_recv_request_cls = {
|
||||
lam_class_info_t mca_ptl_base_recv_request_t_class_info = {
|
||||
"mca_ptl_base_recv_request_t",
|
||||
&mca_pml_base_request_cls,
|
||||
(class_init_t) mca_ptl_base_recv_request_init,
|
||||
(class_destroy_t) mca_ptl_base_recv_request_destroy
|
||||
CLASS_INFO(mca_pml_base_request_t),
|
||||
(lam_construct_t) mca_ptl_base_recv_request_construct,
|
||||
(lam_destruct_t) mca_ptl_base_recv_request_destruct
|
||||
};
|
||||
|
||||
|
||||
static void mca_ptl_base_recv_request_init(mca_ptl_base_recv_request_t* request)
|
||||
static void mca_ptl_base_recv_request_construct(mca_ptl_base_recv_request_t* request)
|
||||
{
|
||||
SUPER_INIT(request, &mca_pml_base_request_cls);
|
||||
OBJ_CONSTRUCT_SUPER(request, mca_pml_base_request_t);
|
||||
}
|
||||
|
||||
|
||||
static void mca_ptl_base_recv_request_destroy(mca_ptl_base_recv_request_t* request)
|
||||
static void mca_ptl_base_recv_request_destruct(mca_ptl_base_recv_request_t* request)
|
||||
{
|
||||
SUPER_DESTROY(request, &mca_pml_base_request_cls);
|
||||
OBJ_DESTRUCT_SUPER(request, mca_pml_base_request_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "mca/mpi/ptl/ptl.h"
|
||||
#include "mca/mpi/pml/base/pml_base_request.h"
|
||||
|
||||
extern lam_class_info_t mca_ptl_base_recv_request_cls;;
|
||||
extern lam_class_info_t mca_ptl_base_recv_request_t_class_info;;
|
||||
struct mca_ptl_base_recv_frag_t;
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ int mca_ptl_base_select(bool *allow_multi_user_threads,
|
||||
if (NULL == sm) {
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
}
|
||||
lam_list_item_init((lam_list_item_t *) sm);
|
||||
lam_list_item_construct((lam_list_item_t *) sm);
|
||||
sm->pbsm_module = module;
|
||||
sm->pbsm_actions = actions[i];
|
||||
lam_list_append(&mca_ptl_base_modules_initialized,
|
||||
|
@ -4,25 +4,25 @@
|
||||
|
||||
#include "mca/mpi/ptl/base/ptl_base_sendfrag.h"
|
||||
|
||||
static void mca_ptl_base_send_frag_init(mca_ptl_base_send_frag_t* frag);
|
||||
static void mca_ptl_base_send_frag_destroy(mca_ptl_base_send_frag_t* frag);
|
||||
static void mca_ptl_base_send_frag_construct(mca_ptl_base_send_frag_t* frag);
|
||||
static void mca_ptl_base_send_frag_destruct(mca_ptl_base_send_frag_t* frag);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_base_send_frag_cls = {
|
||||
lam_class_info_t mca_ptl_base_send_frag_t_class_info = {
|
||||
"mca_ptl_base_send_frag_t",
|
||||
&mca_ptl_base_frag_cls,
|
||||
(class_init_t) mca_ptl_base_send_frag_init,
|
||||
(class_destroy_t) mca_ptl_base_send_frag_destroy
|
||||
CLASS_INFO(mca_ptl_base_frag_t),
|
||||
(lam_construct_t) mca_ptl_base_send_frag_construct,
|
||||
(lam_destruct_t) mca_ptl_base_send_frag_destruct
|
||||
};
|
||||
|
||||
|
||||
static void mca_ptl_base_send_frag_init(mca_ptl_base_send_frag_t* frag)
|
||||
static void mca_ptl_base_send_frag_construct(mca_ptl_base_send_frag_t* frag)
|
||||
{
|
||||
SUPER_INIT(frag, &mca_ptl_base_frag_cls);
|
||||
OBJ_CONSTRUCT_SUPER(frag, mca_ptl_base_frag_t);
|
||||
}
|
||||
|
||||
static void mca_ptl_base_send_frag_destroy(mca_ptl_base_send_frag_t* frag)
|
||||
static void mca_ptl_base_send_frag_destruct(mca_ptl_base_send_frag_t* frag)
|
||||
{
|
||||
SUPER_DESTROY(frag, &mca_ptl_base_frag_cls);
|
||||
OBJ_DESTRUCT_SUPER(frag, mca_ptl_base_frag_t);
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "mca/mpi/ptl/ptl.h"
|
||||
#include "mca/mpi/ptl/base/ptl_base_fragment.h"
|
||||
|
||||
extern lam_class_info_t mca_ptl_base_send_frag_cls;
|
||||
extern lam_class_info_t mca_ptl_base_send_frag_t_class_info;
|
||||
|
||||
|
||||
struct mca_ptl_base_send_frag_t {
|
||||
|
@ -3,27 +3,27 @@
|
||||
*/
|
||||
#include "mca/mpi/ptl/base/ptl_base_sendreq.h"
|
||||
|
||||
static void mca_ptl_base_send_request_init(mca_ptl_base_send_request_t* req);
|
||||
static void mca_ptl_base_send_request_destroy(mca_ptl_base_send_request_t* req);
|
||||
static void mca_ptl_base_send_request_construct(mca_ptl_base_send_request_t* req);
|
||||
static void mca_ptl_base_send_request_destruct(mca_ptl_base_send_request_t* req);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_base_send_request_cls = {
|
||||
lam_class_info_t mca_ptl_base_send_request_t_class_info = {
|
||||
"mca_ptl_base_send_request_t",
|
||||
&mca_pml_base_request_cls,
|
||||
(class_init_t) mca_ptl_base_send_request_init,
|
||||
(class_destroy_t) mca_ptl_base_send_request_destroy
|
||||
CLASS_INFO(mca_pml_base_request_t),
|
||||
(lam_construct_t) mca_ptl_base_send_request_construct,
|
||||
(lam_destruct_t) mca_ptl_base_send_request_destruct
|
||||
};
|
||||
|
||||
|
||||
static void mca_ptl_base_send_request_init(mca_ptl_base_send_request_t* req)
|
||||
static void mca_ptl_base_send_request_construct(mca_ptl_base_send_request_t* req)
|
||||
{
|
||||
SUPER_INIT(req, &mca_pml_base_request_cls);
|
||||
STATIC_INIT(req->req_unacked_frags, &lam_list_cls);
|
||||
OBJ_CONSTRUCT_SUPER(req, mca_pml_base_request_t);
|
||||
OBJ_CONSTRUCT(&req->req_unacked_frags, lam_list_t);
|
||||
}
|
||||
|
||||
static void mca_ptl_base_send_request_destroy(mca_ptl_base_send_request_t* req)
|
||||
static void mca_ptl_base_send_request_destruct(mca_ptl_base_send_request_t* req)
|
||||
{
|
||||
STATIC_DESTROY(req->req_unacked_frags);
|
||||
SUPER_DESTROY(&req->req_unacked_frags, &mca_pml_base_request_cls);
|
||||
OBJ_DESTRUCT(&req->req_unacked_frags);
|
||||
OBJ_DESTRUCT_SUPER(&req->req_unacked_frags, mca_pml_base_request_t);
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "mca/mpi/pml/base/pml_base_request.h"
|
||||
|
||||
|
||||
extern lam_class_info_t mca_ptl_base_send_request_cls;
|
||||
extern lam_class_info_t mca_ptl_base_send_request_t_class_info;
|
||||
|
||||
|
||||
struct mca_ptl_base_send_request_t {
|
||||
|
@ -76,7 +76,7 @@ int mca_ptl_tcp_add_proc(struct mca_ptl_t* ptl, struct lam_proc_t *lam_proc, str
|
||||
/* The ptl_proc datastructure is shared by all TCP PTL instances that are trying
|
||||
* to reach this destination. Cache the peer instance on the ptl_proc.
|
||||
*/
|
||||
ptl_peer = OBJ_CREATE(mca_ptl_base_peer_t, &mca_ptl_tcp_peer_cls);
|
||||
ptl_peer = OBJ_NEW(mca_ptl_base_peer_t);
|
||||
if(NULL == ptl_peer) {
|
||||
THREAD_UNLOCK(&ptl_proc->proc_lock);
|
||||
return LAM_ERR_OUT_OF_RESOURCE;
|
||||
|
@ -101,12 +101,12 @@ static inline int mca_ptl_tcp_param_register_int(
|
||||
|
||||
int mca_ptl_tcp_module_open(void)
|
||||
{
|
||||
lam_mutex_init(&mca_ptl_tcp_module.tcp_lock);
|
||||
STATIC_INIT(mca_ptl_tcp_module.tcp_reactor, &lam_reactor_cls);
|
||||
STATIC_INIT(mca_ptl_tcp_module.tcp_procs, &lam_list_cls);
|
||||
STATIC_INIT(mca_ptl_tcp_module.tcp_send_requests, &lam_free_list_cls);
|
||||
STATIC_INIT(mca_ptl_tcp_module.tcp_send_frags, &lam_free_list_cls);
|
||||
STATIC_INIT(mca_ptl_tcp_module.tcp_recv_frags, &lam_free_list_cls);
|
||||
lam_mutex_construct(&mca_ptl_tcp_module.tcp_lock);
|
||||
OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_reactor, lam_reactor_t);
|
||||
OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_procs, lam_list_t);
|
||||
OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_send_requests, lam_free_list_t);
|
||||
OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_send_frags, lam_free_list_t);
|
||||
OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_recv_frags, lam_free_list_t);
|
||||
|
||||
/* register TCP module parameters */
|
||||
mca_ptl_tcp_module.tcp_if_include =
|
||||
@ -137,12 +137,12 @@ int mca_ptl_tcp_module_close(void)
|
||||
if (NULL != mca_ptl_tcp_module.tcp_ptls)
|
||||
free(mca_ptl_tcp_module.tcp_ptls);
|
||||
|
||||
STATIC_DESTROY(mca_ptl_tcp_module.tcp_reactor);
|
||||
STATIC_DESTROY(mca_ptl_tcp_module.tcp_procs);
|
||||
STATIC_DESTROY(mca_ptl_tcp_module.tcp_send_requests);
|
||||
STATIC_DESTROY(mca_ptl_tcp_module.tcp_send_frags);
|
||||
STATIC_DESTROY(mca_ptl_tcp_module.tcp_recv_frags);
|
||||
lam_mutex_destroy(&mca_ptl_tcp_module.tcp_lock);
|
||||
OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_reactor);
|
||||
OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_procs);
|
||||
OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_send_requests);
|
||||
OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_send_frags);
|
||||
OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_recv_frags);
|
||||
lam_mutex_destruct(&mca_ptl_tcp_module.tcp_lock);
|
||||
return LAM_SUCCESS;
|
||||
}
|
||||
|
||||
@ -290,25 +290,25 @@ mca_ptl_t** mca_ptl_tcp_module_init(int *num_ptls,
|
||||
|
||||
|
||||
/* initialize free lists */
|
||||
lam_free_list_init_with(&mca_ptl_tcp_module.tcp_send_requests,
|
||||
lam_free_list_construct_with(&mca_ptl_tcp_module.tcp_send_requests,
|
||||
sizeof(mca_ptl_tcp_send_request_t),
|
||||
&mca_ptl_tcp_send_request_cls,
|
||||
CLASS_INFO(mca_ptl_tcp_send_request_t),
|
||||
mca_ptl_tcp_module.tcp_free_list_num,
|
||||
mca_ptl_tcp_module.tcp_free_list_max,
|
||||
mca_ptl_tcp_module.tcp_free_list_inc,
|
||||
NULL); /* use default allocator */
|
||||
|
||||
lam_free_list_init_with(&mca_ptl_tcp_module.tcp_send_frags,
|
||||
lam_free_list_construct_with(&mca_ptl_tcp_module.tcp_send_frags,
|
||||
sizeof(mca_ptl_tcp_send_frag_t),
|
||||
&mca_ptl_tcp_send_frag_cls,
|
||||
CLASS_INFO(mca_ptl_tcp_send_frag_t),
|
||||
mca_ptl_tcp_module.tcp_free_list_num,
|
||||
mca_ptl_tcp_module.tcp_free_list_max,
|
||||
mca_ptl_tcp_module.tcp_free_list_inc,
|
||||
NULL); /* use default allocator */
|
||||
|
||||
lam_free_list_init_with(&mca_ptl_tcp_module.tcp_recv_frags,
|
||||
lam_free_list_construct_with(&mca_ptl_tcp_module.tcp_recv_frags,
|
||||
sizeof(mca_ptl_tcp_recv_frag_t),
|
||||
&mca_ptl_tcp_recv_frag_cls,
|
||||
CLASS_INFO(mca_ptl_tcp_recv_frag_t),
|
||||
mca_ptl_tcp_module.tcp_free_list_num,
|
||||
mca_ptl_tcp_module.tcp_free_list_max,
|
||||
mca_ptl_tcp_module.tcp_free_list_inc,
|
||||
|
@ -14,7 +14,7 @@
|
||||
|
||||
|
||||
static void mca_ptl_tcp_peer_init(mca_ptl_base_peer_t* ptl_peer);
|
||||
static void mca_ptl_tcp_peer_destroy(mca_ptl_base_peer_t* ptl_peer);
|
||||
static void mca_ptl_tcp_peer_destruct(mca_ptl_base_peer_t* ptl_peer);
|
||||
static int mca_ptl_tcp_peer_start_connect(mca_ptl_base_peer_t*);
|
||||
static void mca_ptl_tcp_peer_close_i(mca_ptl_base_peer_t*);
|
||||
static void mca_ptl_tcp_peer_connected(mca_ptl_base_peer_t*);
|
||||
@ -23,11 +23,11 @@ static void mca_ptl_tcp_peer_send_handler(mca_ptl_base_peer_t*, int sd);
|
||||
static void mca_ptl_tcp_peer_except_handler(mca_ptl_base_peer_t*, int sd);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_tcp_peer_cls = {
|
||||
lam_class_info_t mca_ptl_tcp_peer_t_class_info = {
|
||||
"mca_tcp_ptl_peer_t",
|
||||
&lam_list_cls,
|
||||
(class_init_t)mca_ptl_tcp_peer_init,
|
||||
(class_destroy_t)mca_ptl_tcp_peer_destroy
|
||||
CLASS_INFO(lam_list_t),
|
||||
(lam_construct_t)mca_ptl_tcp_peer_construct,
|
||||
(lam_destruct_t)mca_ptl_tcp_peer_destruct
|
||||
};
|
||||
|
||||
|
||||
@ -42,9 +42,9 @@ static lam_reactor_listener_t mca_ptl_tcp_peer_listener = {
|
||||
* Initialize state of the peer instance.
|
||||
*/
|
||||
|
||||
void mca_ptl_tcp_peer_init(mca_ptl_base_peer_t* ptl_peer)
|
||||
void mca_ptl_tcp_peer_construct(mca_ptl_base_peer_t* ptl_peer)
|
||||
{
|
||||
SUPER_INIT(ptl_peer, &lam_list_cls);
|
||||
OBJ_CONSTRUCT_SUPER(ptl_peer, lam_list_t);
|
||||
ptl_peer->peer_ptl = 0;
|
||||
ptl_peer->peer_proc = 0;
|
||||
ptl_peer->peer_addr = 0;
|
||||
@ -53,8 +53,8 @@ void mca_ptl_tcp_peer_init(mca_ptl_base_peer_t* ptl_peer)
|
||||
ptl_peer->peer_recv_frag = 0;
|
||||
ptl_peer->peer_state = MCA_PTL_TCP_CLOSED;
|
||||
ptl_peer->peer_retries = 0;
|
||||
STATIC_INIT(ptl_peer->peer_frags, &lam_list_cls);
|
||||
lam_mutex_init(&ptl_peer->peer_lock);
|
||||
OBJ_CONSTRUCT(&ptl_peer->peer_frags, lam_list_t);
|
||||
lam_mutex_construct(&ptl_peer->peer_lock);
|
||||
}
|
||||
|
||||
|
||||
@ -62,11 +62,11 @@ void mca_ptl_tcp_peer_init(mca_ptl_base_peer_t* ptl_peer)
|
||||
* Cleanup any resources held by the peer.
|
||||
*/
|
||||
|
||||
void mca_ptl_tcp_peer_destroy(mca_ptl_base_peer_t* ptl_peer)
|
||||
void mca_ptl_tcp_peer_destruct(mca_ptl_base_peer_t* ptl_peer)
|
||||
{
|
||||
mca_ptl_tcp_proc_remove(ptl_peer->peer_proc, ptl_peer);
|
||||
mca_ptl_tcp_peer_close_i(ptl_peer);
|
||||
SUPER_DESTROY(ptl_peer, &lam_list_cls);
|
||||
OBJ_DESTRUCT_SUPER(ptl_peer, lam_list_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,7 @@ typedef enum {
|
||||
} mca_ptl_tcp_state_t;
|
||||
|
||||
|
||||
extern lam_class_info_t mca_ptl_tcp_peer_cls;
|
||||
extern lam_class_info_t mca_ptl_tcp_peer_t_class_info;
|
||||
|
||||
/**
|
||||
* An abstraction that represents a connection to a peer process.
|
||||
|
@ -10,27 +10,27 @@
|
||||
#include "ptl_tcp_proc.h"
|
||||
|
||||
|
||||
static void mca_ptl_tcp_proc_init(mca_ptl_tcp_proc_t* proc);
|
||||
static void mca_ptl_tcp_proc_destroy(mca_ptl_tcp_proc_t* proc);
|
||||
static void mca_ptl_tcp_proc_construct(mca_ptl_tcp_proc_t* proc);
|
||||
static void mca_ptl_tcp_proc_destruct(mca_ptl_tcp_proc_t* proc);
|
||||
static mca_ptl_tcp_proc_t* mca_ptl_tcp_proc_lookup_lam(lam_proc_t* lam_proc);
|
||||
|
||||
lam_class_info_t mca_ptl_tcp_proc_cls = {
|
||||
lam_class_info_t mca_ptl_tcp_proc_t_class_info = {
|
||||
"mca_ptl_tcp_proc_t",
|
||||
&lam_list_item_cls,
|
||||
(class_init_t)mca_ptl_tcp_proc_init,
|
||||
(class_destroy_t)mca_ptl_tcp_proc_destroy
|
||||
CLASS_INFO(lam_list_item_t),
|
||||
(lam_construct_t)mca_ptl_tcp_proc_construct,
|
||||
(lam_destruct_t)mca_ptl_tcp_proc_destruct
|
||||
};
|
||||
|
||||
|
||||
void mca_ptl_tcp_proc_init(mca_ptl_tcp_proc_t* proc)
|
||||
void mca_ptl_tcp_proc_construct(mca_ptl_tcp_proc_t* proc)
|
||||
{
|
||||
SUPER_INIT(proc, &lam_list_item_cls);
|
||||
OBJ_CONSTRUCT_SUPER(proc, lam_list_item_t);
|
||||
proc->proc_lam = 0;
|
||||
proc->proc_addrs = 0;
|
||||
proc->proc_addr_count = 0;
|
||||
proc->proc_peers = 0;
|
||||
proc->proc_peer_count = 0;
|
||||
lam_mutex_init(&proc->proc_lock);
|
||||
lam_mutex_construct(&proc->proc_lock);
|
||||
|
||||
/* add to list of all proc instance */
|
||||
THREAD_LOCK(&mca_ptl_tcp_module.tcp_lock);
|
||||
@ -39,7 +39,7 @@ void mca_ptl_tcp_proc_init(mca_ptl_tcp_proc_t* proc)
|
||||
}
|
||||
|
||||
|
||||
void mca_ptl_tcp_proc_destroy(mca_ptl_tcp_proc_t* proc)
|
||||
void mca_ptl_tcp_proc_destruct(mca_ptl_tcp_proc_t* proc)
|
||||
{
|
||||
/* remove from list of all proc instances */
|
||||
THREAD_LOCK(&mca_ptl_tcp_module.tcp_lock);
|
||||
@ -51,7 +51,7 @@ void mca_ptl_tcp_proc_destroy(mca_ptl_tcp_proc_t* proc)
|
||||
free(proc->proc_peers);
|
||||
if(NULL != proc->proc_guid)
|
||||
free(proc->proc_guid);
|
||||
SUPER_DESTROY(proc, &lam_list_item_cls);
|
||||
OBJ_DESTRUCT_SUPER(proc, lam_list_item_t);
|
||||
}
|
||||
|
||||
|
||||
@ -72,7 +72,7 @@ mca_ptl_tcp_proc_t* mca_ptl_tcp_proc_create(lam_proc_t* lam_proc)
|
||||
if(ptl_proc != NULL)
|
||||
return ptl_proc;
|
||||
|
||||
ptl_proc = OBJ_CREATE(mca_ptl_tcp_proc_t, &mca_ptl_tcp_proc_cls);
|
||||
ptl_proc = OBJ_NEW(mca_ptl_tcp_proc_t);
|
||||
ptl_proc->proc_lam = lam_proc;
|
||||
|
||||
/* build a unique identifier (of arbitrary size) to represent the proc */
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "ptl_tcp.h"
|
||||
#include "ptl_tcp_peer.h"
|
||||
|
||||
extern lam_class_info_t mca_ptl_tcp_proc_cls;
|
||||
extern lam_class_info_t mca_ptl_tcp_proc_t_class_info;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include "ptl_tcp_recvfrag.h"
|
||||
|
||||
|
||||
static void mca_ptl_tcp_recv_frag_init(mca_ptl_tcp_recv_frag_t* frag);
|
||||
static void mca_ptl_tcp_recv_frag_destroy(mca_ptl_tcp_recv_frag_t* frag);
|
||||
static void mca_ptl_tcp_recv_frag_construct(mca_ptl_tcp_recv_frag_t* frag);
|
||||
static void mca_ptl_tcp_recv_frag_destruct(mca_ptl_tcp_recv_frag_t* frag);
|
||||
static bool mca_ptl_tcp_recv_frag_header(mca_ptl_tcp_recv_frag_t* frag, int sd, size_t);
|
||||
static bool mca_ptl_tcp_recv_frag_ack(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
||||
static bool mca_ptl_tcp_recv_frag_frag(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
||||
@ -19,23 +19,23 @@ static bool mca_ptl_tcp_recv_frag_data(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
||||
static bool mca_ptl_tcp_recv_frag_discard(mca_ptl_tcp_recv_frag_t* frag, int sd);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_tcp_recv_frag_cls = {
|
||||
lam_class_info_t mca_ptl_tcp_recv_frag_t_class_info = {
|
||||
"mca_ptl_tcp_recv_frag_t",
|
||||
&mca_ptl_base_recv_frag_cls,
|
||||
(class_init_t)mca_ptl_tcp_recv_frag_init,
|
||||
(class_destroy_t)mca_ptl_tcp_recv_frag_destroy
|
||||
CLASS_INFO(mca_ptl_base_recv_frag_t),
|
||||
(lam_construct_t)mca_ptl_tcp_recv_frag_construct,
|
||||
(lam_destruct_t)mca_ptl_tcp_recv_frag_destruct
|
||||
};
|
||||
|
||||
|
||||
static void mca_ptl_tcp_recv_frag_init(mca_ptl_tcp_recv_frag_t* frag)
|
||||
static void mca_ptl_tcp_recv_frag_construct(mca_ptl_tcp_recv_frag_t* frag)
|
||||
{
|
||||
SUPER_INIT(frag, &mca_ptl_base_recv_frag_cls);
|
||||
OBJ_CONSTRUCT_SUPER(frag, mca_ptl_base_recv_frag_t);
|
||||
}
|
||||
|
||||
|
||||
static void mca_ptl_tcp_recv_frag_destroy(mca_ptl_tcp_recv_frag_t* frag)
|
||||
static void mca_ptl_tcp_recv_frag_destruct(mca_ptl_tcp_recv_frag_t* frag)
|
||||
{
|
||||
SUPER_DESTROY(frag, &mca_ptl_base_recv_frag_cls);
|
||||
OBJ_DESTRUCT_SUPER(frag, mca_ptl_base_recv_frag_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "mca/mpi/ptl/base/ptl_base_recvfrag.h"
|
||||
|
||||
|
||||
extern lam_class_info_t mca_ptl_tcp_recv_frag_cls;
|
||||
extern lam_class_info_t mca_ptl_tcp_recv_frag_t_class_info;
|
||||
|
||||
|
||||
struct mca_ptl_tcp_recv_frag_t {
|
||||
|
@ -11,23 +11,23 @@
|
||||
#include "ptl_tcp_sendfrag.h"
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_tcp_send_frag_cls = {
|
||||
lam_class_info_t mca_ptl_tcp_send_frag_t_class_info = {
|
||||
"mca_ptl_tcp_send_frag_t",
|
||||
&mca_ptl_base_send_frag_cls,
|
||||
(class_init_t)mca_ptl_tcp_send_frag_init,
|
||||
(class_destroy_t)mca_ptl_tcp_send_frag_destroy
|
||||
CLASS_INFO(mca_ptl_base_send_frag_t),
|
||||
(lam_construct_t)mca_ptl_tcp_send_frag_construct,
|
||||
(lam_destruct_t)mca_ptl_tcp_send_frag_destruct
|
||||
};
|
||||
|
||||
|
||||
void mca_ptl_tcp_send_frag_init(mca_ptl_tcp_send_frag_t* frag)
|
||||
void mca_ptl_tcp_send_frag_construct(mca_ptl_tcp_send_frag_t* frag)
|
||||
{
|
||||
SUPER_INIT(frag, &mca_ptl_base_send_frag_cls);
|
||||
OBJ_CONSTRUCT_SUPER(frag, mca_ptl_base_send_frag_t);
|
||||
}
|
||||
|
||||
|
||||
void mca_ptl_tcp_send_frag_destroy(mca_ptl_tcp_send_frag_t* frag)
|
||||
void mca_ptl_tcp_send_frag_destruct(mca_ptl_tcp_send_frag_t* frag)
|
||||
{
|
||||
SUPER_DESTROY(frag, &mca_ptl_base_send_frag_cls);
|
||||
OBJ_DESTRUCT_SUPER(frag, mca_ptl_base_send_frag_t);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "mca/mpi/ptl/base/ptl_base_sendfrag.h"
|
||||
|
||||
|
||||
extern lam_class_info_t mca_ptl_tcp_send_frag_cls;
|
||||
extern lam_class_info_t mca_ptl_tcp_send_frag_t_class_info;
|
||||
|
||||
|
||||
struct mca_ptl_tcp_send_frag_t {
|
||||
@ -28,8 +28,8 @@ struct mca_ptl_tcp_send_frag_t {
|
||||
typedef struct mca_ptl_tcp_send_frag_t mca_ptl_tcp_send_frag_t;
|
||||
|
||||
|
||||
void mca_ptl_tcp_send_frag_init(mca_ptl_tcp_send_frag_t*);
|
||||
void mca_ptl_tcp_send_frag_destroy(mca_ptl_tcp_send_frag_t*);
|
||||
void mca_ptl_tcp_send_frag_construct(mca_ptl_tcp_send_frag_t*);
|
||||
void mca_ptl_tcp_send_frag_destruct(mca_ptl_tcp_send_frag_t*);
|
||||
bool mca_ptl_tcp_send_frag_handler(mca_ptl_tcp_send_frag_t*, int sd);
|
||||
|
||||
void mca_ptl_tcp_send_frag_reinit(
|
||||
|
@ -10,28 +10,28 @@
|
||||
#include "ptl_tcp_sendreq.h"
|
||||
|
||||
|
||||
static void mca_ptl_tcp_send_request_init(mca_ptl_tcp_send_request_t*);
|
||||
static void mca_ptl_tcp_send_request_destroy(mca_ptl_tcp_send_request_t*);
|
||||
static void mca_ptl_tcp_send_request_construct(mca_ptl_tcp_send_request_t*);
|
||||
static void mca_ptl_tcp_send_request_destruct(mca_ptl_tcp_send_request_t*);
|
||||
|
||||
|
||||
lam_class_info_t mca_ptl_tcp_send_request_cls = {
|
||||
lam_class_info_t mca_ptl_tcp_send_request_t_class_info = {
|
||||
"mca_ptl_tcp_send_request_t",
|
||||
&mca_ptl_base_send_request_cls,
|
||||
(class_init_t)mca_ptl_tcp_send_request_init,
|
||||
(class_destroy_t)mca_ptl_tcp_send_request_destroy
|
||||
CLASS_INFO(mca_ptl_base_send_request_t),
|
||||
(lam_construct_t)mca_ptl_tcp_send_request_construct,
|
||||
(lam_destruct_t)mca_ptl_tcp_send_request_destruct
|
||||
};
|
||||
|
||||
|
||||
void mca_ptl_tcp_send_request_init(mca_ptl_tcp_send_request_t* request)
|
||||
void mca_ptl_tcp_send_request_construct(mca_ptl_tcp_send_request_t* request)
|
||||
{
|
||||
SUPER_INIT(request, &mca_ptl_base_send_request_cls);
|
||||
STATIC_INIT(request->req_frag, &mca_ptl_tcp_send_frag_cls);
|
||||
OBJ_CONSTRUCT_SUPER(request, mca_ptl_base_send_request_t);
|
||||
OBJ_CONSTRUCT(&request->req_frag, mca_ptl_tcp_send_frag_t);
|
||||
}
|
||||
|
||||
|
||||
void mca_ptl_tcp_send_request_destroy(mca_ptl_tcp_send_request_t* request)
|
||||
void mca_ptl_tcp_send_request_destruct(mca_ptl_tcp_send_request_t* request)
|
||||
{
|
||||
STATIC_DESTROY(request->req_frag);
|
||||
SUPER_DESTROY(request, &mca_ptl_base_send_request_cls);
|
||||
OBJ_DESTRUCT(&request->req_frag);
|
||||
OBJ_DESTRUCT_SUPER(request, mca_ptl_base_send_request_t);
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
#include "ptl_tcp_sendfrag.h"
|
||||
|
||||
|
||||
extern lam_class_info_t mca_ptl_tcp_send_request_cls;
|
||||
extern lam_class_info_t mca_ptl_tcp_send_request_t_class_info;
|
||||
|
||||
struct mca_ptl_tcp_send_request_t {
|
||||
mca_ptl_base_send_request_t super;
|
||||
|
@ -75,7 +75,7 @@ static inline lam_proc_t* lam_comm_lookup_peer(lam_communicator_t* comm, size_t
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
int lam_comm_init(lam_communicator_t *comm);
|
||||
int lam_comm_construct(lam_communicator_t *comm);
|
||||
int lam_comm_link_function(void);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
|
@ -2,19 +2,16 @@
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/** @file */
|
||||
|
||||
#ifdef DATATYPES_ARE_READY
|
||||
/** @file lam_datatype_t implementation */
|
||||
|
||||
#include "lam_config.h"
|
||||
#include "lam/datatype.h"
|
||||
|
||||
|
||||
lam_class_info_t lam_datatype_cls = {
|
||||
lam_class_info_t lam_datatype_t_class_info = {
|
||||
"lam_datatype_t",
|
||||
&lam_dbl_item_cls,
|
||||
(class_init_t) lam_p2p_cdi_init,
|
||||
(class_destroy_t) lam_p2p_cdi_destroy
|
||||
CLASS_INFO(lam_dbl_item_t),
|
||||
(lam_construct_t) lam_p2p_cdi_construct,
|
||||
(lam_destruct_t) lam_p2p_cdi_destruct
|
||||
};
|
||||
|
||||
|
||||
@ -22,12 +19,12 @@ static int lam_datatype_init = 0;
|
||||
lam_dbl_list_t lam_p2p_cdis;
|
||||
|
||||
|
||||
void lam_datatype_t(lam_p2p_cdi_t* cdi)
|
||||
void lam_datatype_t(lam_p2p_cdi_t * cdi)
|
||||
{
|
||||
if(fetchNset(&lam_p2p_cdis_init,1) == 0) {
|
||||
lam_dbl_init(&lam_p2p_cdis);
|
||||
if (fetchNset(&lam_p2p_cdis_init, 1) == 0) {
|
||||
lam_dbl_construct(&lam_p2p_cdis);
|
||||
}
|
||||
lam_dbl_item_init(&cdi->cdi_base);
|
||||
lam_dbl_item_construct(&cdi->cdi_base);
|
||||
cdi->cdi_name = 0;
|
||||
cdi->cdi_id = lam_dbl_get_size(&lam_p2p_cdis) + 1;
|
||||
cdi->cdi_frag_first_size = 0;
|
||||
@ -36,16 +33,16 @@ void lam_datatype_t(lam_p2p_cdi_t* cdi)
|
||||
cdi->cdi_endpoint_latency = 0;
|
||||
cdi->cdi_endpoint_bandwidth = 0;
|
||||
cdi->cdi_endpoint_count = 0;
|
||||
lam_dbl_init(&cdi->cdi_incomplete_sends);
|
||||
lam_dbl_construct(&cdi->cdi_incomplete_sends);
|
||||
lam_dbl_append(&lam_p2p_cdis, &cdi->cdi_base);
|
||||
}
|
||||
|
||||
|
||||
void lam_p2p_cdi_destroy(lam_p2p_cdi_t* cdi)
|
||||
void lam_p2p_cdi_destruct(lam_p2p_cdi_t * cdi)
|
||||
{
|
||||
lam_dbl_remove(&lam_p2p_cdis, &cdi->cdi_base);
|
||||
lam_dbl_destroy(&cdi->cdi_incomplete_sends);
|
||||
lam_dbl_item_destroy(&cdi->cdi_base);
|
||||
lam_dbl_destruct(&cdi->cdi_incomplete_sends);
|
||||
lam_dbl_item_destruct(&cdi->cdi_base);
|
||||
}
|
||||
|
||||
|
||||
@ -116,21 +113,20 @@ struct lam_packer_state_t {
|
||||
* @param count size of array
|
||||
* @param type type descriptor
|
||||
*/
|
||||
lam_packer_status_t lam_packer(lam_packer_direction_t direction,
|
||||
lam_packer_status_t
|
||||
lam_packer(lam_packer_direction_t direction,
|
||||
void *buf,
|
||||
size_t bufsize,
|
||||
size_t *offset,
|
||||
size_t * offset,
|
||||
void *typebuf,
|
||||
size_t ntype,
|
||||
lam_datatype_t *datatype,
|
||||
lam_pack_state_t *pack_state,
|
||||
lam_checksum_t *checksum)
|
||||
lam_datatype_t * datatype,
|
||||
lam_pack_state_t * pack_state, lam_checksum_t * checksum)
|
||||
{
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* lam_datatype_copy - Copy (the contents of) an array of data types
|
||||
*
|
||||
@ -139,11 +135,12 @@ lam_packer_status_t lam_packer(lam_packer_direction_t direction,
|
||||
* @param count size of array
|
||||
* @param type type descriptor
|
||||
*/
|
||||
void lam_datatype_copy(void *dest,
|
||||
void
|
||||
lam_datatype_copy(void *dest,
|
||||
const void *src,
|
||||
size_t count,
|
||||
lam_datatype_t *datatype,
|
||||
lam_checksum_t *checksum)
|
||||
lam_checksum_t *csum)
|
||||
{
|
||||
if (datatype == NULL) {
|
||||
memmove(dest, src, count);
|
||||
@ -165,5 +162,3 @@ void lam_datatype_copy(void *dest,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -2,7 +2,7 @@
|
||||
* $HEADER$
|
||||
*/
|
||||
|
||||
/** @file
|
||||
/** @file
|
||||
*
|
||||
* Data stuctures and functions related to LAM datatypes.
|
||||
*/
|
||||
@ -182,9 +182,21 @@ struct lam_dataxdr_element_t {
|
||||
|
||||
|
||||
/**
|
||||
* Function protoype to do a memcpy with checksum
|
||||
* Function protoype for a generalized memcpy()
|
||||
*
|
||||
* Copy data from one buffer to another and optionally calculate a
|
||||
* checksum or CRC
|
||||
*
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param src pointer to the source buffer
|
||||
* @param size size of the buffer
|
||||
* @param check pointer to the optional checksum or CRC
|
||||
* @return the original value of dst
|
||||
*/
|
||||
typedef void *(*lam_memcpy_fn_t)(void *dst, const void *src, size_t size, void *csum);
|
||||
typedef void *(lam_memcpy_fn_t) (void *restrict dst,
|
||||
const void *restrict src,
|
||||
size_t size,
|
||||
lam_memcpy_state_t *check);
|
||||
|
||||
|
||||
/* interface **********************************************************/
|
||||
@ -210,7 +222,7 @@ int lam_datatype_checksum(const void *addr,
|
||||
* @param src Input data type array
|
||||
* @param count Size of array
|
||||
* @param datatype Datatype descriptor
|
||||
* @param csum Pointer to checksum or CRC
|
||||
* @param check Pointer to checksum or CRC
|
||||
* @return 0 on success, -1 on error
|
||||
*/
|
||||
int lam_datatype_copy(void *dst,
|
||||
@ -218,7 +230,7 @@ int lam_datatype_copy(void *dst,
|
||||
size_t count,
|
||||
lam_datatype_t *datatype,
|
||||
lam_memcpy_fn_t *memcpy_fn,
|
||||
void *csum);
|
||||
lam_memcpy_state_t *check);
|
||||
|
||||
/**
|
||||
* Copy (the contents of) an array of data types, and convert to
|
||||
@ -239,7 +251,8 @@ int lam_datatype_convert(void *dst,
|
||||
const void *src,
|
||||
lam_datatype_t *src_datatype,
|
||||
size_t src_count,
|
||||
lam_checksum_t *checksum);
|
||||
lam_memcpy_fn_t *memcpy_fn,
|
||||
lam_memcpy_state_t *check);
|
||||
|
||||
/**
|
||||
* Pack state
|
||||
@ -266,7 +279,7 @@ struct lam_pack_state_t {
|
||||
* @param ntype size of type array
|
||||
* @param datatype type descriptor
|
||||
* @param memcpy_fn pointer to memcpy function
|
||||
* @param csum pointer to checksum
|
||||
* @param check pointer to checksum
|
||||
* @return 0 if complete, non-zero otherwise
|
||||
*
|
||||
* Incrementally copy data type arrays to/from a packed buffer by
|
||||
@ -283,7 +296,7 @@ int lam_datatype_pack(lam_pack_state_t *state,
|
||||
size_t ntype,
|
||||
lam_datatype_t *datatype,
|
||||
lam_memcpy_fn_t *memcpy_fn,
|
||||
void *csum);
|
||||
lam_memcpy_state_t *check);
|
||||
|
||||
|
||||
/**
|
||||
@ -296,7 +309,7 @@ int lam_datatype_pack(lam_pack_state_t *state,
|
||||
* @param bufsize size of buffer
|
||||
* @param datatype type descriptor
|
||||
* @param memcpy_fn pointer to memcpy function
|
||||
* @param csum pointer to checksum
|
||||
* @param check pointer to checksum
|
||||
* @return 0 complete, non-zero otherwise
|
||||
*
|
||||
* Incrementally copy data type arrays to/from a packed buffer by
|
||||
@ -313,7 +326,7 @@ int lam_datatype_unpack(lam_pack_state_t *state,
|
||||
size_t bufsize,
|
||||
lam_datatype_t *datatype,
|
||||
lam_memcpy_fn_t *memcpy_fn,
|
||||
void *csum);
|
||||
lam_memcpy_state_t *check);
|
||||
|
||||
/**
|
||||
* Incrementally generate an iovec for gathering from an array of
|
||||
@ -385,7 +398,7 @@ int lam_datatype_scatter_iovec(lam_pack_state_t *state,
|
||||
size_t bufsize,
|
||||
lam_datatype_t *datatype,
|
||||
lam_memcpy_fn_t *memcpy_fn,
|
||||
void *csum);
|
||||
lam_memcpy_state_t *check);
|
||||
|
||||
|
||||
/*
|
||||
@ -399,35 +412,41 @@ int lam_datatype_scatter_iovec(lam_pack_state_t *state,
|
||||
* @param state pointer to state object for the current sequence of copies
|
||||
* @param sum_size the length of the entire buffer to be checksummed
|
||||
*/
|
||||
static inline void lam_memcpy_init(lam_memcpy_state_t *state, size_t sum_size)
|
||||
static inline void
|
||||
lam_memcpy_init(lam_memcpy_state_t *state, size_t sum_size)
|
||||
{
|
||||
state->size = sum_size;
|
||||
state->first_call = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* prototypes for memcpy functions
|
||||
*/
|
||||
|
||||
extern lam_memcpy_fn_t lam_memcpy_crc32;
|
||||
extern lam_memcpy_fn_t lam_memcpy_sum32;
|
||||
extern lam_memcpy_fn_t lam_memcpy_sum64;
|
||||
|
||||
/**
|
||||
* Copy data from one buffer to another and calculate a 32-bit checksum
|
||||
* Copy data from one buffer to another
|
||||
*
|
||||
* @param dst pointer to the destination buffer
|
||||
* @param src pointer to the source buffer
|
||||
* @param size size of the buffer
|
||||
* @param state pointer to a memcpy with checksum/CRC state structure (ignored)
|
||||
* @param check unused
|
||||
* @return the original value of dst
|
||||
*/
|
||||
static inline void *lam_memcpy(void *dst, const void *src, size_t size,
|
||||
lam_memcpy_state_t *state)
|
||||
void *check)
|
||||
{
|
||||
return memcpy(dst, src, size);
|
||||
}
|
||||
|
||||
#if 0
|
||||
uint32_t lam_crc32(const void *restrict buffer, size_t size, uint32_t initial_crc);
|
||||
uint32_t lam_sum32(const void *restrict buffer, size_t size, uint32_t initial_crc);
|
||||
void *lam_memcpy_sum32(void *dst, const void *src, size_t size,
|
||||
lam_memcpy_state_t *state);
|
||||
void *lam_memcpy_crc32(void *dst, const void *src, size_t size,
|
||||
lam_memcpy_state_t *state);
|
||||
uint32_t lam_crc32(const void *restrict buffer, size_t size,
|
||||
uint32_t initial_crc);
|
||||
uint32_t lam_sum32(const void *restrict buffer, size_t size,
|
||||
uint32_t initial_crc);
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ int lam_datatype_copy(void *dst,
|
||||
size_t count,
|
||||
lam_datatype_t *d,
|
||||
lam_memcpy_fn_t *memcpy_fn,
|
||||
void *csum)
|
||||
lam_memcpy_state_t *csum)
|
||||
{
|
||||
int status;
|
||||
|
||||
|
@ -32,8 +32,7 @@
|
||||
*/
|
||||
void *lam_memcpy_sum32(void *restrict dst,
|
||||
const void *restrict src,
|
||||
size_t size,
|
||||
lam_memcpy_state_t *state)
|
||||
size_t size, lam_memcpy_state_t * state)
|
||||
{
|
||||
uint32_t *restrict p = (uint32_t *) dst;
|
||||
uint32_t *restrict q = (uint32_t *) src;
|
||||
@ -52,20 +51,25 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
csumlenresidue = (csumlen > size) ? (csumlen - size) : 0;
|
||||
temp = state->partial_int;
|
||||
|
||||
#if 0
|
||||
if (intaligned(p) && intaligned(q)) {
|
||||
if (IS_32BIT_ALIGNED(p) && IS_32BIT_ALIGNED(q)) {
|
||||
if (state->partial_size) {
|
||||
// do we have enough data to fill out the partial word?
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do...
|
||||
/* do we have enough data to fill out the partial word? */
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) {
|
||||
/* YES, we do... */
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
memcpy(p, ((char *) &temp + state->partial_size),
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size);
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
csum += (temp - state->partial_int);
|
||||
size -= sizeof(uint32_t) - state->partial_size;
|
||||
// now we have an unaligned source and an unaligned destination
|
||||
/*
|
||||
* now we have an unaligned source and an unaligned
|
||||
* destination
|
||||
*/
|
||||
for (; size >= sizeof(*q); size -= sizeof(*q)) {
|
||||
memcpy(&temp, q, sizeof(temp));
|
||||
q++;
|
||||
@ -75,7 +79,8 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
}
|
||||
state->partial_size = 0;
|
||||
state->partial_int = 0;
|
||||
} else { // NO, we don't...
|
||||
} else {
|
||||
/* NO, we don't... */
|
||||
memcpy(((char *) &temp + state->partial_size), q, size);
|
||||
memcpy(p, ((char *) &temp + state->partial_size), size);
|
||||
q = (uint32_t *) ((char *) q + size);
|
||||
@ -85,7 +90,7 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
state->partial_size += size;
|
||||
size = 0;
|
||||
}
|
||||
} else { // fast path...
|
||||
} else { /* fast path... */
|
||||
size_t numLongs = size / sizeof(uint32_t);
|
||||
for (i = 0; i < numLongs; i++) {
|
||||
csum += *q;
|
||||
@ -93,27 +98,33 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
}
|
||||
state->partial_int = 0;
|
||||
state->partial_size = 0;
|
||||
if (intaligned(size) && (csumlenresidue == 0)) {
|
||||
if (IS_32BIT_ALIGNED(size) && (csumlenresidue == 0)) {
|
||||
state->sum = csum;
|
||||
return dst;
|
||||
} else {
|
||||
size -= i * sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
} else if (intaligned(q)) {
|
||||
} else if (IS_32BIT_ALIGNED(q)) {
|
||||
if (state->partial_size) {
|
||||
// do we have enough data to fill out the partial word?
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do...
|
||||
/* do we have enough data to fill out the partial word? */
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) {
|
||||
/* YES, we do... */
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
memcpy(p, ((char *) &temp + state->partial_size),
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size);
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
csum += (temp - state->partial_int);
|
||||
size -= sizeof(uint32_t) - state->partial_size;
|
||||
// now we have an unaligned source and an unknown alignment for our destination
|
||||
if (intaligned(p)) {
|
||||
/*
|
||||
* now we have an unaligned source and an unknown
|
||||
* alignment for our destination
|
||||
*/
|
||||
if (IS_32BIT_ALIGNED(p)) {
|
||||
size_t numLongs = size / sizeof(uint32_t);
|
||||
for (i = 0; i < numLongs; i++) {
|
||||
memcpy(&temp, q, sizeof(temp));
|
||||
@ -133,7 +144,8 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
}
|
||||
state->partial_int = 0;
|
||||
state->partial_size = 0;
|
||||
} else { // NO, we don't...
|
||||
} else {
|
||||
/* NO, we don't... */
|
||||
memcpy(((char *) &temp + state->partial_size), q, size);
|
||||
memcpy(p, ((char *) &temp + state->partial_size), size);
|
||||
q = (uint32_t *) ((char *) q + size);
|
||||
@ -153,20 +165,26 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
state->partial_int = 0;
|
||||
state->partial_size = 0;
|
||||
}
|
||||
} else if (intaligned(p)) {
|
||||
} else if (IS_32BIT_ALIGNED(p)) {
|
||||
if (state->partial_size) {
|
||||
// do we have enough data to fill out the partial word?
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do...
|
||||
/* do we have enough data to fill out the partial word? */
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) {
|
||||
/* YES, we do... */
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
memcpy(p, ((char *) &temp + state->partial_size),
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size);
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
csum += (temp - state->partial_int);
|
||||
size -= sizeof(uint32_t) - state->partial_size;
|
||||
// now we have a source of unknown alignment and a unaligned destination
|
||||
if (intaligned(q)) {
|
||||
/*
|
||||
* now we have a source of unknown alignment and a
|
||||
* unaligned destination
|
||||
*/
|
||||
if (IS_32BIT_ALIGNED(q)) {
|
||||
for (; size >= sizeof(*q); size -= sizeof(*q)) {
|
||||
temp = *q++;
|
||||
csum += temp;
|
||||
@ -186,7 +204,8 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
state->partial_size = 0;
|
||||
state->partial_int = 0;
|
||||
}
|
||||
} else { // NO, we don't...
|
||||
} else {
|
||||
/* NO, we don't... */
|
||||
memcpy(((char *) &temp + state->partial_size), q, size);
|
||||
memcpy(p, ((char *) &temp + state->partial_size), size);
|
||||
q = (uint32_t *) ((char *) q + size);
|
||||
@ -208,25 +227,31 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
}
|
||||
} else {
|
||||
if (state->partial_size) {
|
||||
// do we have enough data to fill out the partial word?
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do...
|
||||
/* do we have enough data to fill out the partial word? */
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) {
|
||||
/* YES, we do... */
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
memcpy(p, ((char *) &temp + state->partial_size),
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size);
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
csum += (temp - state->partial_int);
|
||||
size -= sizeof(uint32_t) - state->partial_size;
|
||||
// now we have an unknown alignment for our source and destination
|
||||
if (intaligned(q) && intaligned(p)) {
|
||||
/*
|
||||
* now we have an unknown alignment for our source and
|
||||
* destination
|
||||
*/
|
||||
if (IS_32BIT_ALIGNED(q) && IS_32BIT_ALIGNED(p)) {
|
||||
size_t numLongs = size / sizeof(uint32_t);
|
||||
for (i = 0; i < numLongs; i++) {
|
||||
csum += *q;
|
||||
*p++ = *q++;
|
||||
}
|
||||
size -= i * sizeof(uint32_t);
|
||||
} else { // safe but slower for all other alignments
|
||||
} else { /* safe but slower for all other alignments */
|
||||
for (; size >= sizeof(*q); size -= sizeof(*q)) {
|
||||
memcpy(&temp, q, sizeof(temp));
|
||||
q++;
|
||||
@ -237,7 +262,8 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
}
|
||||
state->partial_int = 0;
|
||||
state->partial_size = 0;
|
||||
} else { // NO, we don't...
|
||||
} else {
|
||||
/* NO, we don't... */
|
||||
memcpy(((char *) &temp + state->partial_size), q, size);
|
||||
memcpy(p, ((char *) &temp + state->partial_size), size);
|
||||
q = (uint32_t *) ((char *) q + size);
|
||||
@ -259,56 +285,68 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
state->partial_int = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if size is non-zero there was a bit left, less than an uint32_t's worth */
|
||||
/*
|
||||
* if size is non-zero there was a bit left, less than an
|
||||
* uint32_t's worth
|
||||
*/
|
||||
|
||||
if ((size != 0) && (csumlenresidue == 0)) {
|
||||
temp = state->partial_int;
|
||||
if (state->partial_size) {
|
||||
if (size >= (sizeof(uint32_t) - state->partial_size)) {
|
||||
// copy all remaining bytes from q to p
|
||||
/* copy all remaining bytes from q to p */
|
||||
uint32_t copytemp = 0;
|
||||
memcpy(©temp, q, size);
|
||||
memcpy(p, ©temp, size);
|
||||
// fill out rest of partial word and add to checksum
|
||||
/* fill out rest of partial word and add to checksum */
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
// avoid unsigned arithmetic overflow by subtracting the old partial
|
||||
// word from the new one before adding to the checksum...
|
||||
/*
|
||||
* avoid unsigned arithmetic overflow by subtracting
|
||||
* the old partial word from the new one before adding
|
||||
* to the checksum...
|
||||
*/
|
||||
csum += (temp - state->partial_int);
|
||||
size -= sizeof(uint32_t) - state->partial_size;
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size);
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
state->partial_size = size;
|
||||
// reset temp, and calculate next partial word
|
||||
/* reset temp, and calculate next partial word */
|
||||
temp = 0;
|
||||
if (size) {
|
||||
memcpy(&temp, q, size);
|
||||
}
|
||||
// add it to the the checksum
|
||||
/* add it to the the checksum */
|
||||
csum += temp;
|
||||
state->partial_int = temp;
|
||||
} else {
|
||||
// copy all remaining bytes from q to p
|
||||
/* copy all remaining bytes from q to p */
|
||||
uint32_t copytemp = 0;
|
||||
memcpy(©temp, q, size);
|
||||
memcpy(p, ©temp, size);
|
||||
// fill out rest of partial word and add to checksum
|
||||
/* fill out rest of partial word and add to checksum */
|
||||
memcpy(((char *) &temp + state->partial_size), q, size);
|
||||
// avoid unsigned arithmetic overflow by subtracting the old partial
|
||||
// word from the new one before adding to the checksum...
|
||||
/*
|
||||
* avoid unsigned arithmetic overflow by subtracting
|
||||
* the old partial word from the new one before adding
|
||||
* to the checksum...
|
||||
*/
|
||||
csum += temp - state->partial_int;
|
||||
state->partial_int = temp;
|
||||
state->partial_size += size;
|
||||
}
|
||||
} else { // fast path...
|
||||
// temp and state->partial_int are 0 if state->partial_size is 0...
|
||||
} else { /* fast path... */
|
||||
/*
|
||||
* temp and state->partial_int are 0 if
|
||||
* state->partial_size is 0...
|
||||
*/
|
||||
memcpy(&temp, q, size);
|
||||
csum += temp;
|
||||
memcpy(p, &temp, size);
|
||||
state->partial_int = temp;
|
||||
state->partial_size = size;
|
||||
// done...return the checksum
|
||||
/* done...return the checksum */
|
||||
}
|
||||
} else if (csumlenresidue != 0) {
|
||||
if (size != 0) {
|
||||
@ -316,32 +354,43 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
memcpy(&temp, q, size);
|
||||
memcpy(p, &temp, size);
|
||||
}
|
||||
if (csumlenresidue < (ssize_t) (sizeof(uint32_t) - size - state->partial_size)) {
|
||||
if (csumlenresidue <
|
||||
(ssize_t) (sizeof(uint32_t) - size - state->partial_size)) {
|
||||
temp = state->partial_int;
|
||||
memcpy(((char *) &temp + state->partial_size), q, (size + csumlenresidue));
|
||||
// avoid unsigned arithmetic overflow by subtracting the old partial
|
||||
// word from the new one before adding to the checksum...
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(size + csumlenresidue));
|
||||
/*
|
||||
* avoid unsigned arithmetic overflow by subtracting the
|
||||
* old partial word from the new one before adding to the
|
||||
* checksum...
|
||||
*/
|
||||
csum += temp - state->partial_int;
|
||||
q++;
|
||||
state->partial_int = temp;
|
||||
state->partial_size += size + csumlenresidue;
|
||||
csumlenresidue = 0;
|
||||
} else {
|
||||
// we have enough chksum data to fill out our last partial
|
||||
// word
|
||||
/*
|
||||
* we have enough chksum data to fill out our last partial
|
||||
* word
|
||||
*/
|
||||
temp = state->partial_int;
|
||||
memcpy(((char *) &temp + state->partial_size), q,
|
||||
(sizeof(uint32_t) - state->partial_size));
|
||||
// avoid unsigned arithmetic overflow by subtracting the old partial
|
||||
// word from the new one before adding to the checksum...
|
||||
/*
|
||||
* avoid unsigned arithmetic overflow by subtracting the
|
||||
* old partial word from the new one before adding to the
|
||||
* checksum...
|
||||
*/
|
||||
csum += temp - state->partial_int;
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size);
|
||||
csumlenresidue -= sizeof(uint32_t) - state->partial_size - size;
|
||||
q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
|
||||
state->partial_size);
|
||||
csumlenresidue -=
|
||||
sizeof(uint32_t) - state->partial_size - size;
|
||||
state->partial_size = 0;
|
||||
state->partial_int = 0;
|
||||
}
|
||||
#if 0
|
||||
if (intaligned(q)) {
|
||||
if (IS_32BIT_ALIGNED(q)) {
|
||||
for (i = 0; i < csumlenresidue / sizeof(uint32_t); i++) {
|
||||
csum += *q++;
|
||||
}
|
||||
@ -352,7 +401,6 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
q++;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
csumlenresidue -= i * sizeof(uint32_t);
|
||||
if (csumlenresidue) {
|
||||
temp = 0;
|
||||
@ -368,4 +416,3 @@ void *lam_memcpy_sum32(void *restrict dst,
|
||||
|
||||
return dst;
|
||||
}
|
||||
|
||||
|
@ -7,43 +7,46 @@
|
||||
/*
|
||||
* lam_info_t classes
|
||||
*/
|
||||
lam_class_info_t lam_info_cls = { "lam_info_t",
|
||||
&lam_list_cls,
|
||||
(class_init_t)lam_info_init,
|
||||
(class_destroy_t)lam_info_destroy};
|
||||
lam_class_info_t lam_info_t_class_info = {
|
||||
"lam_info_t",
|
||||
CLASS_INFO(lam_list_t),
|
||||
(lam_construct_t)lam_info_construct,
|
||||
(lam_destruct_t)lam_info_destruct
|
||||
};
|
||||
|
||||
/*
|
||||
* lam_info_entry_t classes
|
||||
*/
|
||||
lam_class_info_t lam_info_entry_cls = {
|
||||
lam_class_info_t lam_info_entry_t_class_info = {
|
||||
"lam_info_entry_t",
|
||||
&lam_list_item_cls,
|
||||
(class_init_t)lam_info_entry_init,
|
||||
(class_destroy_t)lam_info_entry_destroy};
|
||||
CLASS_INFO(lam_list_item_t),
|
||||
(lam_construct_t)lam_info_entry_construct,
|
||||
(lam_destruct_t)lam_info_entry_destruct
|
||||
};
|
||||
|
||||
/*
|
||||
* lam_info_t interface functions
|
||||
*/
|
||||
void lam_info_init(lam_info_t *info) {
|
||||
SUPER_INIT(info, lam_info_cls.cls_parent);
|
||||
void lam_info_construct(lam_info_t *info) {
|
||||
OBJ_CONSTRUCT_SUPER(info, lam_list_t);
|
||||
info->i_fhandle = -1;
|
||||
}
|
||||
|
||||
void lam_info_destroy(lam_info_t *info) {
|
||||
SUPER_DESTROY(info, lam_info_cls.cls_parent);
|
||||
void lam_info_destruct(lam_info_t *info) {
|
||||
OBJ_DESTRUCT_SUPER(info, lam_list_t);
|
||||
}
|
||||
|
||||
/*
|
||||
* lam_info_entry_t interface functions
|
||||
*/
|
||||
void lam_info_entry_init(lam_info_entry_t *entry) {
|
||||
SUPER_INIT(entry, lam_list_item_cls.cls_parent);
|
||||
void lam_info_entry_construct(lam_info_entry_t *entry) {
|
||||
OBJ_CONSTRUCT_SUPER(entry, lam_object_t);
|
||||
memset(entry->ie_key, 0, sizeof(entry->ie_key));
|
||||
entry->ie_key[MPI_MAX_INFO_KEY] = 0;
|
||||
}
|
||||
|
||||
void lam_info_entry_destroy(lam_info_entry_t *entry) {
|
||||
SUPER_DESTROY(entry, lam_list_item_cls.cls_parent);
|
||||
void lam_info_entry_destruct(lam_info_entry_t *entry) {
|
||||
OBJ_DESTRUCT_SUPER(entry, lam_object_t);
|
||||
if (NULL != entry->ie_value) {
|
||||
free(entry->ie_value);
|
||||
}
|
||||
|
@ -37,19 +37,19 @@ struct lam_info_entry_t {
|
||||
typedef struct lam_info_entry_t lam_info_entry_t;
|
||||
|
||||
/**
|
||||
* Some declarations needed to use OBJ_CREATE and OBJ_DESTROY macros
|
||||
* Some declarations needed to use OBJ_NEW and OBJ_DESTRUCT macros
|
||||
*/
|
||||
extern lam_class_info_t lam_info_cls;
|
||||
extern lam_class_info_t lam_info_entry_cls;
|
||||
extern lam_class_info_t lam_info_t_class_info;
|
||||
extern lam_class_info_t lam_info_entry_t_class_info;
|
||||
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
void lam_info_init(lam_info_t *info);
|
||||
void lam_info_destroy(lam_info_t *info);
|
||||
void lam_info_construct(lam_info_t *info);
|
||||
void lam_info_destruct(lam_info_t *info);
|
||||
|
||||
void lam_info_entry_init(lam_info_entry_t *entry);
|
||||
void lam_info_entry_destroy(lam_info_entry_t *entry);
|
||||
void lam_info_entry_construct(lam_info_entry_t *entry);
|
||||
void lam_info_entry_destruct(lam_info_entry_t *entry);
|
||||
#if defined(c_plusplus) || defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@ int MPI_Info_create(MPI_Info *info) {
|
||||
* allocates the space for MPI_Info, but also calls all the
|
||||
* relevant init functions.
|
||||
*/
|
||||
(*info) = OBJ_CREATE(lam_info_t, &lam_info_cls);
|
||||
(*info) = OBJ_NEW(lam_info_t);
|
||||
|
||||
if (NULL == (*info)) {
|
||||
printf ("Malloc failed. Ran out of resources\n");
|
||||
|
@ -97,7 +97,7 @@ int MPI_Info_set(MPI_Info info, char *key, char *value) {
|
||||
free(old_info->ie_value);
|
||||
old_info->ie_value = new_value;
|
||||
} else {
|
||||
new_info = OBJ_CREATE(lam_info_entry_t, &lam_info_entry_cls);
|
||||
new_info = OBJ_NEW(lam_info_entry_t);
|
||||
if (NULL == new_info) {
|
||||
printf ("Unable to malloc memory for new (key, value) pair\n");
|
||||
return MPI_ERR_SYSRESOURCE;
|
||||
|
@ -7,22 +7,22 @@ static lam_mutex_t lam_proc_lock;
|
||||
lam_proc_t* lam_proc_self = 0;
|
||||
|
||||
|
||||
lam_class_info_t lam_proc_cls = {
|
||||
lam_class_info_t lam_proc_t_class_info = {
|
||||
"lam_proc_t",
|
||||
&lam_list_cls,
|
||||
(class_init_t)lam_proc_init,
|
||||
(class_destroy_t)lam_proc_destroy
|
||||
CLASS_INFO(lam_list_t),
|
||||
(lam_construct_t)lam_proc_construct,
|
||||
(lam_destruct_t)lam_proc_destruct
|
||||
};
|
||||
|
||||
void lam_proc_init(lam_proc_t* proc)
|
||||
void lam_proc_construct(lam_proc_t* proc)
|
||||
{
|
||||
static int init = 0;
|
||||
if(init++ == 0) {
|
||||
lam_list_init(&lam_proc_list);
|
||||
lam_mutex_init(&lam_proc_lock);
|
||||
lam_list_construct(&lam_proc_list);
|
||||
lam_mutex_construct(&lam_proc_lock);
|
||||
}
|
||||
|
||||
SUPER_INIT(proc, &lam_list_cls);
|
||||
OBJ_CONSTRUCT_SUPER(proc, lam_list_t);
|
||||
proc->proc_job = 0;
|
||||
proc->proc_vpid = 0;
|
||||
proc->proc_pml = 0;
|
||||
@ -33,11 +33,11 @@ void lam_proc_init(lam_proc_t* proc)
|
||||
}
|
||||
|
||||
|
||||
void lam_proc_destroy(lam_proc_t* proc)
|
||||
void lam_proc_destruct(lam_proc_t* proc)
|
||||
{
|
||||
THREAD_LOCK(&lam_proc_lock);
|
||||
lam_list_remove_item(&lam_proc_list, (lam_list_item_t*)proc);
|
||||
THREAD_UNLOCK(&lam_proc_lock);
|
||||
SUPER_DESTROY(proc, &lam_list_cls);
|
||||
OBJ_DESTRUCT_SUPER(proc, lam_list_t);
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "lam/lfc/list.h"
|
||||
|
||||
|
||||
extern lam_class_info_t lam_proc_cls;
|
||||
extern lam_class_info_t lam_proc_t_class_info;
|
||||
|
||||
|
||||
struct lam_proc_t {
|
||||
@ -30,8 +30,8 @@ struct lam_proc_t {
|
||||
typedef struct lam_proc_t lam_proc_t;
|
||||
|
||||
|
||||
void lam_proc_init(lam_proc_t*);
|
||||
void lam_proc_destroy(lam_proc_t*);
|
||||
void lam_proc_construct(lam_proc_t*);
|
||||
void lam_proc_destruct(lam_proc_t*);
|
||||
|
||||
static inline lam_proc_t* lam_proc_local(void)
|
||||
{
|
||||
|
@ -4,23 +4,23 @@
|
||||
|
||||
#include "mpi/request/request.h"
|
||||
|
||||
lam_class_info_t lam_request_cls = {
|
||||
lam_class_info_t lam_request_t_class_info = {
|
||||
"lam_request_t",
|
||||
&lam_object_cls,
|
||||
(class_init_t) lam_request_init,
|
||||
(class_destroy_t) lam_request_destroy,
|
||||
CLASS_INFO(lam_object_t),
|
||||
(lam_construct_t) lam_request_construct,
|
||||
(lam_destruct_t) lam_request_destruct,
|
||||
};
|
||||
|
||||
|
||||
void lam_request_init(lam_request_t* rq)
|
||||
void lam_request_construct(lam_request_t* rq)
|
||||
{
|
||||
SUPER_INIT(rq, &lam_object_cls);
|
||||
OBJ_CONSTRUCT_SUPER(rq, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
void lam_request_destroy(lam_request_t* rq)
|
||||
void lam_request_destruct(lam_request_t* rq)
|
||||
{
|
||||
SUPER_DESTROY(rq, &lam_object_cls);
|
||||
OBJ_DESTRUCT_SUPER(rq, lam_object_t);
|
||||
}
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "lam/lfc/list.h"
|
||||
|
||||
|
||||
extern lam_class_info_t lam_request_cls;
|
||||
extern lam_class_info_t lam_request_t_class_info;
|
||||
|
||||
typedef enum {
|
||||
LAM_REQUEST_PML,
|
||||
@ -24,8 +24,8 @@ struct lam_request_t {
|
||||
};
|
||||
typedef struct lam_request_t lam_request_t;
|
||||
|
||||
void lam_request_init(lam_request_t*);
|
||||
void lam_request_destroy(lam_request_t*);
|
||||
void lam_request_construct(lam_request_t*);
|
||||
void lam_request_destruct(lam_request_t*);
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -111,7 +111,7 @@ void test_dynamic()
|
||||
{
|
||||
lam_fast_hash_t *table;
|
||||
|
||||
table = OBJ_CREATE(lam_fast_hash_t, &lam_fast_hash_cls);
|
||||
table = OBJ_NEW(lam_fast_hash_t);
|
||||
if ( NULL == table )
|
||||
{
|
||||
printf("Error: Unable to create hash table.\n");
|
||||
@ -128,12 +128,12 @@ void test_static()
|
||||
{
|
||||
lam_fast_hash_t table;
|
||||
|
||||
STATIC_INIT(table, &lam_fast_hash_cls);
|
||||
OBJ_CONSTRUCT(&table, lam_fast_hash_t);
|
||||
|
||||
printf("Testing with statically created table...\n");
|
||||
test_htable(&table);
|
||||
|
||||
STATIC_DESTROY(table);
|
||||
OBJ_DESTRUCT(&table);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ int main(int argc, char **argv)
|
||||
|
||||
/* initialize list */
|
||||
lam_list_set_size(&list,0Xdeadbeaf);
|
||||
lam_list_init(&list);
|
||||
lam_list_construct(&list);
|
||||
|
||||
/* check length of list */
|
||||
list_size=lam_list_get_size(&list);
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user