1
1
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.
Этот коммит содержится в:
David Daniel 2004-02-10 14:04:27 +00:00
родитель 413d87586d
Коммит 00e50911b0
93 изменённых файлов: 1439 добавлений и 1068 удалений

Просмотреть файл

@ -10,3 +10,7 @@ doxygen
bin bin
lib lib
include include
cscope.*
etags

Просмотреть файл

@ -8,18 +8,21 @@
#define CHANNEL_CLS(chnl) ((lam_ctchannel_class_t *)(OBJECT(chnl)->obj_class)) #define CHANNEL_CLS(chnl) ((lam_ctchannel_class_t *)(OBJECT(chnl)->obj_class))
lam_ctchannel_class_t lam_ctchannel_cls = { lam_ctchannel_class_t lam_ct_channel_t_class_info = {
{"lam_ct_channel_t", &lam_object_cls, {
(class_init_t)lam_cth_init, "lam_ct_channel_t",
(class_destroy_t)lam_obj_destroy}, CLASS_INFO(lam_object_t),
(lam_construct_t)lam_cth_construct,
(lam_destruct_t)lam_object_destruct
},
NULL, NULL, NULL, NULL, NULL, NULL, 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_status = CT_CHNL_CLOSED;
channel->cth_id = 0; channel->cth_id = 0;
channel->cth_timeout_secs = 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_ctchannel_class_t lam_tcp_chnl_t_class_info = {
{"lam_tcp_chnl_t", &lam_ctchannel_cls, {
(class_init_t)lam_tcpch_init, "lam_tcp_chnl_t",
(class_destroy_t)lam_tcpch_destroy}, CLASS_INFO(lam_ctchannel_t),
(lam_construct_t) lam_tcpch_construct,
(lam_destruct_t) lam_tcpch_destruct
},
lam_tcpch_send, lam_tcpch_send,
lam_tcpch_recv, lam_tcpch_recv,
lam_tcpch_get_msg, lam_tcpch_get_msg,
@ -100,17 +106,17 @@ lam_ctchannel_class_t lam_tcp_channel_cls = {
lam_tcpch_send_packed_msg 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; channel->tcp_sockfd = 0;
memset(&(channel->tcp_addr), 0, sizeof(channel->tcp_addr)); memset(&(channel->tcp_addr), 0, sizeof(channel->tcp_addr));
channel->tcp_blocking = 0; 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; } 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 typedef struct lam_ctchannel
{ {
@ -109,7 +109,7 @@ typedef struct lam_ctchannel
} lam_ctchannel_t; } 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; int tcp_blocking;
} lam_tcp_chnl_t; } 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_construct(lam_tcp_chnl_t *channel);
void lam_tcpch_destroy(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, 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_ctnode_failed_fn ctl_node_failed_callback;
} lam_ctctrl_t; } lam_ctctrl_t;
void lam_ctl_init(lam_ctctrl_t *ctrl); void lam_ctl_construct(lam_ctctrl_t *ctrl);
void lam_ctl_destroy(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) 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" #include "lam/mem/malloc.h"
lam_class_info_t lam_ctctrl_cls = {"lam_ct_ctrl_t", &lam_object_cls, lam_class_info_t lam_ct_ctrl_t_class_info = {
(class_init_t) lam_ctc_init, (class_destroy_t)lam_ctc_destroy}; "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, lam_class_info_t lam_ctmsg_t_class_info = {
(class_init_t) lam_ctm_init, (class_destroy_t)lam_ctm_destroy}; "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) - static const uint32_t ctrl_alloc_len = sizeof(lam_ct_ctrl_t) -
sizeof(lam_object_t) - sizeof(lam_object_t) -
sizeof(ctrl->ctc_info); 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_is_user_msg = 0;
ctrl->ctc_routing_type = LAM_CT_PT2PT; 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); 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 sender,
uint32_t dest) 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_forwarding (uint32_t)><ctc_client_tag (uint32_t)>
<ctc_info_len (uint32_t)><ctc_info (uint8_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 ) if ( 0 == ctrl )
{ {
return 0; 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); OBJ_CONSTRUCT_SUPER(msg, lam_object_t);
CREATE_OBJECT(msg->ctm_ctrl, lam_ct_ctrl_t, &lam_ctctrl_cls); msg->ctm_ctrl = OBJ_NEW(lam_ct_ctrl_t);
msg->ctm_len = 0; msg->ctm_len = 0;
msg->ctm_data = 0; msg->ctm_data = 0;
msg->ctm_should_free = 1; 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 ) if ( msg->ctm_should_free )
{ {
lam_free(msg->ctm_data); lam_free(msg->ctm_data);
} }
OBJECT_RELEASE(msg->ctm_ctrl); 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, 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; lam_ctmsg_t *msg;
CREATE_OBJECT(msg, lam_ctmsg_t, &lam_ctmsg_cls); msg = OBJ_NEW(lam_ctmsg_t);
if ( 0 == msg ) if ( 0 == msg )
{ {
return 0; return 0;
} }
STATIC_INIT(msg->ctm_ctrl, &lam_ctctrl_cls); OBJ_CONSTRUCT(&msg->ctm_ctrl, lam_ct_ctrl_t);
lam_ctc_init_with(&(msg->ctm_ctrl), sender, dest); lam_ctc_construct_with(&(msg->ctm_ctrl), sender, dest);
msg->ctm_should_free = should_free; msg->ctm_should_free = should_free;
msg->ctm_data = data; msg->ctm_data = data;
msg->ctm_len = data_len; msg->ctm_len = data_len;

Просмотреть файл

@ -14,8 +14,8 @@
* *
*/ */
extern lam_class_info_t lam_ctctrl_cls; extern lam_class_info_t lam_ct_ctrl_t_class_info;
extern lam_class_info_t lam_ctmsg_cls; extern lam_class_info_t lam_ctmsg_t_class_info;
/* /*
* *
@ -62,10 +62,10 @@ typedef struct lam_ct_ctrl
} lam_ct_ctrl_t; } lam_ct_ctrl_t;
void lam_ctc_init(lam_ct_ctrl_t *ctrl); void lam_ctc_construct(lam_ct_ctrl_t *ctrl);
void lam_ctc_destroy(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 sender,
uint32_t dest); uint32_t dest);
@ -187,8 +187,8 @@ typedef struct lam_ctmsg
} lam_ctmsg_t; } lam_ctmsg_t;
void lam_ctm_init(lam_ctmsg_t *msg); void lam_ctm_construct(lam_ctmsg_t *msg);
void lam_ctm_destroy(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, lam_ctmsg_t *lam_ctm_create_with(int is_user_msg, int routing_type,
uint32_t sender, 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; } lam_ctnode_t;
void lam_ctn_init(lam_ctnode_t *node); void lam_ctn_construct(lam_ctnode_t *node);
void lam_ctn_destroy(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) */ unsigned int hc_hsize; /* hc_hsize = log2(# nodes in network) */
} lam_hcube_t; } lam_hcube_t;
extern lam_class_info_t hcube_cls; extern lam_class_info_t hcube_t_class_info;
#endif /* LAM_CT_NODE_H */ #endif /* LAM_CT_NODE_H */

Просмотреть файл

@ -9,8 +9,12 @@
#define ARR_BLK_SZ 20 #define ARR_BLK_SZ 20
lam_class_info_t lam_array_cls = {"lam_array_t", &lam_object_cls, lam_class_info_t lam_array_t_class_info = {
(class_init_t) lam_arr_init, (class_destroy_t) lam_arr_destroy}; "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_items = NULL;
arr->arr_size = 0; arr->arr_size = 0;
arr->arr_length = 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); lam_arr_remove_all(arr);
free(arr->arr_items); 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. /* 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 ) if ( arr->arr_items )
{ {
lam_arr_remove_all(arr); 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) #if defined(c_plusplus) || defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
void lam_arr_init(lam_array_t *arr); void lam_arr_construct(lam_array_t *arr);
void lam_arr_destroy(lam_array_t *arr); void lam_arr_destruct(lam_array_t *arr);
/* initializes array with fixed length. /* 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); bool lam_arr_append_item(lam_array_t *arr, lam_object_t *item);

Просмотреть файл

@ -12,9 +12,11 @@
#define BUCKET_ALLOC_SZ 5 #define BUCKET_ALLOC_SZ 5
lam_class_info_t lam_fast_hash_cls = { lam_class_info_t lam_fast_hash_t_class_info = {
"lam_fast_hash_t", &lam_object_cls, (class_init_t)lam_fh_init, "lam_fast_hash_t",
(class_destroy_t)lam_fh_destroy 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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; hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
buckets = htbl->fh_nodes[hval]; 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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; hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
buckets = htbl->fh_nodes[hval]; 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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; hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
buckets = htbl->fh_nodes[hval]; 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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; hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
buckets = htbl->fh_nodes[hval]; 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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]; buckets = htbl->fh_nodes[hval];
if ( !buckets ) 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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; hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
err = lam_fh_find_empty_bucket(htbl, hval, &bucket_idx); 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; lam_fhnode_t *buckets;
/* ASSERT: table size is power of 2 and table /* 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; hval = lam_hash_value((const char *)key, keysize) & htbl->fh_mask;
err = lam_fh_find_empty_bucket(htbl, hval, &bucket_idx); 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 #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_nodes = 0;
htbl->fh_count = 0; htbl->fh_count = 0;
htbl->fh_size = 0; htbl->fh_size = 0;
@ -298,7 +300,7 @@ void lam_fh_init(lam_fast_hash_t *htbl)
lam_fh_resize(htbl, DEFAULT_SIZE); 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; int i;
@ -314,7 +316,7 @@ void lam_fh_destroy(lam_fast_hash_t *htbl)
free(htbl->fh_bucket_cnt); 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; 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 * This is a simple function that does not very much. It's just a test
* so that I can show what Doxygen does. * so that I can show what Doxygen does.
*/ */
void lam_fh_init(lam_fast_hash_t *htbl); void lam_fh_construct(lam_fast_hash_t *htbl);
void lam_fh_destroy(lam_fast_hash_t *htbl); void lam_fh_destruct(lam_fast_hash_t *htbl);
/* resize hash table to size */ /* resize hash table to size */
int lam_fh_resize(lam_fast_hash_t *htbl, uint32_t 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, lam_class_info_t lam_list_item_t_class_info = {
(class_init_t) lam_list_item_init, (class_destroy_t)lam_obj_destroy}; "lam_list_item_t",
lam_class_info_t lam_list_cls = {"lam_list_t", &lam_object_cls, CLASS_INFO(lam_object_t),
(class_init_t)lam_list_init, (class_destroy_t)lam_list_destroy}; (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_next = item->lam_list_prev = NULL;
item->lam_list_type = 0; 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_prev = NULL;
list->lam_list_head.lam_list_next = &list->lam_list_tail; list->lam_list_head.lam_list_next = &list->lam_list_tail;
list->lam_list_tail.lam_list_prev = &list->lam_list_head; 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 */ /* release all items in list */
lam_list_init(list); lam_list_construct(list);
SUPER_DESTROY(list, lam_list_cls.cls_parent); 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_item_t_class_info;
extern lam_class_info_t lam_list_cls; extern lam_class_info_t lam_list_t_class_info;
typedef int lam_list_type_t; typedef int lam_list_type_t;
@ -37,8 +37,8 @@ typedef struct lam_list_item
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
void lam_list_item_init(lam_list_item_t *item); void lam_list_item_construct(lam_list_item_t *item);
void lam_list_item_destroy(lam_list_item_t *item); void lam_list_item_destruct(lam_list_item_t *item);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif
@ -68,8 +68,8 @@ typedef struct lam_list
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
void lam_list_init(lam_list_t *list); void lam_list_construct(lam_list_t *list);
void lam_list_destroy(lam_list_t *list); void lam_list_destruct(lam_list_t *list);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif

Просмотреть файл

@ -2,17 +2,30 @@
* $HEADER$ * $HEADER$
*/ */
/**
* @file Implementation of lam_object_t, the base lam foundation class
*/
#include "lam/lfc/object.h" #include "lam/lfc/object.h"
lam_class_info_t lam_object_cls = { "lam_object_t", 0, lam_obj_init, lam_obj_destroy }; void lam_object_construct(lam_object_t * obj)
void lam_obj_init(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! */ /* 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$ * $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 #ifndef LAM_OBJECT_H
#define LAM_OBJECT_H #define LAM_OBJECT_H
#include <stdlib.h> #include <stdlib.h>
#include "lam/types.h" #include "lam/types.h"
#include "lam/atomic.h" #include "lam/atomic.h"
#include "lam/mem/malloc.h" #include "lam/mem/malloc.h"
/* /*
* * Class definition
* Base data structures
*
*/ */
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 *); struct lam_class_info_t {
typedef void (*class_destroy_t)(struct lam_object *); const char *cls_name;
lam_class_info_t *cls_parent;
lam_construct_t cls_construct;
lam_destruct_t cls_destruct;
};
typedef struct lam_class_info extern lam_class_info_t lam_object_t_class_info;
{
const char *cls_name;
struct lam_class_info *cls_parent;
class_init_t cls_init;
class_destroy_t cls_destroy;
} lam_class_info_t;
/* /**
* * Base object for the class system. This is special and does not
* Available Classes * follow the pattern for other classes.
*
*/ */
struct lam_object_t {
extern lam_class_info_t lam_object_cls; lam_class_info_t *obj_class_info; /**< class information */
int obj_reference_count; /**< reference count for the class */
/* };
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
*/ */
static inline lam_object_t *lam_new(size_t size,
#define SUPER(obj) (&((obj)->super)) lam_class_info_t *
class_info)
/* 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)
{ {
lam_object_t *obj = (lam_object_t *) malloc(size); lam_object_t *obj = (lam_object_t *) malloc(size);
if ( NULL != obj ) { if (NULL != obj) {
obj->obj_class = class_info; obj->obj_class_info = class_info;
obj->obj_class->cls_init(obj); obj->obj_class_info->cls_construct(obj);
} }
return 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); 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)
static inline int lam_obj_get_ref_count(lam_object_t *obj)
/**
* 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 obj->obj_refcnt; 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_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) 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) static inline void lam_obj_release(lam_object_t *obj)
{ {
if ( fetchNadd(&obj->obj_refcnt, -1) == 1 ) if (fetchNadd(&obj->obj_reference_count, -1) == 1) {
{ obj->obj_class_info->cls_destruct(obj);
obj->obj_class->cls_destroy(obj); free(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_malloc(lam_allocator_t *allocator, size_t chunk_size);
void lam_allocator_default_free(lam_allocator_t *allocator, void *base_ptr); void lam_allocator_default_free(lam_allocator_t *allocator, void *base_ptr);
lam_class_info_t allocator_cls = {"lam_allocator_t", &lam_object_cls, lam_class_info_t lam_allocator_t_class_info = {
(class_init_t)lam_allocator_init, (class_destroy_t)lam_obj_destroy}; "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_alloc_fn = lam_allocator_malloc;
allocator->alc_free_fn = lam_allocator_free; allocator->alc_free_fn = lam_allocator_free;
allocator->alc_is_shared = 0; allocator->alc_is_shared = 0;

Просмотреть файл

@ -31,9 +31,9 @@ typedef struct lam_allocator
void (*alc_free_fn)(struct lam_allocator *, void *); void (*alc_free_fn)(struct lam_allocator *, void *);
} lam_allocator_t; } 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, void *lam_alg_get_chunk(size_t chunk_size, int is_shared,
int mem_protect); int mem_protect);

Просмотреть файл

@ -5,25 +5,25 @@
#include "lam/mem/free_list.h" #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_free_list_t",
&lam_list_cls, CLASS_INFO(lam_list_t),
(class_init_t)lam_free_list_init, (lam_construct_t)lam_free_list_construct,
(class_destroy_t)lam_free_list_destroy (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, lam_free_list_t *flist,
size_t elem_size, size_t elem_size,
lam_class_info_t* elem_class, 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++) { for(i=0; i<num_elements; i++) {
lam_list_item_t* item = (lam_list_item_t*)ptr; lam_list_item_t* item = (lam_list_item_t*)ptr;
if (NULL != flist->fl_elem_class) if (NULL != flist->fl_elem_class) {
STATIC_INIT((*item), 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); lam_list_append(&flist->super, item);
ptr += flist->fl_elem_size; ptr += flist->fl_elem_size;
} }

Просмотреть файл

@ -11,7 +11,7 @@
#include "lam/mem/seg_list.h" #include "lam/mem/seg_list.h"
#include "lam/mem/mem_pool.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 struct lam_free_list_t
@ -28,12 +28,12 @@ struct lam_free_list_t
typedef struct lam_free_list_t 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_construct(lam_free_list_t *flist);
void lam_free_list_destroy(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_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, lam_free_list_t *flist,
size_t element_size, size_t element_size,
lam_class_info_t* element_class, 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 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, size_t page_size, long min_pages_per_list,
long default_min_pages_per_list, long default_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); 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, lam_class_info_t lam_free_lists_t_class_info = {
(class_init_t)lam_free_lists_init, (class_destroy_t)lam_free_lists_destroy}; "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); OBJ_CONSTRUCT_SUPER(flist, lam_object_t);
lam_mutex_init(&flist->fl_lock); lam_mutex_construct(&flist->fl_lock);
flist->fl_pool = NULL; flist->fl_pool = NULL;
flist->fl_elt_cls = NULL; flist->fl_elt_cls = NULL;
flist->fl_description = 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; int i;
@ -93,11 +97,11 @@ void lam_free_lists_destroy(lam_free_lists_t *flist)
free(flist->fl_chunks_returned); free(flist->fl_chunks_returned);
#endif #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, lam_free_lists_t *flist,
int nlists, int nlists,
int pages_per_list, int pages_per_list,
@ -113,7 +117,7 @@ int lam_free_lists_init_with(
bool enforce_affinity, bool enforce_affinity,
lam_mem_pool_t *mem_pool) 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 max_mem_in_pool;
size_t initial_mem_per_list; size_t initial_mem_per_list;
long max_mem_per_list; long max_mem_per_list;
@ -133,7 +137,7 @@ int lam_free_lists_init_with(
{ {
/* instantiate memory pool */ /* instantiate memory pool */
max_mem_in_pool = max_pages_per_list * page_size; 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, flist,
nlists, nlists,
pages_per_list, pages_per_list,
@ -205,7 +209,7 @@ int lam_free_lists_init_with(
lam_abort(1, "Error: Out of memory"); 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], lam_sgl_set_min_bytes_pushed(flist->fl_free_lists[list],
initial_mem_per_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, int nlists, long pages_per_list, ssize_t chunk_size,
size_t page_size, long min_pages_per_list, size_t page_size, long min_pages_per_list,
long default_min_pages_per_list, long default_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, (lam_mem_pool_t *)lam_fmp_get_mem_segment(&lam_shmem_pools,
to_alloc, to_alloc,
CACHE_ALIGNMENT, 0); CACHE_ALIGNMENT, 0);
if ( flist->fl_pool ) if ( flist->fl_pool ) {
STATIC_INIT(flist->fl_pool, &shmem_pool_cls); OBJ_CONSTRUCT(&flist->fl_pool, shmem_pool_t);
}
} else { } else {
/* process private memory allocation */ /* 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, flist->fl_pool,
mem_in_pool, mem_in_pool,
max_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; current_loc = (char *) ptr;
for (desc = 0; desc < flist->fl_elt_per_chunk; desc++) 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; 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; 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_construct(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);
/* lam_frl_init must have been called prior to calling this function */ /* lam_frl_construct must have been called prior to calling this function */
int lam_free_lists_init_with(lam_free_lists_t *flist, int lam_free_lists_construct_with(lam_free_lists_t *flist,
int nlists, int nlists,
int pages_per_list, int pages_per_list,
size_t chunk_size, size_t chunk_size,

Просмотреть файл

@ -18,8 +18,8 @@ int lam_setup_per_proc_shmem_pools(int npools)
ssize_t min_alloc_size = 4 * getpagesize(); ssize_t min_alloc_size = 4 * getpagesize();
int n_array_elts_add = 10; int n_array_elts_add = 10;
STATIC_INIT(lam_per_proc_shmem_pools, &fixed_mem_pool_cls); OBJ_CONSTRUCT(&lam_per_proc_shmem_pools, lam_fixed_mpool_t);
lam_fmp_init_with(&lam_per_proc_shmem_pools, lam_fmp_construct_with(&lam_per_proc_shmem_pools,
initial_alloc, min_alloc_size, initial_alloc, min_alloc_size,
npools, n_array_elts_add, 1); npools, n_array_elts_add, 1);

Просмотреть файл

@ -16,43 +16,51 @@
#include "lam/util/output.h" #include "lam/util/output.h"
#include "lam/os/numa.h" #include "lam/os/numa.h"
lam_class_info_t mem_pool_cls = {"lam_mem_pool_t", &lam_object_cls, lam_class_info_t lam_mem_pool_t_class_info = {
(class_init_t)lam_mp_init, (class_destroy_t)lam_mp_destroy}; "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 */ /* process-shared mem pool class */
lam_class_info_t shmem_pool_cls = {"shmem_pool_t", &lam_object_cls, lam_class_info_t shmem_pool_t_class_info = {
(class_init_t)lam_mp_shared_init, (class_destroy_t)lam_mp_destroy}; "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); pool->mp_private_alloc = OBJ_NEW(lam_allocator_t);
lam_mutex_init(&(pool->mp_lock)); lam_mutex_construct(&(pool->mp_lock));
pool->mp_dev_alloc = NULL; 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); pool->mp_private_alloc = OBJ_NEW(lam_allocator_t);
lam_mutex_init(&(pool->mp_lock)); lam_mutex_construct(&(pool->mp_lock));
lam_allocator_set_is_shared(pool->mp_private_alloc, 1); lam_allocator_set_is_shared(pool->mp_private_alloc, 1);
lam_allocator_set_mem_prot(pool->mp_private_alloc, MMAP_SHARED_PROT); lam_allocator_set_mem_prot(pool->mp_private_alloc, MMAP_SHARED_PROT);
pool->mp_dev_alloc = NULL; 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 ) if ( pool->mp_dev_alloc )
OBJ_RELEASE(pool->mp_dev_alloc); OBJ_RELEASE(pool->mp_dev_alloc);
OBJ_RELEASE(pool->mp_private_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 max_len,
uint64_t chunk_size, size_t page_size) 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, lam_class_info_t lam_fixed_mpool_t_class_info = {
(class_init_t)lam_fmp_init, (class_destroy_t)lam_fmp_destroy}; "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_is_shared(pool->fmp_private_alloc, 1);
lam_allocator_set_mem_prot(pool->fmp_private_alloc, MMAP_SHARED_PROT); 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; 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; int i;
@ -307,12 +319,12 @@ void lam_fmp_destroy(lam_fixed_mpool_t *pool)
if ( pool->fmp_n_segs_in_array ) if ( pool->fmp_n_segs_in_array )
free(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, ssize_t min_allocation_size,
int n_pools, int n_array_elements_to_add, int apply_mem_affinity) int n_pools, int n_array_elements_to_add, int apply_mem_affinity)
{ {

Просмотреть файл

@ -18,10 +18,10 @@
/* /*
To create a process-private pool, use 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 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 typedef struct lam_chunk_desc
@ -46,16 +46,16 @@ typedef struct lam_mem_pool
} lam_mem_pool_t; } lam_mem_pool_t;
/* process-private mem pool class */ /* 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 */ /* 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_construct(lam_mem_pool_t *pool);
void lam_mp_shared_init(lam_mem_pool_t *pool); void lam_mp_shared_construct(lam_mem_pool_t *pool);
void lam_mp_destroy(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 max_len,
uint64_t chunk_size, size_t pg_size); uint64_t chunk_size, size_t pg_size);
@ -121,11 +121,11 @@ typedef struct lam_fixed_mpool
int fmp_apply_affinity; int fmp_apply_affinity;
} lam_fixed_mpool_t; } 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_construct(lam_fixed_mpool_t *pool);
void lam_fmp_destroy(lam_fixed_mpool_t *pool); void lam_fmp_destruct(lam_fixed_mpool_t *pool);
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, ssize_t min_allocation_size,
int n_pools, int n_array_elements_to_add, int apply_mem_affinity); int n_pools, int n_array_elements_to_add, int apply_mem_affinity);
void *lam_fmp_get_mem_segment(lam_fixed_mpool_t *pool, void *lam_fmp_get_mem_segment(lam_fixed_mpool_t *pool,

Просмотреть файл

@ -8,14 +8,18 @@
/* /*
* Public variable * Public variable
*/ */
lam_class_info_t lam_seg_list_cls = {"lam_seg_list_t", &lam_object_cls, lam_class_info_t lam_seg_list_t_class_info = {
(class_init_t)lam_sgl_init, (class_destroy_t)lam_sgl_destroy}; "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); OBJ_CONSTRUCT_SUPER(slist, lam_object_t);
STATIC_INIT(slist->sgl_list, &lam_list_cls); OBJ_CONSTRUCT(&slist->sgl_list, lam_list_t);
lam_mutex_init(&slist->sgl_lock); lam_mutex_construct(&slist->sgl_lock);
slist->sgl_min_bytes_pushed = 0; slist->sgl_min_bytes_pushed = 0;
slist->sgl_max_bytes_pushed = 0; slist->sgl_max_bytes_pushed = 0;
slist->sgl_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; 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)); lam_list_destruct(&(slist->sgl_list));
SUPER_DESTROY(slist, lam_seg_list_cls.cls_parent); 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; 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_construct(lam_seg_list_t *slist);
void lam_sgl_destroy(lam_seg_list_t *slist); void lam_sgl_destruct(lam_seg_list_t *slist);
void lam_sgl_append_elt_chunk( void lam_sgl_append_elt_chunk(
lam_seg_list_t *slist, lam_seg_list_t *slist,
void *chunk, void *chunk,

Просмотреть файл

@ -8,8 +8,8 @@
#include "lam/os/atomic.h" #include "lam/os/atomic.h"
typedef lam_lock_data_t lam_mutex_t; typedef lam_lock_data_t lam_mutex_t;
#define lam_mutex_init(m) spinunlock(m) #define lam_mutex_construct(m) spinunlock(m)
#define lam_mutex_destroy(m) #define lam_mutex_destruct(m)
#define lam_mutex_lock(m) spinlock(m) #define lam_mutex_lock(m) spinlock(m)
#define lam_mutex_trylock(m) spintrylock(m) #define lam_mutex_trylock(m) spintrylock(m)
#define lam_mutex_unlock(m) spinunlock(m) #define lam_mutex_unlock(m) spinunlock(m)

Просмотреть файл

@ -22,7 +22,7 @@ struct lam_mutex_t {
struct lam_mutex_t 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_spinlock = 0;
m->mutex_waiting = 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); 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; } 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); lam_thread_t *lam_thr_create(lam_object_t *arg);
#endif /* LAM_THREAD_H */ #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 only thread that has this instance), there's no need to lock it
right now. */ right now. */
lam_mutex_init(&cmd->lcl_mutex); lam_mutex_construct(&cmd->lcl_mutex);
/* Initialize the lists */ /* Initialize the lists */
lam_list_init(&cmd->lcl_options); lam_list_construct(&cmd->lcl_options);
lam_list_init(&cmd->lcl_params); lam_list_construct(&cmd->lcl_params);
/* Initialize the argc/argv pairs */ /* 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)); option = malloc(sizeof(cmd_line_option_t));
if (NULL == option) if (NULL == option)
return LAM_ERR_OUT_OF_RESOURCE; 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; option->clo_short_name = short_name;
if (NULL != long_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; return LAM_ERR_OUT_OF_RESOURCE;
} }
item = (lam_list_item_t *) param; 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_arg = cmd->lcl_argv[i];
param->clp_option = option; param->clp_option = option;
param->clp_argc = 0; param->clp_argc = 0;

Просмотреть файл

@ -66,15 +66,15 @@ static int lam_ifinit(void)
close(sd); close(sd);
return LAM_ERROR; 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; ) { for(ptr = buff; ptr < buff + ifconf.ifc_len; ) {
struct ifreq* ifr = (struct ifreq*)ptr; struct ifreq* ifr = (struct ifreq*)ptr;
lam_if_t intf; lam_if_t intf;
lam_if_t *intf_ptr; 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__) #if defined(__APPLE__)
ptr += (sizeof(ifr->ifr_name) + ptr += (sizeof(ifr->ifr_name) +

Просмотреть файл

@ -115,7 +115,7 @@ bool lam_output_init(void)
/* Initialize the mutex that protects the output */ /* Initialize the mutex that protects the output */
lam_mutex_init(&mutex); lam_mutex_construct(&mutex);
initialized = true; initialized = true;
/* Open the default verbose stream */ /* Open the default verbose stream */

Просмотреть файл

@ -23,30 +23,30 @@ const int LAM_REACTOR_NOTIFY_ALL = 7;
#define MAX_DESCRIPTOR_POOL_SIZE 256 #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_reactor_t",
&lam_object_cls, CLASS_INFO(lam_object_t),
(class_init_t)lam_reactor_init, (lam_construct_t)lam_reactor_construct,
(class_destroy_t)lam_reactor_destroy (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 = {
void lam_reactor_descriptor_init(lam_reactor_descriptor_t* rd) "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_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)) { if(lam_list_get_size(&r->r_free)) {
descriptor = (lam_reactor_descriptor_t*)lam_list_remove_first(&r->r_free); descriptor = (lam_reactor_descriptor_t*)lam_list_remove_first(&r->r_free);
} else { } else {
descriptor = OBJ_CREATE(lam_reactor_descriptor_t, &lam_reactor_descriptor_cls); descriptor = OBJ_NEW(lam_reactor_descriptor_t);
} }
if (NULL == descriptor) { if (NULL == descriptor) {
return 0; 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_mutex_construct(&r->r_mutex);
lam_list_init(&r->r_active); lam_list_construct(&r->r_active);
lam_list_init(&r->r_free); lam_list_construct(&r->r_free);
lam_list_init(&r->r_pending); lam_list_construct(&r->r_pending);
lam_fh_init(&r->r_hash); lam_fh_construct(&r->r_hash);
lam_fh_resize(&r->r_hash, 1024); lam_fh_resize(&r->r_hash, 1024);
r->r_max = -1; 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_destruct(&r->r_active);
lam_list_destroy(&r->r_free); lam_list_destruct(&r->r_free);
lam_list_destroy(&r->r_pending); lam_list_destruct(&r->r_pending);
lam_fh_destroy(&r->r_hash); lam_fh_destruct(&r->r_hash);
SUPER_DESTROY(r, &lam_object_cls); 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) { if(lam_list_get_size(&r->r_free) < MAX_DESCRIPTOR_POOL_SIZE) {
lam_list_append(&r->r_free, &descriptor->super); lam_list_append(&r->r_free, &descriptor->super);
} else { } else {
lam_reactor_descriptor_destroy(descriptor); lam_reactor_descriptor_destruct(descriptor);
free(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) { if(lam_list_get_size(&r->r_free) < MAX_DESCRIPTOR_POOL_SIZE) {
lam_list_append(&r->r_free, &descriptor->super); lam_list_append(&r->r_free, &descriptor->super);
} else { } else {
lam_reactor_descriptor_destroy(descriptor); lam_reactor_descriptor_destruct(descriptor);
free(descriptor); free(descriptor);
} }
} else { } 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_SEND;
extern const int LAM_REACTOR_NOTIFY_EXCEPT; 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; typedef struct lam_reactor_descriptor_t lam_reactor_descriptor_t;
void lam_reactor_descriptor_init(lam_reactor_descriptor_t*); void lam_reactor_descriptor_construct(lam_reactor_descriptor_t*);
void lam_reactor_descriptor_destroy(lam_reactor_descriptor_t*); void lam_reactor_descriptor_destruct(lam_reactor_descriptor_t*);
struct lam_reactor_t { struct lam_reactor_t {
@ -73,8 +73,8 @@ struct lam_reactor_t {
typedef struct lam_reactor_t lam_reactor_t; typedef struct lam_reactor_t lam_reactor_t;
void lam_reactor_init(lam_reactor_t*); void lam_reactor_construct(lam_reactor_t*);
void lam_reactor_destroy(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_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); int lam_reactor_remove(lam_reactor_t*, int sd, int flags);

Просмотреть файл

@ -78,7 +78,7 @@ extern "C" {
/* mca_base_module_register.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, int mca_base_module_registry_retain(char *type, lt_dlhandle module_handle,
const mca_base_module_t *module_struct); const mca_base_module_t *module_struct);
int mca_base_module_registry_link(const char *src_type, 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 */ /* 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) { for (i = 0; NULL != static_modules[i]; ++i) {
mli = malloc(sizeof(mca_base_module_list_item_t)); mli = malloc(sizeof(mca_base_module_list_item_t));
if (NULL == mli) { if (NULL == mli) {
return LAM_ERR_OUT_OF_RESOURCE; 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]; mli->mli_module = static_modules[i];
lam_list_append(found_modules, (lam_list_item_t *) mli); 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 make a master array of all the matching filenames that we
find. */ find. */
lam_list_init(&found_files); lam_list_construct(&found_files);
dir = path_to_use; dir = path_to_use;
do { do {
end = strchr(dir, ':'); 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 */ /* JMS This list memory management may change */
#if 0 #if 0
lam_list_destroy(&found_files); lam_list_destruct(&found_files);
#endif #endif
free(path_to_use); free(path_to_use);
} }
@ -269,7 +269,7 @@ static int save_filename(const char *filename, lt_ptr data)
if (NULL == module_file) { if (NULL == module_file) {
return LAM_ERR_OUT_OF_RESOURCE; 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->type, params->type);
strcpy(module_file->name, basename + prefix_len); strcpy(module_file->name, basename + prefix_len);
strcpy(module_file->basename, basename); 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 them. If we can't load them, then this module must also fail to
load. */ load. */
lam_list_init(&dependencies); lam_list_construct(&dependencies);
if (0 != check_laminfo(target_file, &dependencies, found_modules)) { if (0 != check_laminfo(target_file, &dependencies, found_modules)) {
target_file->status = FAILED_TO_LOAD; target_file->status = FAILED_TO_LOAD;
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
@ -372,7 +372,7 @@ static int open_module(module_file_item_t *target_file,
free_dependency_list(&dependencies); free_dependency_list(&dependencies);
return LAM_ERR_OUT_OF_RESOURCE; 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); module_struct = lt_dlsym(module_handle, struct_name);
if (NULL == module_struct) { if (NULL == module_struct) {
@ -408,7 +408,7 @@ static int open_module(module_file_item_t *target_file,
ditem->di_module_file_item->name); ditem->di_module_file_item->name);
free(ditem); free(ditem);
} }
lam_list_destroy(&dependencies); lam_list_destruct(&dependencies);
lam_output_verbose(0, 40, " opened dynamic %s MCA module \"%s\"", lam_output_verbose(0, 40, " opened dynamic %s MCA module \"%s\"",
target_file->type, target_file->name, NULL); 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; return LAM_ERR_OUT_OF_RESOURCE;
} }
cur = (lam_list_item_t *) ditem; cur = (lam_list_item_t *) ditem;
lam_list_item_init(cur); lam_list_item_construct(cur);
lam_list_append(dependencies, cur); lam_list_append(dependencies, cur);
/* All done -- all depenencies satisfied */ /* All done -- all depenencies satisfied */
@ -647,5 +647,5 @@ static void free_dependency_list(lam_list_t *dependencies)
item = lam_list_remove_first(dependencies)) { item = lam_list_remove_first(dependencies)) {
free(item); 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 * Initialize the registry
*/ */
int mca_base_module_registry_init(void) int mca_base_module_registry_construct(void)
{ {
/* Setup internal structures */ /* Setup internal structures */
@ -69,7 +69,7 @@ int mca_base_module_registry_init(void)
if (lt_dlinit() != 0) if (lt_dlinit() != 0)
return LAM_ERR_OUT_OF_RESOURCE; return LAM_ERR_OUT_OF_RESOURCE;
lam_list_init(&registry); lam_list_construct(&registry);
initialized = true; initialized = true;
} }
@ -96,12 +96,12 @@ int mca_base_module_registry_retain(char *type, lt_dlhandle module_handle,
/* Initialize the registry item */ /* 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); strcpy(ri->ri_type, type);
ri->ri_dlhandle = module_handle; ri->ri_dlhandle = module_handle;
ri->ri_module_struct = module_struct; ri->ri_module_struct = module_struct;
ri->ri_refcount = 1; ri->ri_refcount = 1;
lam_list_init(&ri->ri_dependencies); lam_list_construct(&ri->ri_dependencies);
/* Append the new item to the registry */ /* 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 */ /* 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; di->di_registry_entry = depend;
/* Add it to the dependency list on the source registry entry */ /* 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 pointer is no longer valid because it has [potentially] been
unloaded from memory. So don't try to use it. :-) */ 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(&registry, (lam_list_item_t *) ri); lam_list_remove_item(&registry, (lam_list_item_t *) ri);
free(ri); free(ri);
} }

Просмотреть файл

@ -172,7 +172,7 @@ static int open_modules(const char *type_name, int output_id,
/* Traverse the list of found modules */ /* Traverse the list of found modules */
lam_list_init(modules_available); lam_list_construct(modules_available);
for (item = lam_list_get_first(modules_found); for (item = lam_list_get_first(modules_found);
lam_list_get_end(modules_found) != item; lam_list_get_end(modules_found) != item;
item = lam_list_get_next(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) { if (NULL == mli) {
return LAM_ERROR; return LAM_ERROR;
} }
lam_list_item_init(&mli->super); lam_list_item_construct(&mli->super);
mli->mli_module = module; mli->mli_module = module;
lam_list_append(modules_available, (lam_list_item_t *) mli); lam_list_append(modules_available, (lam_list_item_t *) mli);
} }

Просмотреть файл

@ -64,7 +64,7 @@ int mca_base_open(void)
/* Open up the module registry */ /* 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 */ /* Initialize the array if it has never been initialized */
if (!initialized) { if (!initialized) {
lam_arr_init(&mca_base_params); lam_arr_construct(&mca_base_params);
initialized = true; initialized = true;
} }
@ -290,7 +290,7 @@ static int param_register(const char *type_name, const char *module_name,
if (NULL == param) { if (NULL == param) {
return LAM_ERR_OUT_OF_RESOURCE; 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_type = type;
param->mbp_keyval = -1; param->mbp_keyval = -1;

Просмотреть файл

@ -259,7 +259,7 @@ int mca_base_param_finalize(void)
for (i = 0; i < size; ++i) for (i = 0; i < size; ++i)
param_free(array[i]); param_free(array[i]);
lam_arr_destroy(&mca_base_params); lam_arr_destruct(&mca_base_params);
initialized = false; 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 */ /* Initialize the array if it has never been initialized */
if (!initialized) { if (!initialized) {
lam_arr_init(&mca_base_params); lam_arr_construct(&mca_base_params);
initialized = true; initialized = true;
} }

Просмотреть файл

@ -53,7 +53,7 @@ int mca_mpi_init_select_modules(int requested,
allow_multi_user_threads |= user_threads; allow_multi_user_threads |= user_threads;
have_hidden_threads |= hidden_threads; have_hidden_threads |= hidden_threads;
lam_list_init(&colls); lam_list_construct(&colls);
if (LAM_SUCCESS != mca_coll_base_select(&colls, &user_threads, if (LAM_SUCCESS != mca_coll_base_select(&colls, &user_threads,
&hidden_threads)) { &hidden_threads)) {
return LAM_ERROR; return LAM_ERROR;

Просмотреть файл

@ -5,20 +5,20 @@
#include "mca/mpi/pml/base/pml_base_request.h" #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", "mca_pml_base_request_t",
&lam_request_cls, CLASS_INFO(lam_request_t),
(class_init_t) mca_pml_base_request_init, (lam_construct_t) mca_pml_base_request_construct,
(class_destroy_t) mca_pml_base_request_destroy (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/datatype/datatype.h"
#include "mpi/communicator/communicator.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 */ /* MPI request status */
typedef enum { typedef enum {
@ -58,8 +58,8 @@ typedef struct {
} mca_pml_base_request_t; } mca_pml_base_request_t;
void mca_pml_base_request_init(mca_pml_base_request_t*); void mca_pml_base_request_construct(mca_pml_base_request_t*);
void mca_pml_base_request_destroy(mca_pml_base_request_t*); void mca_pml_base_request_destruct(mca_pml_base_request_t*);
#endif #endif

Просмотреть файл

@ -47,7 +47,7 @@ int mca_pml_base_select(mca_pml_t *selected, bool *allow_multi_user_threads,
best_priority = -1; best_priority = -1;
best_module = NULL; best_module = NULL;
lam_list_init(&opened); lam_list_construct(&opened);
for (item = lam_list_get_first(&mca_pml_base_modules_available); for (item = lam_list_get_first(&mca_pml_base_modules_available);
lam_list_get_end(&mca_pml_base_modules_available) != item; lam_list_get_end(&mca_pml_base_modules_available) != item;
item = lam_list_get_next(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) { if (NULL == om) {
return LAM_ERR_OUT_OF_RESOURCE; 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; om->om_module = module;
lam_list_append(&opened, (lam_list_item_t*) om); lam_list_append(&opened, (lam_list_item_t*) om);
} }

Просмотреть файл

@ -6,17 +6,17 @@
#include "pml_ptl_array.h" #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", "mca_ptl_array_t",
&lam_object_cls, CLASS_INFO(lam_object_t),
(class_init_t) mca_ptl_array_init, (lam_construct_t) mca_ptl_array_construct,
(class_destroy_t) mca_ptl_array_destroy (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_procs = 0;
array->ptl_size = 0; array->ptl_size = 0;
array->ptl_index = 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); 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 "lam/util/output.h"
#include "mca/mpi/ptl/ptl.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 { struct mca_ptl_proc_t {
double ptl_weight; /* PTL weight for scheduling */ 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; typedef struct mca_ptl_array_t mca_ptl_array_t;
void mca_ptl_array_init(mca_ptl_array_t*); void mca_ptl_array_construct(mca_ptl_array_t*);
void mca_ptl_array_destroy(mca_ptl_array_t*); void mca_ptl_array_destruct(mca_ptl_array_t*);
int mca_ptl_array_reserve(mca_ptl_array_t*, size_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) 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) int mca_pml_teg_add_comm(lam_communicator_t* comm)
{ {
/* allocate pml specific comm data */ /* 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) { if (NULL == pml_comm) {
return LAM_ERR_OUT_OF_RESOURCE; 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 */ /* do any required cleanup */
mca_pml_teg_proc_destroy(proc_pml); mca_pml_teg_proc_destruct(proc_pml);
free(proc_pml); free(proc_pml);
proc->proc_pml = 0; proc->proc_pml = 0;
} }
return LAM_SUCCESS; return LAM_SUCCESS;
} }
int mca_pml_teg_module_fini(void) int mca_pml_teg_module_destruct(void)
{ {
/* FIX */ /* FIX */
return LAM_SUCCESS; return LAM_SUCCESS;

Просмотреть файл

@ -58,8 +58,8 @@ static inline int mca_pml_teg_param_register_int(
int mca_pml_teg_module_open(void) int mca_pml_teg_module_open(void)
{ {
STATIC_INIT(mca_pml_teg.teg_recv_requests, &lam_free_list_cls); OBJ_CONSTRUCT(&mca_pml_teg.teg_recv_requests, lam_free_list_t);
STATIC_INIT(mca_pml_teg.teg_procs, &lam_list_cls); OBJ_CONSTRUCT(&mca_pml_teg.teg_procs, lam_list_t);
mca_pml_teg.teg_free_list_num = mca_pml_teg.teg_free_list_num =
mca_pml_teg_param_register_int("free_list_num", 256); mca_pml_teg_param_register_int("free_list_num", 256);
mca_pml_teg.teg_free_list_max = 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); free(mca_pml_teg.teg_ptl_modules);
if(NULL != mca_pml_teg.teg_ptls) if(NULL != mca_pml_teg.teg_ptls)
free(mca_pml_teg.teg_ptls); free(mca_pml_teg.teg_ptls);
STATIC_DESTROY(mca_pml_teg.teg_recv_requests); OBJ_DESTRUCT(&mca_pml_teg.teg_recv_requests);
STATIC_DESTROY(mca_pml_teg.teg_procs); OBJ_DESTRUCT(&mca_pml_teg.teg_procs);
return LAM_SUCCESS; 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_ptls = NULL;
mca_pml_teg.teg_num_ptls = 0; mca_pml_teg.teg_num_ptls = 0;
lam_free_list_init_with( lam_free_list_construct_with(
&mca_pml_teg.teg_recv_requests, &mca_pml_teg.teg_recv_requests,
sizeof(mca_ptl_base_recv_request_t), 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_num,
mca_pml_teg.teg_free_list_max, mca_pml_teg.teg_free_list_max,
mca_pml_teg.teg_free_list_inc, mca_pml_teg.teg_free_list_inc,
NULL); NULL);
lam_mutex_init(&mca_pml_teg.teg_lock); lam_mutex_construct(&mca_pml_teg.teg_lock);
mca_pml_teg.teg_recv_sequence = 0; mca_pml_teg.teg_recv_sequence = 0;
return &mca_pml_teg.super; return &mca_pml_teg.super;
} }

Просмотреть файл

@ -7,19 +7,19 @@
#include "pml_teg_proc.h" #include "pml_teg_proc.h"
#include "pml_ptl_array.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", "mca_pml_teg_proc_t",
&lam_list_item_cls, CLASS_INFO(lam_list_item_t),
(class_init_t) mca_pml_teg_proc_init, (lam_construct_t) mca_pml_teg_proc_construct,
(class_destroy_t) mca_pml_teg_proc_destroy (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); OBJ_CONSTRUCT_SUPER(proc, lam_list_item_t);
mca_ptl_array_init(&proc->proc_ptl_first); mca_ptl_array_construct(&proc->proc_ptl_first);
mca_ptl_array_init(&proc->proc_ptl_next); mca_ptl_array_construct(&proc->proc_ptl_next);
THREAD_LOCK(&mca_pml_teg.teg_lock); THREAD_LOCK(&mca_pml_teg.teg_lock);
lam_list_append(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc); 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); THREAD_LOCK(&mca_pml_teg.teg_lock);
lam_list_remove_item(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc); lam_list_remove_item(&mca_pml_teg.teg_procs, (lam_list_item_t*)proc);
THREAD_UNLOCK(&mca_pml_teg.teg_lock); 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 "mpi/proc/proc.h"
#include "pml_ptl_array.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 * 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; 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_construct(mca_pml_proc_t*);
void mca_pml_teg_proc_destroy(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) 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" #include "ptl_base_comm.h"
static void mca_pml_ptl_comm_init(mca_pml_comm_t* comm); static void mca_pml_ptl_comm_construct(mca_pml_comm_t* comm);
static void mca_pml_ptl_comm_destroy(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", "mca_pml_comm_t",
&lam_object_cls, CLASS_INFO(lam_object_t),
(class_init_t)mca_pml_ptl_comm_init, (lam_construct_t)mca_pml_ptl_comm_construct,
(class_destroy_t)mca_pml_ptl_comm_destroy (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); OBJ_CONSTRUCT_SUPER(comm, lam_object_t);
STATIC_INIT(comm->c_wild_receives, &lam_list_cls); OBJ_CONSTRUCT(&comm->c_wild_receives, lam_list_t);
lam_mutex_init(&comm->c_wild_lock); 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_msg_seq);
free(comm->c_next_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_unexpected_frags_lock);
free(comm->c_frags_cant_match); free(comm->c_frags_cant_match);
free(comm->c_specific_receives); free(comm->c_specific_receives);
lam_list_destroy(&comm->c_wild_receives); lam_list_destruct(&comm->c_wild_receives);
SUPER_DESTROY(comm, &lam_object_cls); 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) if(NULL == comm->c_matching_lock)
return LAM_ERR_OUT_OF_RESOURCE; return LAM_ERR_OUT_OF_RESOURCE;
for(i=0; i<size; i++) 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 */ /* unexpected fragments queues */
comm->c_unexpected_frags = malloc(sizeof(lam_list_t) * size); comm->c_unexpected_frags = malloc(sizeof(lam_list_t) * size);
if(NULL == comm->c_unexpected_frags) if(NULL == comm->c_unexpected_frags)
return LAM_ERR_OUT_OF_RESOURCE; return LAM_ERR_OUT_OF_RESOURCE;
for(i=0; i<size; i++) 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 */ /* these locks are needed to avoid a probe interfering with a match */
comm->c_unexpected_frags_lock = malloc(sizeof(lam_mutex_t) * size); comm->c_unexpected_frags_lock = malloc(sizeof(lam_mutex_t) * size);
if(NULL == comm->c_unexpected_frags_lock) if(NULL == comm->c_unexpected_frags_lock)
return LAM_ERR_OUT_OF_RESOURCE; return LAM_ERR_OUT_OF_RESOURCE;
for(i=0; i<size; i++) 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 */ /* out-of-order fragments queues */
comm->c_frags_cant_match = malloc(sizeof(lam_list_t) * size); comm->c_frags_cant_match = malloc(sizeof(lam_list_t) * size);
if(NULL == comm->c_frags_cant_match) if(NULL == comm->c_frags_cant_match)
return LAM_ERR_OUT_OF_RESOURCE; return LAM_ERR_OUT_OF_RESOURCE;
for(i=0; i<size; i++) 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 */ /* queues of unmatched specific (source process specified) receives */
comm->c_specific_receives = malloc(sizeof(lam_list_t) * size); comm->c_specific_receives = malloc(sizeof(lam_list_t) * size);
if(NULL == comm->c_specific_receives) if(NULL == comm->c_specific_receives)
return LAM_ERR_OUT_OF_RESOURCE; return LAM_ERR_OUT_OF_RESOURCE;
for(i=0; i<size; i++) 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; return LAM_SUCCESS;
} }

Просмотреть файл

@ -10,7 +10,7 @@
* specific to the PML. * 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 { struct mca_pml_comm_t {
lam_object_t super; lam_object_t super;

Просмотреть файл

@ -6,24 +6,24 @@
#include "lam/lfc/list.h" #include "lam/lfc/list.h"
#include "mca/mpi/ptl/base/ptl_base_fragment.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_construct(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_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", "mca_ptl_base_frag_t",
&lam_list_item_cls, CLASS_INFO(lam_list_item_t),
(class_init_t) mca_ptl_base_frag_init, (lam_construct_t) mca_ptl_base_frag_construct,
(class_destroy_t) mca_ptl_base_frag_destroy (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" #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 { struct mca_ptl_base_frag_t {
lam_list_item_t super; 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)) 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. */ /* 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 iterate over it (even if it's empty, as in the case of
laminfo) */ laminfo) */
lam_list_init(&mca_ptl_base_modules_initialized); lam_list_construct(&mca_ptl_base_modules_initialized);
/* All done */ /* All done */

Просмотреть файл

@ -7,25 +7,25 @@
#include "mca/mpi/ptl/base/ptl_base_recvfrag.h" #include "mca/mpi/ptl/base/ptl_base_recvfrag.h"
#include "mca/mpi/ptl/base/ptl_base_match.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_construct(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_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_recv_frag_t",
&mca_ptl_base_frag_cls, CLASS_INFO(mca_ptl_base_frag_t),
(class_init_t) mca_ptl_base_recv_frag_init, (lam_construct_t) mca_ptl_base_recv_frag_construct,
(class_destroy_t) mca_ptl_base_recv_frag_destroy (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_recvreq.h"
#include "mca/mpi/ptl/base/ptl_base_match.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 { struct mca_ptl_base_recv_frag_t {

Просмотреть файл

@ -9,28 +9,28 @@
#include "mca/mpi/ptl/base/ptl_base_recvfrag.h" #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_construct(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_destruct(mca_ptl_base_recv_request_t*);
static bool mca_ptl_base_recv_request_match_specific_proc(mca_ptl_base_recv_request_t*, int); 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_ptl_base_recv_request_t",
&mca_pml_base_request_cls, CLASS_INFO(mca_pml_base_request_t),
(class_init_t) mca_ptl_base_recv_request_init, (lam_construct_t) mca_ptl_base_recv_request_construct,
(class_destroy_t) mca_ptl_base_recv_request_destroy (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/ptl/ptl.h"
#include "mca/mpi/pml/base/pml_base_request.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; struct mca_ptl_base_recv_frag_t;

Просмотреть файл

@ -76,7 +76,7 @@ int mca_ptl_base_select(bool *allow_multi_user_threads,
if (NULL == sm) { if (NULL == sm) {
return LAM_ERR_OUT_OF_RESOURCE; 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_module = module;
sm->pbsm_actions = actions[i]; sm->pbsm_actions = actions[i];
lam_list_append(&mca_ptl_base_modules_initialized, lam_list_append(&mca_ptl_base_modules_initialized,

Просмотреть файл

@ -4,25 +4,25 @@
#include "mca/mpi/ptl/base/ptl_base_sendfrag.h" #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_construct(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_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_send_frag_t",
&mca_ptl_base_frag_cls, CLASS_INFO(mca_ptl_base_frag_t),
(class_init_t) mca_ptl_base_send_frag_init, (lam_construct_t) mca_ptl_base_send_frag_construct,
(class_destroy_t) mca_ptl_base_send_frag_destroy (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/ptl.h"
#include "mca/mpi/ptl/base/ptl_base_fragment.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 { struct mca_ptl_base_send_frag_t {

Просмотреть файл

@ -3,27 +3,27 @@
*/ */
#include "mca/mpi/ptl/base/ptl_base_sendreq.h" #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_construct(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_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_ptl_base_send_request_t",
&mca_pml_base_request_cls, CLASS_INFO(mca_pml_base_request_t),
(class_init_t) mca_ptl_base_send_request_init, (lam_construct_t) mca_ptl_base_send_request_construct,
(class_destroy_t) mca_ptl_base_send_request_destroy (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); OBJ_CONSTRUCT_SUPER(req, mca_pml_base_request_t);
STATIC_INIT(req->req_unacked_frags, &lam_list_cls); 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); OBJ_DESTRUCT(&req->req_unacked_frags);
SUPER_DESTROY(&req->req_unacked_frags, &mca_pml_base_request_cls); 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" #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 { 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 /* 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. * 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) { if(NULL == ptl_peer) {
THREAD_UNLOCK(&ptl_proc->proc_lock); THREAD_UNLOCK(&ptl_proc->proc_lock);
return LAM_ERR_OUT_OF_RESOURCE; 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) int mca_ptl_tcp_module_open(void)
{ {
lam_mutex_init(&mca_ptl_tcp_module.tcp_lock); lam_mutex_construct(&mca_ptl_tcp_module.tcp_lock);
STATIC_INIT(mca_ptl_tcp_module.tcp_reactor, &lam_reactor_cls); OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_reactor, lam_reactor_t);
STATIC_INIT(mca_ptl_tcp_module.tcp_procs, &lam_list_cls); OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_procs, lam_list_t);
STATIC_INIT(mca_ptl_tcp_module.tcp_send_requests, &lam_free_list_cls); OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_send_requests, lam_free_list_t);
STATIC_INIT(mca_ptl_tcp_module.tcp_send_frags, &lam_free_list_cls); OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_send_frags, lam_free_list_t);
STATIC_INIT(mca_ptl_tcp_module.tcp_recv_frags, &lam_free_list_cls); OBJ_CONSTRUCT(&mca_ptl_tcp_module.tcp_recv_frags, lam_free_list_t);
/* register TCP module parameters */ /* register TCP module parameters */
mca_ptl_tcp_module.tcp_if_include = 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) if (NULL != mca_ptl_tcp_module.tcp_ptls)
free(mca_ptl_tcp_module.tcp_ptls); free(mca_ptl_tcp_module.tcp_ptls);
STATIC_DESTROY(mca_ptl_tcp_module.tcp_reactor); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_reactor);
STATIC_DESTROY(mca_ptl_tcp_module.tcp_procs); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_procs);
STATIC_DESTROY(mca_ptl_tcp_module.tcp_send_requests); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_send_requests);
STATIC_DESTROY(mca_ptl_tcp_module.tcp_send_frags); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_send_frags);
STATIC_DESTROY(mca_ptl_tcp_module.tcp_recv_frags); OBJ_DESTRUCT(&mca_ptl_tcp_module.tcp_recv_frags);
lam_mutex_destroy(&mca_ptl_tcp_module.tcp_lock); lam_mutex_destruct(&mca_ptl_tcp_module.tcp_lock);
return LAM_SUCCESS; return LAM_SUCCESS;
} }
@ -290,25 +290,25 @@ mca_ptl_t** mca_ptl_tcp_module_init(int *num_ptls,
/* initialize free lists */ /* 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), 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_num,
mca_ptl_tcp_module.tcp_free_list_max, mca_ptl_tcp_module.tcp_free_list_max,
mca_ptl_tcp_module.tcp_free_list_inc, mca_ptl_tcp_module.tcp_free_list_inc,
NULL); /* use default allocator */ 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), 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_num,
mca_ptl_tcp_module.tcp_free_list_max, mca_ptl_tcp_module.tcp_free_list_max,
mca_ptl_tcp_module.tcp_free_list_inc, mca_ptl_tcp_module.tcp_free_list_inc,
NULL); /* use default allocator */ 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), 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_num,
mca_ptl_tcp_module.tcp_free_list_max, mca_ptl_tcp_module.tcp_free_list_max,
mca_ptl_tcp_module.tcp_free_list_inc, 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_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 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_close_i(mca_ptl_base_peer_t*);
static void mca_ptl_tcp_peer_connected(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); 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", "mca_tcp_ptl_peer_t",
&lam_list_cls, CLASS_INFO(lam_list_t),
(class_init_t)mca_ptl_tcp_peer_init, (lam_construct_t)mca_ptl_tcp_peer_construct,
(class_destroy_t)mca_ptl_tcp_peer_destroy (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. * 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_ptl = 0;
ptl_peer->peer_proc = 0; ptl_peer->peer_proc = 0;
ptl_peer->peer_addr = 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_recv_frag = 0;
ptl_peer->peer_state = MCA_PTL_TCP_CLOSED; ptl_peer->peer_state = MCA_PTL_TCP_CLOSED;
ptl_peer->peer_retries = 0; ptl_peer->peer_retries = 0;
STATIC_INIT(ptl_peer->peer_frags, &lam_list_cls); OBJ_CONSTRUCT(&ptl_peer->peer_frags, lam_list_t);
lam_mutex_init(&ptl_peer->peer_lock); 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. * 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_proc_remove(ptl_peer->peer_proc, ptl_peer);
mca_ptl_tcp_peer_close_i(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; } 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. * An abstraction that represents a connection to a peer process.

Просмотреть файл

@ -10,27 +10,27 @@
#include "ptl_tcp_proc.h" #include "ptl_tcp_proc.h"
static void mca_ptl_tcp_proc_init(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_destroy(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); 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", "mca_ptl_tcp_proc_t",
&lam_list_item_cls, CLASS_INFO(lam_list_item_t),
(class_init_t)mca_ptl_tcp_proc_init, (lam_construct_t)mca_ptl_tcp_proc_construct,
(class_destroy_t)mca_ptl_tcp_proc_destroy (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_lam = 0;
proc->proc_addrs = 0; proc->proc_addrs = 0;
proc->proc_addr_count = 0; proc->proc_addr_count = 0;
proc->proc_peers = 0; proc->proc_peers = 0;
proc->proc_peer_count = 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 */ /* add to list of all proc instance */
THREAD_LOCK(&mca_ptl_tcp_module.tcp_lock); 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 */ /* remove from list of all proc instances */
THREAD_LOCK(&mca_ptl_tcp_module.tcp_lock); 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); free(proc->proc_peers);
if(NULL != proc->proc_guid) if(NULL != proc->proc_guid)
free(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) if(ptl_proc != NULL)
return ptl_proc; 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; ptl_proc->proc_lam = lam_proc;
/* build a unique identifier (of arbitrary size) to represent the proc */ /* build a unique identifier (of arbitrary size) to represent the proc */

Просмотреть файл

@ -14,7 +14,7 @@
#include "ptl_tcp.h" #include "ptl_tcp.h"
#include "ptl_tcp_peer.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" #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_construct(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_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_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_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); 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); 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_tcp_recv_frag_t",
&mca_ptl_base_recv_frag_cls, CLASS_INFO(mca_ptl_base_recv_frag_t),
(class_init_t)mca_ptl_tcp_recv_frag_init, (lam_construct_t)mca_ptl_tcp_recv_frag_construct,
(class_destroy_t)mca_ptl_tcp_recv_frag_destroy (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" #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 { struct mca_ptl_tcp_recv_frag_t {

Просмотреть файл

@ -11,23 +11,23 @@
#include "ptl_tcp_sendfrag.h" #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_tcp_send_frag_t",
&mca_ptl_base_send_frag_cls, CLASS_INFO(mca_ptl_base_send_frag_t),
(class_init_t)mca_ptl_tcp_send_frag_init, (lam_construct_t)mca_ptl_tcp_send_frag_construct,
(class_destroy_t)mca_ptl_tcp_send_frag_destroy (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" #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 { 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; 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_construct(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_destruct(mca_ptl_tcp_send_frag_t*);
bool mca_ptl_tcp_send_frag_handler(mca_ptl_tcp_send_frag_t*, int sd); bool mca_ptl_tcp_send_frag_handler(mca_ptl_tcp_send_frag_t*, int sd);
void mca_ptl_tcp_send_frag_reinit( void mca_ptl_tcp_send_frag_reinit(

Просмотреть файл

@ -10,28 +10,28 @@
#include "ptl_tcp_sendreq.h" #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_construct(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_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_tcp_send_request_t",
&mca_ptl_base_send_request_cls, CLASS_INFO(mca_ptl_base_send_request_t),
(class_init_t)mca_ptl_tcp_send_request_init, (lam_construct_t)mca_ptl_tcp_send_request_construct,
(class_destroy_t)mca_ptl_tcp_send_request_destroy (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); OBJ_CONSTRUCT_SUPER(request, mca_ptl_base_send_request_t);
STATIC_INIT(request->req_frag, &mca_ptl_tcp_send_frag_cls); 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); OBJ_DESTRUCT(&request->req_frag);
SUPER_DESTROY(request, &mca_ptl_base_send_request_cls); OBJ_DESTRUCT_SUPER(request, mca_ptl_base_send_request_t);
} }

Просмотреть файл

@ -14,7 +14,7 @@
#include "ptl_tcp_sendfrag.h" #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 { struct mca_ptl_tcp_send_request_t {
mca_ptl_base_send_request_t super; 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) #if defined(c_plusplus) || defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
int lam_comm_init(lam_communicator_t *comm); int lam_comm_construct(lam_communicator_t *comm);
int lam_comm_link_function(void); int lam_comm_link_function(void);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }

Просмотреть файл

@ -2,19 +2,16 @@
* $HEADER$ * $HEADER$
*/ */
/** @file */ /** @file lam_datatype_t implementation */
#ifdef DATATYPES_ARE_READY
#include "lam_config.h" #include "lam_config.h"
#include "lam/datatype.h" #include "lam/datatype.h"
lam_class_info_t lam_datatype_t_class_info = {
lam_class_info_t lam_datatype_cls = {
"lam_datatype_t", "lam_datatype_t",
&lam_dbl_item_cls, CLASS_INFO(lam_dbl_item_t),
(class_init_t) lam_p2p_cdi_init, (lam_construct_t) lam_p2p_cdi_construct,
(class_destroy_t) lam_p2p_cdi_destroy (lam_destruct_t) lam_p2p_cdi_destruct
}; };
@ -22,12 +19,12 @@ static int lam_datatype_init = 0;
lam_dbl_list_t lam_p2p_cdis; 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) { if (fetchNset(&lam_p2p_cdis_init, 1) == 0) {
lam_dbl_init(&lam_p2p_cdis); 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_name = 0;
cdi->cdi_id = lam_dbl_get_size(&lam_p2p_cdis) + 1; cdi->cdi_id = lam_dbl_get_size(&lam_p2p_cdis) + 1;
cdi->cdi_frag_first_size = 0; 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_latency = 0;
cdi->cdi_endpoint_bandwidth = 0; cdi->cdi_endpoint_bandwidth = 0;
cdi->cdi_endpoint_count = 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); 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_remove(&lam_p2p_cdis, &cdi->cdi_base);
lam_dbl_destroy(&cdi->cdi_incomplete_sends); lam_dbl_destruct(&cdi->cdi_incomplete_sends);
lam_dbl_item_destroy(&cdi->cdi_base); lam_dbl_item_destruct(&cdi->cdi_base);
} }
@ -116,21 +113,20 @@ struct lam_packer_state_t {
* @param count size of array * @param count size of array
* @param type type descriptor * @param type type descriptor
*/ */
lam_packer_status_t lam_packer(lam_packer_direction_t direction, lam_packer_status_t
void *buf, lam_packer(lam_packer_direction_t direction,
size_t bufsize, void *buf,
size_t *offset, size_t bufsize,
void *typebuf, size_t * offset,
size_t ntype, void *typebuf,
lam_datatype_t *datatype, size_t ntype,
lam_pack_state_t *pack_state, lam_datatype_t * datatype,
lam_checksum_t *checksum) lam_pack_state_t * pack_state, lam_checksum_t * checksum)
{ {
return 0;
} }
/** /**
* lam_datatype_copy - Copy (the contents of) an array of data types * lam_datatype_copy - Copy (the contents of) an array of data types
* *
@ -139,31 +135,30 @@ lam_packer_status_t lam_packer(lam_packer_direction_t direction,
* @param count size of array * @param count size of array
* @param type type descriptor * @param type type descriptor
*/ */
void lam_datatype_copy(void *dest, void
const void *src, lam_datatype_copy(void *dest,
size_t count, const void *src,
lam_datatype_t *datatype, size_t count,
lam_checksum_t *checksum) lam_datatype_t *datatype,
lam_checksum_t *csum)
{ {
if (datatype == NULL) { if (datatype == NULL) {
memmove(dest, src, count); memmove(dest, src, count);
} else if (datatype->layout == CONTIGUOUS) { } else if (datatype->layout == CONTIGUOUS) {
memmove(dest, src, count * datatype->extent); memmove(dest, src, count * datatype->extent);
} else { } else {
unsigned char *p = ((unsigned char *) dest); unsigned char *p = ((unsigned char *) dest);
unsigned char *q = ((unsigned char *) src); unsigned char *q = ((unsigned char *) src);
int map; int map;
while (count--) { while (count--) {
for (map = 0; map < datatype->num_pairs; map++) { for (map = 0; map < datatype->num_pairs; map++) {
memmove(p + datatype->type_map[map].offset, memmove(p + datatype->type_map[map].offset,
q + datatype->type_map[map].offset, q + datatype->type_map[map].offset,
datatype->type_map[map].size); datatype->type_map[map].size);
} }
p += datatype->extent; p += datatype->extent;
q += datatype->extent; q += datatype->extent;
} }
} }
} }
#endif

Просмотреть файл

@ -2,10 +2,10 @@
* $HEADER$ * $HEADER$
*/ */
/** @file /** @file
* *
* Data stuctures and functions related to LAM datatypes. * Data stuctures and functions related to LAM datatypes.
*/ */
/* /*
* LAM internal data type representation * LAM internal data type representation
@ -42,12 +42,12 @@ typedef struct lam_pack_state_t lam_pack_state_t;
* Datatype state flags * Datatype state flags
*/ */
enum lam_datatype_state_t { enum lam_datatype_state_t {
LAM_DATATYPE_STATE_COMMITTED = 1 << 0, LAM_DATATYPE_STATE_COMMITTED = 1 << 0,
LAM_DATATYPE_STATE_CONTIGUOUS = 1 << 1, LAM_DATATYPE_STATE_CONTIGUOUS = 1 << 1,
LAM_DATATYPE_STATE_FORTRAN = 1 << 2, LAM_DATATYPE_STATE_FORTRAN = 1 << 2,
LAM_DATATYPE_STATE_OPTIMIZED = 1 << 3, LAM_DATATYPE_STATE_OPTIMIZED = 1 << 3,
LAM_DATATYPE_STATE_DONT_OPTIMIZE = 1 << 4, LAM_DATATYPE_STATE_DONT_OPTIMIZE = 1 << 4,
LAM_DATATYPE_STATE_XDR = 1 << 5, LAM_DATATYPE_STATE_XDR = 1 << 5,
/* etc. */ /* etc. */
}; };
typedef enum lam_datatype_state_t lam_datatype_state_t; typedef enum lam_datatype_state_t lam_datatype_state_t;
@ -99,15 +99,15 @@ typedef enum lam_checksum_kind_t lam_checksum_kind_t;
* State of incremental memcpy with checksum or CRC * State of incremental memcpy with checksum or CRC
*/ */
typedef struct lam_memcpy_state_t { typedef struct lam_memcpy_state_t {
size_t size; /**< total size in bytes of the object size_t size; /**< total size in bytes of the object
* being checksummed / CRCed */ * being checksummed / CRCed */
size_t partial_size; /**< size of non- uint32_t to be carried size_t partial_size; /**< size of non- uint32_t to be carried
* over to next call */ * over to next call */
uint32_t partial_int; /**< value of non- uint32_t to be carried uint32_t partial_int; /**< value of non- uint32_t to be carried
* over to next call */ * over to next call */
uint32_t sum; /**< current value of the CRC or uint32_t sum; /**< current value of the CRC or
* checksum */ * checksum */
bool first_call; /**< is this the first call for this bool first_call; /**< is this the first call for this
* checksum/CRC? */ * checksum/CRC? */
} lam_memcpy_state_t; } lam_memcpy_state_t;
@ -117,35 +117,35 @@ typedef struct lam_memcpy_state_t {
*/ */
struct lam_datatype_t { struct lam_datatype_t {
lam_object_t d_super; /**< object super class */ lam_object_t d_super; /**< object super class */
char d_name[MPI_MAX_OBJECT_NAME]; /**< object name */ char d_name[MPI_MAX_OBJECT_NAME]; /**< object name */
int d_flags; /**< bit flags */ int d_flags; /**< bit flags */
/* cached information */ /* cached information */
ssize_t d_lower_bound; ssize_t d_lower_bound;
size_t d_extent; size_t d_extent;
size_t d_packed_size; /**< size in bytes, ignoring gaps */ size_t d_packed_size; /**< size in bytes, ignoring gaps */
int d_nbasic; /**< number of basic elements */ int d_nbasic; /**< number of basic elements */
/* optimized representation */ /* optimized representation */
size_t d_datavec_size; /**< size of optimized representation */ size_t d_datavec_size; /**< size of optimized representation */
lam_datavec_t *d_datavec; /**< optimized representation (may be null) */ lam_datavec_t *d_datavec; /**< optimized representation (may be null) */
/* XDR representation */ /* XDR representation */
size_t d_dataxdr_size; /**< size of XDR representation */ size_t d_dataxdr_size; /**< size of XDR representation */
lam_dataxdr_t *d_dataxdr; /**< XDR representation (may be null) */ lam_dataxdr_t *d_dataxdr; /**< XDR representation (may be null) */
/* full representation (c.f. MPI_Type_create_struct) */ /* full representation (c.f. MPI_Type_create_struct) */
struct { struct {
lam_datatype_kind_t c_kind; /**< creation function */ lam_datatype_kind_t c_kind; /**< creation function */
int c_count; /**< number of blocks */ int c_count; /**< number of blocks */
int *c_blocklengths; /**< number of elements in each block */ int *c_blocklengths; /**< number of elements in each block */
MPI_Aint *c_offset; /**< stride/displacement as appropriate */ MPI_Aint *c_offset; /**< stride/displacement as appropriate */
lam_datatype_t **c_types; /**< array of types (array) */ lam_datatype_t **c_types; /**< array of types (array) */
} d_creator; } d_creator;
}; };
@ -166,9 +166,9 @@ struct lam_datavec_t {
* An element of a data type in optimized form * An element of a data type in optimized form
*/ */
struct lam_datavec_element_t { struct lam_datavec_element_t {
size_t dve_size; /**< size in bytes of element */ size_t dve_size; /**< size in bytes of element */
ssize_t dve_offset; /**< offset from start of data type */ ssize_t dve_offset; /**< offset from start of data type */
ssize_t dve_seq_offset; /**< offset from start of packed data type */ ssize_t dve_seq_offset; /**< offset from start of packed data type */
}; };
@ -177,14 +177,26 @@ struct lam_datavec_element_t {
*/ */
struct lam_dataxdr_element_t { struct lam_dataxdr_element_t {
/* to be done */ /* to be done */
void *x_xdrs; /**< XDR stream */ void *x_xdrs; /**< XDR stream */
}; };
/** /**
* 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 **********************************************************/ /* interface **********************************************************/
@ -199,9 +211,9 @@ typedef void *(*lam_memcpy_fn_t)(void *dst, const void *src, size_t size, void *
* @return 0 on success, -1 on error * @return 0 on success, -1 on error
*/ */
int lam_datatype_checksum(const void *addr, int lam_datatype_checksum(const void *addr,
size_t count, size_t count,
lam_datatype_t *datatype, lam_datatype_t *datatype,
lam_checksum_t *checksum); lam_checksum_t *checksum);
/** /**
* Copy (the contents of) an array of data types * Copy (the contents of) an array of data types
@ -210,15 +222,15 @@ int lam_datatype_checksum(const void *addr,
* @param src Input data type array * @param src Input data type array
* @param count Size of array * @param count Size of array
* @param datatype Datatype descriptor * @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 * @return 0 on success, -1 on error
*/ */
int lam_datatype_copy(void *dst, int lam_datatype_copy(void *dst,
const void *src, const void *src,
size_t count, size_t count,
lam_datatype_t *datatype, lam_datatype_t *datatype,
lam_memcpy_fn_t *memcpy_fn, 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 * Copy (the contents of) an array of data types, and convert to
@ -234,12 +246,13 @@ int lam_datatype_copy(void *dst,
* @return 0 on success, -1 on error * @return 0 on success, -1 on error
*/ */
int lam_datatype_convert(void *dst, int lam_datatype_convert(void *dst,
lam_datatype_t *dst_datatype, lam_datatype_t *dst_datatype,
size_t dst_count, size_t dst_count,
const void *src, const void *src,
lam_datatype_t *src_datatype, lam_datatype_t *src_datatype,
size_t src_count, size_t src_count,
lam_checksum_t *checksum); lam_memcpy_fn_t *memcpy_fn,
lam_memcpy_state_t *check);
/** /**
* Pack state * Pack state
@ -249,9 +262,9 @@ int lam_datatype_convert(void *dst,
*/ */
struct lam_pack_state_t { struct lam_pack_state_t {
size_t current_offset_packed; /**< current offset into packed buffer */ size_t current_offset_packed; /**< current offset into packed buffer */
size_t current_type; /**< current index of datatype */ size_t current_type; /**< current index of datatype */
size_t current_repeat; /**< current index of datavec repeat */ size_t current_repeat; /**< current index of datavec repeat */
size_t current_element; /**< current index of datavec element */ size_t current_element; /**< current index of datavec element */
size_t current_offset_datavec; /**< current offset into datavec element */ size_t current_offset_datavec; /**< current offset into datavec element */
}; };
@ -266,7 +279,7 @@ struct lam_pack_state_t {
* @param ntype size of type array * @param ntype size of type array
* @param datatype type descriptor * @param datatype type descriptor
* @param memcpy_fn pointer to memcpy function * @param memcpy_fn pointer to memcpy function
* @param csum pointer to checksum * @param check pointer to checksum
* @return 0 if complete, non-zero otherwise * @return 0 if complete, non-zero otherwise
* *
* Incrementally copy data type arrays to/from a packed buffer by * Incrementally copy data type arrays to/from a packed buffer by
@ -277,13 +290,13 @@ struct lam_pack_state_t {
* call. * call.
*/ */
int lam_datatype_pack(lam_pack_state_t *state, int lam_datatype_pack(lam_pack_state_t *state,
void *buf, void *buf,
size_t bufsize, size_t bufsize,
const void *typebuf, const void *typebuf,
size_t ntype, size_t ntype,
lam_datatype_t *datatype, lam_datatype_t *datatype,
lam_memcpy_fn_t *memcpy_fn, 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 bufsize size of buffer
* @param datatype type descriptor * @param datatype type descriptor
* @param memcpy_fn pointer to memcpy function * @param memcpy_fn pointer to memcpy function
* @param csum pointer to checksum * @param check pointer to checksum
* @return 0 complete, non-zero otherwise * @return 0 complete, non-zero otherwise
* *
* Incrementally copy data type arrays to/from a packed buffer by * Incrementally copy data type arrays to/from a packed buffer by
@ -307,13 +320,13 @@ int lam_datatype_pack(lam_pack_state_t *state,
* call. * call.
*/ */
int lam_datatype_unpack(lam_pack_state_t *state, int lam_datatype_unpack(lam_pack_state_t *state,
void *typebuf, void *typebuf,
size_t ntype, size_t ntype,
const void *buf, const void *buf,
size_t bufsize, size_t bufsize,
lam_datatype_t *datatype, lam_datatype_t *datatype,
lam_memcpy_fn_t *memcpy_fn, lam_memcpy_fn_t *memcpy_fn,
void *csum); lam_memcpy_state_t *check);
/** /**
* Incrementally generate an iovec for gathering from an array of * Incrementally generate an iovec for gathering from an array of
@ -339,14 +352,14 @@ int lam_datatype_unpack(lam_pack_state_t *state,
* call. * call.
*/ */
int lam_datatype_gather_iovec(lam_pack_state_t *state, int lam_datatype_gather_iovec(lam_pack_state_t *state,
void *base_addr, void *base_addr,
struct iovec *vec, struct iovec *vec,
size_t vec_count, size_t vec_count,
size_t max_bytes, size_t max_bytes,
const void *typebuf, const void *typebuf,
size_t ntype, size_t ntype,
lam_datatype_t *datatype, lam_datatype_t *datatype,
lam_checksum_t *checksum); lam_checksum_t *checksum);
/** /**
* Incrementally generate an iovec for scattering from a packed array * Incrementally generate an iovec for scattering from a packed array
@ -377,15 +390,15 @@ int lam_datatype_gather_iovec(lam_pack_state_t *state,
* call. * call.
*/ */
int lam_datatype_scatter_iovec(lam_pack_state_t *state, int lam_datatype_scatter_iovec(lam_pack_state_t *state,
void *base_addr, void *base_addr,
struct iovec *vec, struct iovec *vec,
size_t vec_count, size_t vec_count,
size_t max_bytes, size_t max_bytes,
const void *buf, const void *buf,
size_t bufsize, size_t bufsize,
lam_datatype_t *datatype, lam_datatype_t *datatype,
lam_memcpy_fn_t *memcpy_fn, 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 state pointer to state object for the current sequence of copies
* @param sum_size the length of the entire buffer to be checksummed * @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->size = sum_size;
state->first_call = true; 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 dst pointer to the destination buffer
* @param src pointer to the source buffer * @param src pointer to the source buffer
* @param size size of the 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 * @return the original value of dst
*/ */
static inline void *lam_memcpy(void *dst, const void *src, size_t size, 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); return memcpy(dst, src, size);
} }
#if 0 #if 0
uint32_t lam_crc32(const void *restrict buffer, size_t size, uint32_t initial_crc); uint32_t lam_crc32(const void *restrict buffer, size_t size,
uint32_t lam_sum32(const void *restrict buffer, size_t size, uint32_t initial_crc); uint32_t initial_crc);
void *lam_memcpy_sum32(void *dst, const void *src, size_t size, uint32_t lam_sum32(const void *restrict buffer, size_t size,
lam_memcpy_state_t *state); uint32_t initial_crc);
void *lam_memcpy_crc32(void *dst, const void *src, size_t size,
lam_memcpy_state_t *state);
#endif #endif
/** /**
@ -452,4 +471,4 @@ void *lam_memcpy_crc32(void *dst, const void *src, size_t size,
*/ */
#endif /* LAM_DATATYPE_H_INCLUDED */ #endif /* LAM_DATATYPE_H_INCLUDED */

Просмотреть файл

@ -13,7 +13,7 @@ int lam_datatype_copy(void *dst,
size_t count, size_t count,
lam_datatype_t *d, lam_datatype_t *d,
lam_memcpy_fn_t *memcpy_fn, lam_memcpy_fn_t *memcpy_fn,
void *csum) lam_memcpy_state_t *csum)
{ {
int status; int status;

Просмотреть файл

@ -31,9 +31,8 @@
* buffers via multiple calls of bcopy_csum() - Mitch * buffers via multiple calls of bcopy_csum() - Mitch
*/ */
void *lam_memcpy_sum32(void *restrict dst, void *lam_memcpy_sum32(void *restrict dst,
const void *restrict src, const void *restrict src,
size_t size, size_t size, lam_memcpy_state_t * state)
lam_memcpy_state_t *state)
{ {
uint32_t *restrict p = (uint32_t *) dst; uint32_t *restrict p = (uint32_t *) dst;
uint32_t *restrict q = (uint32_t *) src; uint32_t *restrict q = (uint32_t *) src;
@ -44,323 +43,372 @@ void *lam_memcpy_sum32(void *restrict dst,
uint32_t temp; uint32_t temp;
if (state->first_call) { if (state->first_call) {
state->first_call = false; state->first_call = false;
state->partial_int = 0; state->partial_int = 0;
state->partial_size = 0; state->partial_size = 0;
} }
csumlenresidue = (csumlen > size) ? (csumlen - size) : 0; csumlenresidue = (csumlen > size) ? (csumlen - size) : 0;
temp = state->partial_int; temp = state->partial_int;
#if 0 if (IS_32BIT_ALIGNED(p) && IS_32BIT_ALIGNED(q)) {
if (intaligned(p) && intaligned(q)) { if (state->partial_size) {
if (state->partial_size) { /* do we have enough data to fill out the partial word? */
// do we have enough data to fill out the partial word? if (size >= (sizeof(uint32_t) - state->partial_size)) {
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do... /* YES, we do... */
memcpy(((char *) &temp + state->partial_size), q, memcpy(((char *) &temp + state->partial_size), q,
(sizeof(uint32_t) - state->partial_size)); (sizeof(uint32_t) - state->partial_size));
memcpy(p, ((char *) &temp + state->partial_size), memcpy(p, ((char *) &temp + state->partial_size),
(sizeof(uint32_t) - state->partial_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) -
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size); state->partial_size);
csum += (temp - state->partial_int); p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
size -= sizeof(uint32_t) - state->partial_size; state->partial_size);
// now we have an unaligned source and an unaligned destination csum += (temp - state->partial_int);
for (; size >= sizeof(*q); size -= sizeof(*q)) { size -= sizeof(uint32_t) - state->partial_size;
memcpy(&temp, q, sizeof(temp)); /*
q++; * now we have an unaligned source and an unaligned
csum += temp; * destination
memcpy(p, &temp, sizeof(temp)); */
p++; for (; size >= sizeof(*q); size -= sizeof(*q)) {
} memcpy(&temp, q, sizeof(temp));
state->partial_size = 0; q++;
state->partial_int = 0; csum += temp;
} else { // NO, we don't... memcpy(p, &temp, sizeof(temp));
memcpy(((char *) &temp + state->partial_size), q, size); p++;
memcpy(p, ((char *) &temp + state->partial_size), size); }
q = (uint32_t *) ((char *) q + size); state->partial_size = 0;
p = (uint32_t *) ((char *) p + size); state->partial_int = 0;
csum += (temp - state->partial_int); } else {
state->partial_int = temp; /* NO, we don't... */
state->partial_size += size; memcpy(((char *) &temp + state->partial_size), q, size);
size = 0; memcpy(p, ((char *) &temp + state->partial_size), size);
} q = (uint32_t *) ((char *) q + size);
} else { // fast path... p = (uint32_t *) ((char *) p + size);
size_t numLongs = size / sizeof(uint32_t); csum += (temp - state->partial_int);
for (i = 0; i < numLongs; i++) { state->partial_int = temp;
csum += *q; state->partial_size += size;
*p++ = *q++; size = 0;
} }
state->partial_int = 0; } else { /* fast path... */
state->partial_size = 0; size_t numLongs = size / sizeof(uint32_t);
if (intaligned(size) && (csumlenresidue == 0)) { for (i = 0; i < numLongs; i++) {
state->sum = csum; csum += *q;
return dst; *p++ = *q++;
} else { }
size -= i * sizeof(uint32_t); state->partial_int = 0;
} state->partial_size = 0;
} if (IS_32BIT_ALIGNED(size) && (csumlenresidue == 0)) {
} else if (intaligned(q)) { state->sum = csum;
if (state->partial_size) { return dst;
// do we have enough data to fill out the partial word? } else {
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do... size -= i * sizeof(uint32_t);
memcpy(((char *) &temp + state->partial_size), q, }
(sizeof(uint32_t) - state->partial_size)); }
memcpy(p, ((char *) &temp + state->partial_size), } else if (IS_32BIT_ALIGNED(q)) {
(sizeof(uint32_t) - state->partial_size)); if (state->partial_size) {
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size); /* do we have enough data to fill out the partial word? */
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size); if (size >= (sizeof(uint32_t) - state->partial_size)) {
csum += (temp - state->partial_int); /* YES, we do... */
size -= sizeof(uint32_t) - state->partial_size; memcpy(((char *) &temp + state->partial_size), q,
// now we have an unaligned source and an unknown alignment for our destination (sizeof(uint32_t) - state->partial_size));
if (intaligned(p)) { memcpy(p, ((char *) &temp + state->partial_size),
size_t numLongs = size / sizeof(uint32_t); (sizeof(uint32_t) - state->partial_size));
for (i = 0; i < numLongs; i++) { q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
memcpy(&temp, q, sizeof(temp)); state->partial_size);
q++; p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
csum += temp; state->partial_size);
*p++ = temp; csum += (temp - state->partial_int);
} size -= sizeof(uint32_t) - state->partial_size;
size -= i * sizeof(uint32_t); /*
} else { * now we have an unaligned source and an unknown
for (; size >= sizeof(*q); size -= sizeof(*q)) { * alignment for our destination
memcpy(&temp, q, sizeof(temp)); */
q++; if (IS_32BIT_ALIGNED(p)) {
csum += temp; size_t numLongs = size / sizeof(uint32_t);
memcpy(p, &temp, sizeof(temp)); for (i = 0; i < numLongs; i++) {
p++; memcpy(&temp, q, sizeof(temp));
} q++;
} csum += temp;
state->partial_int = 0; *p++ = temp;
state->partial_size = 0; }
} else { // NO, we don't... size -= i * sizeof(uint32_t);
memcpy(((char *) &temp + state->partial_size), q, size); } else {
memcpy(p, ((char *) &temp + state->partial_size), size); for (; size >= sizeof(*q); size -= sizeof(*q)) {
q = (uint32_t *) ((char *) q + size); memcpy(&temp, q, sizeof(temp));
p = (uint32_t *) ((char *) p + size); q++;
csum += (temp - state->partial_int); csum += temp;
state->partial_int = temp; memcpy(p, &temp, sizeof(temp));
state->partial_size += size; p++;
size = 0; }
} }
} else { state->partial_int = 0;
for (; size >= sizeof(*q); size -= sizeof(*q)) { state->partial_size = 0;
temp = *q++; } else {
csum += temp; /* NO, we don't... */
memcpy(p, &temp, sizeof(temp)); memcpy(((char *) &temp + state->partial_size), q, size);
p++; memcpy(p, ((char *) &temp + state->partial_size), size);
} q = (uint32_t *) ((char *) q + size);
state->partial_int = 0; p = (uint32_t *) ((char *) p + size);
state->partial_size = 0; csum += (temp - state->partial_int);
} state->partial_int = temp;
} else if (intaligned(p)) { state->partial_size += size;
if (state->partial_size) { size = 0;
// do we have enough data to fill out the partial word? }
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do... } else {
memcpy(((char *) &temp + state->partial_size), q, for (; size >= sizeof(*q); size -= sizeof(*q)) {
(sizeof(uint32_t) - state->partial_size)); temp = *q++;
memcpy(p, ((char *) &temp + state->partial_size), csum += temp;
(sizeof(uint32_t) - state->partial_size)); memcpy(p, &temp, sizeof(temp));
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size); p++;
p = (uint32_t *) ((char *) p + sizeof(uint32_t) - state->partial_size); }
csum += (temp - state->partial_int); state->partial_int = 0;
size -= sizeof(uint32_t) - state->partial_size; state->partial_size = 0;
// now we have a source of unknown alignment and a unaligned destination }
if (intaligned(q)) { } else if (IS_32BIT_ALIGNED(p)) {
for (; size >= sizeof(*q); size -= sizeof(*q)) { if (state->partial_size) {
temp = *q++; /* do we have enough data to fill out the partial word? */
csum += temp; if (size >= (sizeof(uint32_t) - state->partial_size)) {
memcpy(p, &temp, sizeof(temp)); /* YES, we do... */
p++; memcpy(((char *) &temp + state->partial_size), q,
} (sizeof(uint32_t) - state->partial_size));
state->partial_int = 0; memcpy(p, ((char *) &temp + state->partial_size),
state->partial_size = 0; (sizeof(uint32_t) - state->partial_size));
} else { q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
for (; size >= sizeof(*q); size -= sizeof(*q)) { state->partial_size);
memcpy(&temp, q, sizeof(temp)); p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
q++; state->partial_size);
csum += temp; csum += (temp - state->partial_int);
memcpy(p, &temp, sizeof(temp)); size -= sizeof(uint32_t) - state->partial_size;
p++; /*
} * now we have a source of unknown alignment and a
state->partial_size = 0; * unaligned destination
state->partial_int = 0; */
} if (IS_32BIT_ALIGNED(q)) {
} else { // NO, we don't... for (; size >= sizeof(*q); size -= sizeof(*q)) {
memcpy(((char *) &temp + state->partial_size), q, size); temp = *q++;
memcpy(p, ((char *) &temp + state->partial_size), size); csum += temp;
q = (uint32_t *) ((char *) q + size); memcpy(p, &temp, sizeof(temp));
p = (uint32_t *) ((char *) p + size); p++;
csum += (temp - state->partial_int); }
state->partial_int = temp; state->partial_int = 0;
state->partial_size += size; state->partial_size = 0;
size = 0; } else {
} for (; size >= sizeof(*q); size -= sizeof(*q)) {
} else { memcpy(&temp, q, sizeof(temp));
for (; size >= sizeof(*q); size -= sizeof(*q)) { q++;
memcpy(&temp, q, sizeof(temp)); csum += temp;
q++; memcpy(p, &temp, sizeof(temp));
csum += temp; p++;
*p++ = temp; }
} state->partial_size = 0;
state->partial_size = 0; state->partial_int = 0;
state->partial_int = 0; }
} } 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);
p = (uint32_t *) ((char *) p + size);
csum += (temp - state->partial_int);
state->partial_int = temp;
state->partial_size += size;
size = 0;
}
} else {
for (; size >= sizeof(*q); size -= sizeof(*q)) {
memcpy(&temp, q, sizeof(temp));
q++;
csum += temp;
*p++ = temp;
}
state->partial_size = 0;
state->partial_int = 0;
}
} else { } else {
if (state->partial_size) { if (state->partial_size) {
// do we have enough data to fill out the partial word? /* do we have enough data to fill out the partial word? */
if (size >= (sizeof(uint32_t) - state->partial_size)) { // YES, we do... if (size >= (sizeof(uint32_t) - state->partial_size)) {
memcpy(((char *) &temp + state->partial_size), q, /* YES, we do... */
(sizeof(uint32_t) - state->partial_size)); memcpy(((char *) &temp + state->partial_size), q,
memcpy(p, ((char *) &temp + state->partial_size), (sizeof(uint32_t) - state->partial_size));
(sizeof(uint32_t) - state->partial_size)); memcpy(p, ((char *) &temp + state->partial_size),
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size); (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) -
csum += (temp - state->partial_int); state->partial_size);
size -= sizeof(uint32_t) - state->partial_size; p = (uint32_t *) ((char *) p + sizeof(uint32_t) -
// now we have an unknown alignment for our source and destination state->partial_size);
if (intaligned(q) && intaligned(p)) { csum += (temp - state->partial_int);
size_t numLongs = size / sizeof(uint32_t); size -= sizeof(uint32_t) - state->partial_size;
for (i = 0; i < numLongs; i++) { /*
csum += *q; * now we have an unknown alignment for our source and
*p++ = *q++; * destination
} */
size -= i * sizeof(uint32_t); if (IS_32BIT_ALIGNED(q) && IS_32BIT_ALIGNED(p)) {
} else { // safe but slower for all other alignments size_t numLongs = size / sizeof(uint32_t);
for (; size >= sizeof(*q); size -= sizeof(*q)) { for (i = 0; i < numLongs; i++) {
memcpy(&temp, q, sizeof(temp)); csum += *q;
q++; *p++ = *q++;
csum += temp; }
memcpy(p, &temp, sizeof(temp)); size -= i * sizeof(uint32_t);
p++; } else { /* safe but slower for all other alignments */
} for (; size >= sizeof(*q); size -= sizeof(*q)) {
} memcpy(&temp, q, sizeof(temp));
state->partial_int = 0; q++;
state->partial_size = 0; csum += temp;
} else { // NO, we don't... memcpy(p, &temp, sizeof(temp));
memcpy(((char *) &temp + state->partial_size), q, size); p++;
memcpy(p, ((char *) &temp + state->partial_size), size); }
q = (uint32_t *) ((char *) q + size); }
p = (uint32_t *) ((char *) p + size); state->partial_int = 0;
csum += (temp - state->partial_int); state->partial_size = 0;
state->partial_int = temp; } else {
state->partial_size += size; /* NO, we don't... */
size = 0; memcpy(((char *) &temp + state->partial_size), q, size);
} memcpy(p, ((char *) &temp + state->partial_size), size);
} else { q = (uint32_t *) ((char *) q + size);
for (; size >= sizeof(*q); size -= sizeof(*q)) { p = (uint32_t *) ((char *) p + size);
memcpy(&temp, q, sizeof(temp)); csum += (temp - state->partial_int);
q++; state->partial_int = temp;
csum += temp; state->partial_size += size;
memcpy(p, &temp, sizeof(temp)); size = 0;
p++; }
} } else {
state->partial_size = 0; for (; size >= sizeof(*q); size -= sizeof(*q)) {
state->partial_int = 0; memcpy(&temp, q, sizeof(temp));
} q++;
csum += temp;
memcpy(p, &temp, sizeof(temp));
p++;
}
state->partial_size = 0;
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)) { if ((size != 0) && (csumlenresidue == 0)) {
temp = state->partial_int; temp = state->partial_int;
if (state->partial_size) { if (state->partial_size) {
if (size >= (sizeof(uint32_t) - 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; uint32_t copytemp = 0;
memcpy(&copytemp, q, size); memcpy(&copytemp, q, size);
memcpy(p, &copytemp, size); memcpy(p, &copytemp, 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, memcpy(((char *) &temp + state->partial_size), q,
(sizeof(uint32_t) - state->partial_size)); (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
csum += (temp - state->partial_int); * the old partial word from the new one before adding
size -= sizeof(uint32_t) - state->partial_size; * to the checksum...
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size); */
state->partial_size = size; csum += (temp - state->partial_int);
// reset temp, and calculate next partial word size -= sizeof(uint32_t) - state->partial_size;
temp = 0; q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
if (size) { state->partial_size);
memcpy(&temp, q, size); state->partial_size = size;
} /* reset temp, and calculate next partial word */
// add it to the the checksum temp = 0;
csum += temp; if (size) {
state->partial_int = temp; memcpy(&temp, q, size);
} else { }
// copy all remaining bytes from q to p /* add it to the the checksum */
uint32_t copytemp = 0; csum += temp;
memcpy(&copytemp, q, size); state->partial_int = temp;
memcpy(p, &copytemp, size); } else {
// fill out rest of partial word and add to checksum /* copy all remaining bytes from q to p */
memcpy(((char *) &temp + state->partial_size), q, size); uint32_t copytemp = 0;
// avoid unsigned arithmetic overflow by subtracting the old partial memcpy(&copytemp, q, size);
// word from the new one before adding to the checksum... memcpy(p, &copytemp, size);
csum += temp - state->partial_int; /* fill out rest of partial word and add to checksum */
state->partial_int = temp; memcpy(((char *) &temp + state->partial_size), q, size);
state->partial_size += size; /*
} * avoid unsigned arithmetic overflow by subtracting
} else { // fast path... * the old partial word from the new one before adding
// temp and state->partial_int are 0 if state->partial_size is 0... * to the checksum...
memcpy(&temp, q, size); */
csum += temp; csum += temp - state->partial_int;
memcpy(p, &temp, size); state->partial_int = temp;
state->partial_int = temp; state->partial_size += size;
state->partial_size = size; }
// done...return the checksum } 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 */
}
} else if (csumlenresidue != 0) { } else if (csumlenresidue != 0) {
if (size != 0) { if (size != 0) {
temp = 0; temp = 0;
memcpy(&temp, q, size); memcpy(&temp, q, size);
memcpy(p, &temp, size); memcpy(p, &temp, size);
} }
if (csumlenresidue < (ssize_t) (sizeof(uint32_t) - size - state->partial_size)) { if (csumlenresidue <
temp = state->partial_int; (ssize_t) (sizeof(uint32_t) - size - state->partial_size)) {
memcpy(((char *) &temp + state->partial_size), q, (size + csumlenresidue)); temp = state->partial_int;
// avoid unsigned arithmetic overflow by subtracting the old partial memcpy(((char *) &temp + state->partial_size), q,
// word from the new one before adding to the checksum... (size + csumlenresidue));
csum += temp - state->partial_int; /*
q++; * avoid unsigned arithmetic overflow by subtracting the
state->partial_int = temp; * old partial word from the new one before adding to the
state->partial_size += size + csumlenresidue; * checksum...
csumlenresidue = 0; */
} else { csum += temp - state->partial_int;
// we have enough chksum data to fill out our last partial q++;
// word state->partial_int = temp;
temp = state->partial_int; state->partial_size += size + csumlenresidue;
memcpy(((char *) &temp + state->partial_size), q, csumlenresidue = 0;
(sizeof(uint32_t) - state->partial_size)); } else {
// avoid unsigned arithmetic overflow by subtracting the old partial /*
// word from the new one before adding to the checksum... * we have enough chksum data to fill out our last partial
csum += temp - state->partial_int; * word
q = (uint32_t *) ((char *) q + sizeof(uint32_t) - state->partial_size); */
csumlenresidue -= sizeof(uint32_t) - state->partial_size - size; temp = state->partial_int;
state->partial_size = 0; memcpy(((char *) &temp + state->partial_size), q,
state->partial_int = 0; (sizeof(uint32_t) - state->partial_size));
} /*
#if 0 * avoid unsigned arithmetic overflow by subtracting the
if (intaligned(q)) { * old partial word from the new one before adding to the
for (i = 0; i < csumlenresidue / sizeof(uint32_t); i++) { * checksum...
csum += *q++; */
} csum += temp - state->partial_int;
} else { q = (uint32_t *) ((char *) q + sizeof(uint32_t) -
for (i = 0; i < csumlenresidue / sizeof(uint32_t); i++) { state->partial_size);
memcpy(&temp, q, sizeof(temp)); csumlenresidue -=
csum += temp; sizeof(uint32_t) - state->partial_size - size;
q++; state->partial_size = 0;
} state->partial_int = 0;
} }
#endif if (IS_32BIT_ALIGNED(q)) {
csumlenresidue -= i * sizeof(uint32_t); for (i = 0; i < csumlenresidue / sizeof(uint32_t); i++) {
if (csumlenresidue) { csum += *q++;
temp = 0; }
memcpy(&temp, q, csumlenresidue); } else {
csum += temp; for (i = 0; i < csumlenresidue / sizeof(uint32_t); i++) {
state->partial_int = temp; memcpy(&temp, q, sizeof(temp));
state->partial_size = csumlenresidue; csum += temp;
} q++;
}
}
csumlenresidue -= i * sizeof(uint32_t);
if (csumlenresidue) {
temp = 0;
memcpy(&temp, q, csumlenresidue);
csum += temp;
state->partial_int = temp;
state->partial_size = csumlenresidue;
}
} }
/* end else if (csumlenresidue != 0) */ /* end else if (csumlenresidue != 0) */
@ -368,4 +416,3 @@ void *lam_memcpy_sum32(void *restrict dst,
return dst; return dst;
} }

Просмотреть файл

@ -7,43 +7,46 @@
/* /*
* lam_info_t classes * lam_info_t classes
*/ */
lam_class_info_t lam_info_cls = { "lam_info_t", lam_class_info_t lam_info_t_class_info = {
&lam_list_cls, "lam_info_t",
(class_init_t)lam_info_init, CLASS_INFO(lam_list_t),
(class_destroy_t)lam_info_destroy}; (lam_construct_t)lam_info_construct,
(lam_destruct_t)lam_info_destruct
};
/* /*
* lam_info_entry_t classes * 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_info_entry_t",
&lam_list_item_cls, CLASS_INFO(lam_list_item_t),
(class_init_t)lam_info_entry_init, (lam_construct_t)lam_info_entry_construct,
(class_destroy_t)lam_info_entry_destroy}; (lam_destruct_t)lam_info_entry_destruct
};
/* /*
* lam_info_t interface functions * lam_info_t interface functions
*/ */
void lam_info_init(lam_info_t *info) { void lam_info_construct(lam_info_t *info) {
SUPER_INIT(info, lam_info_cls.cls_parent); OBJ_CONSTRUCT_SUPER(info, lam_list_t);
info->i_fhandle = -1; info->i_fhandle = -1;
} }
void lam_info_destroy(lam_info_t *info) { void lam_info_destruct(lam_info_t *info) {
SUPER_DESTROY(info, lam_info_cls.cls_parent); OBJ_DESTRUCT_SUPER(info, lam_list_t);
} }
/* /*
* lam_info_entry_t interface functions * lam_info_entry_t interface functions
*/ */
void lam_info_entry_init(lam_info_entry_t *entry) { void lam_info_entry_construct(lam_info_entry_t *entry) {
SUPER_INIT(entry, lam_list_item_cls.cls_parent); OBJ_CONSTRUCT_SUPER(entry, lam_object_t);
memset(entry->ie_key, 0, sizeof(entry->ie_key)); memset(entry->ie_key, 0, sizeof(entry->ie_key));
entry->ie_key[MPI_MAX_INFO_KEY] = 0; entry->ie_key[MPI_MAX_INFO_KEY] = 0;
} }
void lam_info_entry_destroy(lam_info_entry_t *entry) { void lam_info_entry_destruct(lam_info_entry_t *entry) {
SUPER_DESTROY(entry, lam_list_item_cls.cls_parent); OBJ_DESTRUCT_SUPER(entry, lam_object_t);
if (NULL != entry->ie_value) { if (NULL != entry->ie_value) {
free(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; 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_t_class_info;
extern lam_class_info_t lam_info_entry_cls; extern lam_class_info_t lam_info_entry_t_class_info;
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
extern "C" { extern "C" {
#endif #endif
void lam_info_init(lam_info_t *info); void lam_info_construct(lam_info_t *info);
void lam_info_destroy(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_construct(lam_info_entry_t *entry);
void lam_info_entry_destroy(lam_info_entry_t *entry); void lam_info_entry_destruct(lam_info_entry_t *entry);
#if defined(c_plusplus) || defined(__cplusplus) #if defined(c_plusplus) || defined(__cplusplus)
} }
#endif #endif

Просмотреть файл

@ -42,7 +42,7 @@ int MPI_Info_create(MPI_Info *info) {
* allocates the space for MPI_Info, but also calls all the * allocates the space for MPI_Info, but also calls all the
* relevant init functions. * relevant init functions.
*/ */
(*info) = OBJ_CREATE(lam_info_t, &lam_info_cls); (*info) = OBJ_NEW(lam_info_t);
if (NULL == (*info)) { if (NULL == (*info)) {
printf ("Malloc failed. Ran out of resources\n"); 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); free(old_info->ie_value);
old_info->ie_value = new_value; old_info->ie_value = new_value;
} else { } 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) { if (NULL == new_info) {
printf ("Unable to malloc memory for new (key, value) pair\n"); printf ("Unable to malloc memory for new (key, value) pair\n");
return MPI_ERR_SYSRESOURCE; return MPI_ERR_SYSRESOURCE;

Просмотреть файл

@ -7,22 +7,22 @@ static lam_mutex_t lam_proc_lock;
lam_proc_t* lam_proc_self = 0; 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_proc_t",
&lam_list_cls, CLASS_INFO(lam_list_t),
(class_init_t)lam_proc_init, (lam_construct_t)lam_proc_construct,
(class_destroy_t)lam_proc_destroy (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; static int init = 0;
if(init++ == 0) { if(init++ == 0) {
lam_list_init(&lam_proc_list); lam_list_construct(&lam_proc_list);
lam_mutex_init(&lam_proc_lock); 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_job = 0;
proc->proc_vpid = 0; proc->proc_vpid = 0;
proc->proc_pml = 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); THREAD_LOCK(&lam_proc_lock);
lam_list_remove_item(&lam_proc_list, (lam_list_item_t*)proc); lam_list_remove_item(&lam_proc_list, (lam_list_item_t*)proc);
THREAD_UNLOCK(&lam_proc_lock); 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" #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 { struct lam_proc_t {
@ -30,8 +30,8 @@ struct lam_proc_t {
typedef struct lam_proc_t lam_proc_t; typedef struct lam_proc_t lam_proc_t;
void lam_proc_init(lam_proc_t*); void lam_proc_construct(lam_proc_t*);
void lam_proc_destroy(lam_proc_t*); void lam_proc_destruct(lam_proc_t*);
static inline lam_proc_t* lam_proc_local(void) static inline lam_proc_t* lam_proc_local(void)
{ {

Просмотреть файл

@ -4,23 +4,23 @@
#include "mpi/request/request.h" #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_request_t",
&lam_object_cls, CLASS_INFO(lam_object_t),
(class_init_t) lam_request_init, (lam_construct_t) lam_request_construct,
(class_destroy_t) lam_request_destroy, (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" #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 { typedef enum {
LAM_REQUEST_PML, LAM_REQUEST_PML,
@ -24,8 +24,8 @@ struct lam_request_t {
}; };
typedef struct lam_request_t lam_request_t; typedef struct lam_request_t lam_request_t;
void lam_request_init(lam_request_t*); void lam_request_construct(lam_request_t*);
void lam_request_destroy(lam_request_t*); void lam_request_destruct(lam_request_t*);
#endif #endif

Просмотреть файл

@ -111,7 +111,7 @@ void test_dynamic()
{ {
lam_fast_hash_t *table; 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 ) if ( NULL == table )
{ {
printf("Error: Unable to create hash table.\n"); printf("Error: Unable to create hash table.\n");
@ -128,12 +128,12 @@ void test_static()
{ {
lam_fast_hash_t table; 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"); printf("Testing with statically created table...\n");
test_htable(&table); test_htable(&table);
STATIC_DESTROY(table); OBJ_DESTRUCT(&table);
} }

Просмотреть файл

@ -30,7 +30,7 @@ int main(int argc, char **argv)
/* initialize list */ /* initialize list */
lam_list_set_size(&list,0Xdeadbeaf); lam_list_set_size(&list,0Xdeadbeaf);
lam_list_init(&list); lam_list_construct(&list);
/* check length of list */ /* check length of list */
list_size=lam_list_get_size(&list); list_size=lam_list_get_size(&list);