- Reduce the amount of warnings with -Wshadow -- mainly due to
usage of index and abs in inline-fcts in header files. This commit was SVN r13217.
Этот коммит содержится в:
родитель
e934272f3e
Коммит
125ba1acfa
@ -114,7 +114,7 @@ typedef struct ompi_cb_fifo_t ompi_cb_fifo_t;
|
|||||||
static inline void *ompi_cb_fifo_read_from_tail(ompi_cb_fifo_t *fifo,
|
static inline void *ompi_cb_fifo_read_from_tail(ompi_cb_fifo_t *fifo,
|
||||||
bool flush_entries_read, bool *queue_empty, ptrdiff_t offset)
|
bool flush_entries_read, bool *queue_empty, ptrdiff_t offset)
|
||||||
{
|
{
|
||||||
int index = 0,clearIndex, i;
|
int old_fifo_index, clearIndex, i;
|
||||||
void **q_ptr;
|
void **q_ptr;
|
||||||
ompi_cb_fifo_ctl_t *h_ptr, *t_ptr;
|
ompi_cb_fifo_ctl_t *h_ptr, *t_ptr;
|
||||||
void *read_from_tail = (void *)OMPI_CB_ERROR;
|
void *read_from_tail = (void *)OMPI_CB_ERROR;
|
||||||
@ -133,8 +133,8 @@ static inline void *ompi_cb_fifo_read_from_tail(ompi_cb_fifo_t *fifo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set return data */
|
/* set return data */
|
||||||
index = t_ptr->fifo_index;
|
old_fifo_index = t_ptr->fifo_index;
|
||||||
read_from_tail = (void *)q_ptr[index];
|
read_from_tail = (void *)q_ptr[old_fifo_index];
|
||||||
opal_atomic_rmb();
|
opal_atomic_rmb();
|
||||||
t_ptr->num_to_clear++;
|
t_ptr->num_to_clear++;
|
||||||
|
|
||||||
@ -145,7 +145,7 @@ static inline void *ompi_cb_fifo_read_from_tail(ompi_cb_fifo_t *fifo,
|
|||||||
/* check to see if time to do a lazy free of queue slots */
|
/* check to see if time to do a lazy free of queue slots */
|
||||||
if ( (t_ptr->num_to_clear == fifo->lazy_free_frequency) ||
|
if ( (t_ptr->num_to_clear == fifo->lazy_free_frequency) ||
|
||||||
flush_entries_read ) {
|
flush_entries_read ) {
|
||||||
clearIndex = index - t_ptr->num_to_clear + 1;
|
clearIndex = old_fifo_index - t_ptr->num_to_clear + 1;
|
||||||
clearIndex &= fifo->mask;
|
clearIndex &= fifo->mask;
|
||||||
|
|
||||||
for (i = 0; i < t_ptr->num_to_clear; i++) {
|
for (i = 0; i < t_ptr->num_to_clear; i++) {
|
||||||
@ -213,7 +213,7 @@ static inline int ompi_cb_fifo_init_same_base_addr(int size_of_fifo,
|
|||||||
int errorCode = OMPI_SUCCESS,i;
|
int errorCode = OMPI_SUCCESS,i;
|
||||||
size_t len_to_allocate;
|
size_t len_to_allocate;
|
||||||
|
|
||||||
/* verify that size is power of 2, and greatter that 0 - if not,
|
/* verify that size is power of 2, and greater than 0 - if not,
|
||||||
* round up */
|
* round up */
|
||||||
if ( 0 >= size_of_fifo) {
|
if ( 0 >= size_of_fifo) {
|
||||||
return OMPI_ERROR;
|
return OMPI_ERROR;
|
||||||
@ -365,14 +365,20 @@ static inline int ompi_cb_fifo_write_to_head_same_base_addr(void *data, ompi_cb_
|
|||||||
{
|
{
|
||||||
volatile void **ptr;
|
volatile void **ptr;
|
||||||
ompi_cb_fifo_ctl_t *h_ptr;
|
ompi_cb_fifo_ctl_t *h_ptr;
|
||||||
int slot = OMPI_CB_ERROR, index;
|
int slot = OMPI_CB_ERROR;
|
||||||
|
int old_fifo_index;
|
||||||
|
|
||||||
h_ptr=fifo->head;
|
h_ptr=fifo->head;
|
||||||
index = h_ptr->fifo_index;
|
|
||||||
/* make sure the head is pointing at a free element */
|
|
||||||
ptr=fifo->queue;
|
ptr=fifo->queue;
|
||||||
if (ptr[index] == OMPI_CB_FREE) {
|
old_fifo_index = h_ptr->fifo_index;
|
||||||
slot = index;
|
|
||||||
|
/*
|
||||||
|
* What about turning around the logic?
|
||||||
|
* This is called for every sm fragment and twice when the circular buffer is full...
|
||||||
|
*/
|
||||||
|
/* make sure the head is pointing at a free element */
|
||||||
|
if (ptr[old_fifo_index] == OMPI_CB_FREE) {
|
||||||
|
slot = old_fifo_index;
|
||||||
opal_atomic_wmb();
|
opal_atomic_wmb();
|
||||||
ptr[slot] = data;
|
ptr[slot] = data;
|
||||||
(h_ptr->fifo_index)++;
|
(h_ptr->fifo_index)++;
|
||||||
@ -399,21 +405,22 @@ static inline int ompi_cb_fifo_get_slot_same_base_addr(ompi_cb_fifo_t *fifo)
|
|||||||
{
|
{
|
||||||
volatile void **ptr;
|
volatile void **ptr;
|
||||||
ompi_cb_fifo_ctl_t *h_ptr;
|
ompi_cb_fifo_ctl_t *h_ptr;
|
||||||
int return_value = OMPI_CB_ERROR,index;
|
int slot = OMPI_CB_ERROR;
|
||||||
|
int old_fifo_index;
|
||||||
|
|
||||||
h_ptr=fifo->head;
|
h_ptr=fifo->head;
|
||||||
ptr=fifo->queue;
|
ptr=fifo->queue;
|
||||||
index = h_ptr->fifo_index;
|
old_fifo_index = h_ptr->fifo_index;
|
||||||
/* try and reserve slot */
|
/* try and reserve slot */
|
||||||
if ( OMPI_CB_FREE == ptr[index] ) {
|
if ( OMPI_CB_FREE == ptr[old_fifo_index] ) {
|
||||||
ptr[index] = OMPI_CB_RESERVED;
|
slot = old_fifo_index;
|
||||||
return_value = index;
|
ptr[old_fifo_index] = OMPI_CB_RESERVED;
|
||||||
(h_ptr->fifo_index)++;
|
(h_ptr->fifo_index)++;
|
||||||
(h_ptr->fifo_index) &= fifo->mask;
|
(h_ptr->fifo_index) &= fifo->mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return */
|
/* return */
|
||||||
return return_value;
|
return slot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -435,7 +442,7 @@ static inline void *ompi_cb_fifo_read_from_tail_same_base_addr(
|
|||||||
ompi_cb_fifo_t *fifo,
|
ompi_cb_fifo_t *fifo,
|
||||||
bool flush_entries_read, bool *queue_empty)
|
bool flush_entries_read, bool *queue_empty)
|
||||||
{
|
{
|
||||||
int index = 0,clearIndex, i;
|
int old_fifo_index, clearIndex, i;
|
||||||
volatile void **q_ptr;
|
volatile void **q_ptr;
|
||||||
ompi_cb_fifo_ctl_t *h_ptr, *t_ptr;
|
ompi_cb_fifo_ctl_t *h_ptr, *t_ptr;
|
||||||
void *read_from_tail = (void *)OMPI_CB_ERROR;
|
void *read_from_tail = (void *)OMPI_CB_ERROR;
|
||||||
@ -454,8 +461,8 @@ static inline void *ompi_cb_fifo_read_from_tail_same_base_addr(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set return data */
|
/* set return data */
|
||||||
index = t_ptr->fifo_index;
|
old_fifo_index = t_ptr->fifo_index;
|
||||||
read_from_tail = (void *)q_ptr[index];
|
read_from_tail = (void *)q_ptr[old_fifo_index];
|
||||||
opal_atomic_rmb();
|
opal_atomic_rmb();
|
||||||
t_ptr->num_to_clear++;
|
t_ptr->num_to_clear++;
|
||||||
|
|
||||||
@ -466,7 +473,7 @@ static inline void *ompi_cb_fifo_read_from_tail_same_base_addr(
|
|||||||
/* check to see if time to do a lazy free of queue slots */
|
/* check to see if time to do a lazy free of queue slots */
|
||||||
if ( (t_ptr->num_to_clear == fifo->lazy_free_frequency) ||
|
if ( (t_ptr->num_to_clear == fifo->lazy_free_frequency) ||
|
||||||
flush_entries_read ) {
|
flush_entries_read ) {
|
||||||
clearIndex = index - t_ptr->num_to_clear + 1;
|
clearIndex = old_fifo_index - t_ptr->num_to_clear + 1;
|
||||||
clearIndex &= fifo->mask;
|
clearIndex &= fifo->mask;
|
||||||
|
|
||||||
for (i = 0; i < t_ptr->num_to_clear; i++) {
|
for (i = 0; i < t_ptr->num_to_clear; i++) {
|
||||||
|
@ -96,21 +96,21 @@ OMPI_DECLSPEC int ompi_pointer_array_set_item(ompi_pointer_array_t *array,
|
|||||||
* Get the value of an element in array
|
* Get the value of an element in array
|
||||||
*
|
*
|
||||||
* @param array Pointer to array (IN)
|
* @param array Pointer to array (IN)
|
||||||
* @param index Index of element to be returned (IN)
|
* @param element_index Index of element to be returned (IN)
|
||||||
*
|
*
|
||||||
* @return Error code. NULL indicates an error.
|
* @return Error code. NULL indicates an error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void *ompi_pointer_array_get_item(ompi_pointer_array_t *table,
|
static inline void *ompi_pointer_array_get_item(ompi_pointer_array_t *table,
|
||||||
int index)
|
int element_index)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
if( table->size <= index ) {
|
if( table->size <= element_index ) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
OPAL_THREAD_LOCK(&(table->lock));
|
OPAL_THREAD_LOCK(&(table->lock));
|
||||||
p = table->addr[index];
|
p = table->addr[element_index];
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
@ -277,15 +277,15 @@ OMPI_DECLSPEC int ompi_ddt_safeguard_pointer_debug_breakpoint( const void* actua
|
|||||||
|
|
||||||
static inline int GET_FIRST_NON_LOOP( const dt_elem_desc_t* _pElem )
|
static inline int GET_FIRST_NON_LOOP( const dt_elem_desc_t* _pElem )
|
||||||
{
|
{
|
||||||
int index = 0;
|
int element_index = 0;
|
||||||
|
|
||||||
/* We dont have to check for the end as we always put an END_LOOP
|
/* We dont have to check for the end as we always put an END_LOOP
|
||||||
* at the end of all datatype descriptions.
|
* at the end of all datatype descriptions.
|
||||||
*/
|
*/
|
||||||
while( _pElem->elem.common.type == DT_LOOP ) {
|
while( _pElem->elem.common.type == DT_LOOP ) {
|
||||||
++_pElem; index++;
|
++_pElem; element_index++;
|
||||||
}
|
}
|
||||||
return index;
|
return element_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UPDATE_INTERNAL_COUNTERS( DESCRIPTION, POSITION, ELEMENT, COUNTER ) \
|
#define UPDATE_INTERNAL_COUNTERS( DESCRIPTION, POSITION, ELEMENT, COUNTER ) \
|
||||||
|
@ -741,7 +741,8 @@ static int rebuild_communicator_list (mqs_process *proc)
|
|||||||
mqs_image * image = mqs_get_image (proc);
|
mqs_image * image = mqs_get_image (proc);
|
||||||
mpi_image_info *i_info = (mpi_image_info *)mqs_get_image_info (image);
|
mpi_image_info *i_info = (mpi_image_info *)mqs_get_image_info (image);
|
||||||
communicator_t **commp, *old;
|
communicator_t **commp, *old;
|
||||||
int commcount = 0, i;
|
int commcount = 0;
|
||||||
|
int i;
|
||||||
mqs_tword_t comm_size;
|
mqs_tword_t comm_size;
|
||||||
mqs_taddr_t comm_addr_base = p_info->commlist_base + i_info->ompi_pointer_array_t.offset.addr;
|
mqs_taddr_t comm_addr_base = p_info->commlist_base + i_info->ompi_pointer_array_t.offset.addr;
|
||||||
mqs_taddr_t comm_ptr;
|
mqs_taddr_t comm_ptr;
|
||||||
@ -826,7 +827,7 @@ static int rebuild_communicator_list (mqs_process *proc)
|
|||||||
communicator_t ** comm_array =
|
communicator_t ** comm_array =
|
||||||
(communicator_t **) mqs_malloc(commcount * sizeof (communicator_t *));
|
(communicator_t **) mqs_malloc(commcount * sizeof (communicator_t *));
|
||||||
communicator_t *comm = p_info->communicator_list;
|
communicator_t *comm = p_info->communicator_list;
|
||||||
int i;
|
|
||||||
for (i=0; i<commcount; i++, comm=comm->next)
|
for (i=0; i<commcount; i++, comm=comm->next)
|
||||||
comm_array [i] = comm;
|
comm_array [i] = comm;
|
||||||
|
|
||||||
|
@ -170,25 +170,26 @@ static inline bool mca_bml_base_btl_array_remove( mca_bml_base_btl_array_t* arra
|
|||||||
* Return an array item at the specified index.
|
* Return an array item at the specified index.
|
||||||
*
|
*
|
||||||
* @param array (IN)
|
* @param array (IN)
|
||||||
* @param index (IN)
|
* @param item_index (IN)
|
||||||
*/
|
*/
|
||||||
static inline mca_bml_base_btl_t* mca_bml_base_btl_array_get_index(mca_bml_base_btl_array_t* array, size_t index)
|
static inline mca_bml_base_btl_t* mca_bml_base_btl_array_get_index(mca_bml_base_btl_array_t* array, size_t item_index)
|
||||||
{
|
{
|
||||||
#if OMPI_ENABLE_DEBUG
|
#if OMPI_ENABLE_DEBUG
|
||||||
if(index >= array->arr_size) {
|
if(item_index >= array->arr_size) {
|
||||||
opal_output(0, "mca_bml_base_btl_array_get_index: invalid array index %d >= %d",
|
opal_output(0, "mca_bml_base_btl_array_get_index: invalid array index %d >= %d",
|
||||||
index, array->arr_size);
|
item_index, array->arr_size);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return &array->bml_btls[index];
|
return &array->bml_btls[item_index];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the next LRU index in the array.
|
* Return the next LRU index in the array.
|
||||||
*
|
*
|
||||||
* @param array (IN)
|
* @param array (IN)
|
||||||
* @param index (IN)
|
*
|
||||||
|
* @param index (OUT)
|
||||||
*/
|
*/
|
||||||
static inline mca_bml_base_btl_t* mca_bml_base_btl_array_get_next(mca_bml_base_btl_array_t* array)
|
static inline mca_bml_base_btl_t* mca_bml_base_btl_array_get_next(mca_bml_base_btl_array_t* array)
|
||||||
{
|
{
|
||||||
|
@ -512,9 +512,9 @@ int mca_bml_r2_del_procs(size_t nprocs,
|
|||||||
*/
|
*/
|
||||||
n_size = mca_bml_base_btl_array_get_size(&bml_endpoint->btl_eager);
|
n_size = mca_bml_base_btl_array_get_size(&bml_endpoint->btl_eager);
|
||||||
for(n_index = 0; n_index < n_size; n_index++) {
|
for(n_index = 0; n_index < n_size; n_index++) {
|
||||||
mca_bml_base_btl_t* bml_btl = mca_bml_base_btl_array_get_index(&bml_endpoint->btl_send, n_index);
|
mca_bml_base_btl_t* search_bml_btl = mca_bml_base_btl_array_get_index(&bml_endpoint->btl_send, n_index);
|
||||||
if(bml_btl->btl == btl) {
|
if(search_bml_btl->btl == btl) {
|
||||||
memset(bml_btl, 0, sizeof(mca_bml_base_btl_t));
|
memset(search_bml_btl, 0, sizeof(mca_bml_base_btl_t));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,23 +83,23 @@ int MPI_Accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_data
|
|||||||
if (ompi_ddt_is_predefined(origin_datatype)) {
|
if (ompi_ddt_is_predefined(origin_datatype)) {
|
||||||
origin_check_dt = origin_datatype;
|
origin_check_dt = origin_datatype;
|
||||||
} else {
|
} else {
|
||||||
int i, index = -1, num_found = 0;
|
int i, found_index = -1, num_found = 0;
|
||||||
uint64_t mask = 1;
|
uint64_t mask = 1;
|
||||||
|
|
||||||
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
|
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
|
||||||
if (origin_datatype->bdt_used & mask) {
|
if (origin_datatype->bdt_used & mask) {
|
||||||
num_found++;
|
num_found++;
|
||||||
index = i;
|
found_index = i;
|
||||||
}
|
}
|
||||||
mask *= 2;
|
mask *= 2;
|
||||||
}
|
}
|
||||||
if (index < 0 || num_found > 1) {
|
if (found_index < 0 || num_found > 1) {
|
||||||
/* this is an erroneous datatype. Let
|
/* this is an erroneous datatype. Let
|
||||||
ompi_op_is_valid tell the user that */
|
ompi_op_is_valid tell the user that */
|
||||||
OMPI_ERRHANDLER_RETURN(MPI_ERR_TYPE, win, MPI_ERR_TYPE, FUNC_NAME);
|
OMPI_ERRHANDLER_RETURN(MPI_ERR_TYPE, win, MPI_ERR_TYPE, FUNC_NAME);
|
||||||
} else {
|
} else {
|
||||||
origin_check_dt = (ompi_datatype_t*)
|
origin_check_dt = (ompi_datatype_t*)
|
||||||
ompi_ddt_basicDatatypes[index];
|
ompi_ddt_basicDatatypes[found_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,17 +116,17 @@ int MPI_Accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_data
|
|||||||
if (ompi_ddt_is_predefined(target_datatype)) {
|
if (ompi_ddt_is_predefined(target_datatype)) {
|
||||||
op_check_dt = target_datatype;
|
op_check_dt = target_datatype;
|
||||||
} else {
|
} else {
|
||||||
int i, index = -1, num_found = 0;
|
int i, found_index = -1, num_found = 0;
|
||||||
uint64_t mask = 1;
|
uint64_t mask = 1;
|
||||||
|
|
||||||
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
|
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
|
||||||
if (target_datatype->bdt_used & mask) {
|
if (target_datatype->bdt_used & mask) {
|
||||||
num_found++;
|
num_found++;
|
||||||
index = i;
|
found_index = i;
|
||||||
}
|
}
|
||||||
mask *= 2;
|
mask *= 2;
|
||||||
}
|
}
|
||||||
if (index < 0 || num_found > 1) {
|
if (found_index < 0 || num_found > 1) {
|
||||||
/* this is an erroneous datatype. Let
|
/* this is an erroneous datatype. Let
|
||||||
ompi_op_is_valid tell the user that */
|
ompi_op_is_valid tell the user that */
|
||||||
OMPI_ERRHANDLER_RETURN(MPI_ERR_TYPE, win, MPI_ERR_TYPE, FUNC_NAME);
|
OMPI_ERRHANDLER_RETURN(MPI_ERR_TYPE, win, MPI_ERR_TYPE, FUNC_NAME);
|
||||||
@ -136,7 +136,7 @@ int MPI_Accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_data
|
|||||||
op? Unfortunately have to cast away
|
op? Unfortunately have to cast away
|
||||||
constness... */
|
constness... */
|
||||||
op_check_dt = (ompi_datatype_t*)
|
op_check_dt = (ompi_datatype_t*)
|
||||||
ompi_ddt_basicDatatypes[index];
|
ompi_ddt_basicDatatypes[found_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,17 +181,17 @@ int MPI_Accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_data
|
|||||||
if (ompi_ddt_is_predefined(target_datatype)) {
|
if (ompi_ddt_is_predefined(target_datatype)) {
|
||||||
op_check_dt = target_datatype;
|
op_check_dt = target_datatype;
|
||||||
} else {
|
} else {
|
||||||
int i, index = -1, num_found = 0;
|
int i, found_index = -1, num_found = 0;
|
||||||
uint64_t mask = 1;
|
uint64_t mask = 1;
|
||||||
|
|
||||||
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
|
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
|
||||||
if (target_datatype->bdt_used & mask) {
|
if (target_datatype->bdt_used & mask) {
|
||||||
num_found++;
|
num_found++;
|
||||||
index = i;
|
found_index = i;
|
||||||
}
|
}
|
||||||
mask *= 2;
|
mask *= 2;
|
||||||
}
|
}
|
||||||
if (index < 0 || num_found > 1) {
|
if (found_index < 0 || num_found > 1) {
|
||||||
/* this is an erroneous datatype. Let
|
/* this is an erroneous datatype. Let
|
||||||
ompi_op_is_valid tell the user that */
|
ompi_op_is_valid tell the user that */
|
||||||
op_check_dt = target_datatype;
|
op_check_dt = target_datatype;
|
||||||
@ -201,7 +201,7 @@ int MPI_Accumulate(void *origin_addr, int origin_count, MPI_Datatype origin_data
|
|||||||
op? Unfortunately have to cast away
|
op? Unfortunately have to cast away
|
||||||
constness... */
|
constness... */
|
||||||
op_check_dt = (ompi_datatype_t*)
|
op_check_dt = (ompi_datatype_t*)
|
||||||
ompi_ddt_basicDatatypes[index];
|
ompi_ddt_basicDatatypes[found_index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!ompi_op_is_valid(op, op_check_dt, &msg, FUNC_NAME)) {
|
if (!ompi_op_is_valid(op, op_check_dt, &msg, FUNC_NAME)) {
|
||||||
|
@ -150,19 +150,19 @@ OPAL_DECLSPEC int opal_value_array_set_size(opal_value_array_t* array, size_t si
|
|||||||
* Retrieve an item from the array by reference.
|
* Retrieve an item from the array by reference.
|
||||||
*
|
*
|
||||||
* @param array The input array (IN).
|
* @param array The input array (IN).
|
||||||
* @param index The array index (IN).
|
* @param item_index The array index (IN).
|
||||||
*
|
*
|
||||||
* @return ptr Pointer to the requested item.
|
* @return ptr Pointer to the requested item.
|
||||||
*
|
*
|
||||||
* Note that if the specified index is larger than the current
|
* Note that if the specified item_index is larger than the current
|
||||||
* array size, the array is grown to satisfy the request.
|
* array size, the array is grown to satisfy the request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void* opal_value_array_get_item(opal_value_array_t *array, size_t index)
|
static inline void* opal_value_array_get_item(opal_value_array_t *array, size_t item_index)
|
||||||
{
|
{
|
||||||
if(index >= array->array_size && opal_value_array_set_size(array, index+1) != OPAL_SUCCESS)
|
if(item_index >= array->array_size && opal_value_array_set_size(array, item_index+1) != OPAL_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
return array->array_items + (index * array->array_item_sizeof);
|
return array->array_items + (item_index * array->array_item_sizeof);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,13 +198,13 @@ static inline void* opal_value_array_get_item(opal_value_array_t *array, size_t
|
|||||||
* copied into the array by value.
|
* copied into the array by value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline int opal_value_array_set_item(opal_value_array_t *array, size_t index, const void* item)
|
static inline int opal_value_array_set_item(opal_value_array_t *array, size_t item_index, const void* item)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
if(index >= array->array_size &&
|
if(item_index >= array->array_size &&
|
||||||
(rc = opal_value_array_set_size(array, index+1)) != OPAL_SUCCESS)
|
(rc = opal_value_array_set_size(array, item_index+1)) != OPAL_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
memcpy(array->array_items + (index * array->array_item_sizeof), item, array->array_item_sizeof);
|
memcpy(array->array_items + (item_index * array->array_item_sizeof), item, array->array_item_sizeof);
|
||||||
return OPAL_SUCCESS;
|
return OPAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ static inline int opal_value_array_append_item(opal_value_array_t *array, const
|
|||||||
* Remove a specific item from the array.
|
* Remove a specific item from the array.
|
||||||
*
|
*
|
||||||
* @param array The input array (IN).
|
* @param array The input array (IN).
|
||||||
* @param index The index to remove, which must be less than
|
* @param item_index The index to remove, which must be less than
|
||||||
* the current array size (IN).
|
* the current array size (IN).
|
||||||
*
|
*
|
||||||
* @return OMPI error code.
|
* @return OMPI error code.
|
||||||
@ -241,17 +241,17 @@ static inline int opal_value_array_append_item(opal_value_array_t *array, const
|
|||||||
* All elements following this index are shifted down.
|
* All elements following this index are shifted down.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline int opal_value_array_remove_item(opal_value_array_t *array, size_t index)
|
static inline int opal_value_array_remove_item(opal_value_array_t *array, size_t item_index)
|
||||||
{
|
{
|
||||||
#if OMPI_ENABLE_DEBUG
|
#if OMPI_ENABLE_DEBUG
|
||||||
if (index >= array->array_size) {
|
if (item_index >= array->array_size) {
|
||||||
opal_output(0, "opal_value_array_remove_item: invalid index %d\n", index);
|
opal_output(0, "opal_value_array_remove_item: invalid index %d\n", item_index);
|
||||||
return OPAL_ERR_BAD_PARAM;
|
return OPAL_ERR_BAD_PARAM;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
memmove(array->array_items+(array->array_item_sizeof * index),
|
memmove(array->array_items+(array->array_item_sizeof * item_index),
|
||||||
array->array_items+(array->array_item_sizeof * (index+1)),
|
array->array_items+(array->array_item_sizeof * (item_index+1)),
|
||||||
array->array_item_sizeof * (array->array_size - index - 1));
|
array->array_item_sizeof * (array->array_size - item_index - 1));
|
||||||
array->array_size--;
|
array->array_size--;
|
||||||
return OPAL_SUCCESS;
|
return OPAL_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
|
|||||||
const struct timespec *abstime)
|
const struct timespec *abstime)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
struct timeval abs;
|
struct timeval absolute;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
c->c_waiting++;
|
c->c_waiting++;
|
||||||
@ -99,12 +99,12 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
|
|||||||
#if OMPI_HAVE_POSIX_THREADS && OMPI_ENABLE_PROGRESS_THREADS
|
#if OMPI_HAVE_POSIX_THREADS && OMPI_ENABLE_PROGRESS_THREADS
|
||||||
rc = pthread_cond_timedwait(&c->c_cond, &m->m_lock_pthread, abstime);
|
rc = pthread_cond_timedwait(&c->c_cond, &m->m_lock_pthread, abstime);
|
||||||
#else
|
#else
|
||||||
abs.tv_sec = abstime->tv_sec;
|
absolute.tv_sec = abstime->tv_sec;
|
||||||
abs.tv_usec = abstime->tv_nsec * 1000;
|
absolute.tv_usec = abstime->tv_nsec * 1000;
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
while (c->c_signaled == 0 &&
|
while (c->c_signaled == 0 &&
|
||||||
(tv.tv_sec <= abs.tv_sec ||
|
(tv.tv_sec <= absolute.tv_sec ||
|
||||||
(tv.tv_sec == abs.tv_sec && tv.tv_usec < abs.tv_usec))) {
|
(tv.tv_sec == absolute.tv_sec && tv.tv_usec < absolute.tv_usec))) {
|
||||||
opal_mutex_unlock(m);
|
opal_mutex_unlock(m);
|
||||||
opal_progress();
|
opal_progress();
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
@ -112,12 +112,12 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
abs.tv_sec = abstime->tv_sec;
|
absolute.tv_sec = abstime->tv_sec;
|
||||||
abs.tv_usec = abstime->tv_nsec * 1000;
|
absolute.tv_usec = abstime->tv_nsec * 1000;
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
while (c->c_signaled == 0 &&
|
while (c->c_signaled == 0 &&
|
||||||
(tv.tv_sec <= abs.tv_sec ||
|
(tv.tv_sec <= absolute.tv_sec ||
|
||||||
(tv.tv_sec == abs.tv_sec && tv.tv_usec < abs.tv_usec))) {
|
(tv.tv_sec == absolute.tv_sec && tv.tv_usec < absolute.tv_usec))) {
|
||||||
opal_progress();
|
opal_progress();
|
||||||
gettimeofday(&tv,NULL);
|
gettimeofday(&tv,NULL);
|
||||||
}
|
}
|
||||||
@ -143,6 +143,8 @@ static inline int opal_condition_signal(opal_condition_t *c)
|
|||||||
static inline int opal_condition_broadcast(opal_condition_t *c)
|
static inline int opal_condition_broadcast(opal_condition_t *c)
|
||||||
{
|
{
|
||||||
c->c_signaled = c->c_waiting;
|
c->c_signaled = c->c_waiting;
|
||||||
|
/* Should be amended for the case, when we do not have Posix-Threads
|
||||||
|
but do have a progress Thread */
|
||||||
#if OMPI_HAVE_POSIX_THREADS && OMPI_ENABLE_PROGRESS_THREADS
|
#if OMPI_HAVE_POSIX_THREADS && OMPI_ENABLE_PROGRESS_THREADS
|
||||||
if(opal_using_threads()) {
|
if(opal_using_threads()) {
|
||||||
if( 1 == c->c_waiting ) {
|
if( 1 == c->c_waiting ) {
|
||||||
|
@ -117,7 +117,7 @@ int orte_pointer_array_init(orte_pointer_array_t **array,
|
|||||||
*/
|
*/
|
||||||
int orte_pointer_array_add(orte_std_cntr_t *location, orte_pointer_array_t *table, void *ptr)
|
int orte_pointer_array_add(orte_std_cntr_t *location, orte_pointer_array_t *table, void *ptr)
|
||||||
{
|
{
|
||||||
orte_std_cntr_t i, index;
|
orte_std_cntr_t i, element_index;
|
||||||
|
|
||||||
if (0) {
|
if (0) {
|
||||||
opal_output(0,"orte_pointer_array_add: IN: "
|
opal_output(0,"orte_pointer_array_add: IN: "
|
||||||
@ -151,9 +151,9 @@ int orte_pointer_array_add(orte_std_cntr_t *location, orte_pointer_array_t *tabl
|
|||||||
* add pointer to table, and return the index
|
* add pointer to table, and return the index
|
||||||
*/
|
*/
|
||||||
|
|
||||||
index = table->lowest_free;
|
element_index = table->lowest_free;
|
||||||
assert(table->addr[index] == NULL);
|
assert(table->addr[element_index] == NULL);
|
||||||
table->addr[index] = ptr;
|
table->addr[element_index] = ptr;
|
||||||
table->number_free--;
|
table->number_free--;
|
||||||
if (table->number_free > 0) {
|
if (table->number_free > 0) {
|
||||||
for (i = table->lowest_free + 1; i < table->size; i++) {
|
for (i = table->lowest_free + 1; i < table->size; i++) {
|
||||||
@ -172,11 +172,11 @@ int orte_pointer_array_add(orte_std_cntr_t *location, orte_pointer_array_t *tabl
|
|||||||
" table %p (size %ld, lowest free %ld, number free %ld)"
|
" table %p (size %ld, lowest free %ld, number free %ld)"
|
||||||
" addr[%d] = %p\n",
|
" addr[%d] = %p\n",
|
||||||
table, table->size, table->lowest_free, table->number_free,
|
table, table->size, table->lowest_free, table->number_free,
|
||||||
index, ptr);
|
element_index, ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
*location = index;
|
*location = element_index;
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ int orte_pointer_array_add(orte_std_cntr_t *location, orte_pointer_array_t *tabl
|
|||||||
*
|
*
|
||||||
* Assumption: NULL element is free element.
|
* Assumption: NULL element is free element.
|
||||||
*/
|
*/
|
||||||
int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t index,
|
int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t element_index,
|
||||||
void * value)
|
void * value)
|
||||||
{
|
{
|
||||||
assert(table != NULL);
|
assert(table != NULL);
|
||||||
@ -201,13 +201,13 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
|
|||||||
" table %p (size %ld, lowest free %ld, number free %ld)"
|
" table %p (size %ld, lowest free %ld, number free %ld)"
|
||||||
" addr[%d] = %p\n",
|
" addr[%d] = %p\n",
|
||||||
table, table->size, table->lowest_free, table->number_free,
|
table, table->size, table->lowest_free, table->number_free,
|
||||||
index, table->addr[index]);
|
element_index, table->addr[element_index]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* expand table if required to set a specific index */
|
/* expand table if required to set a specific index */
|
||||||
|
|
||||||
OPAL_THREAD_LOCK(&(table->lock));
|
OPAL_THREAD_LOCK(&(table->lock));
|
||||||
if (table->size <= index) {
|
if (table->size <= element_index) {
|
||||||
if (!grow_table(table)) {
|
if (!grow_table(table)) {
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
return ORTE_ERROR;
|
return ORTE_ERROR;
|
||||||
@ -218,22 +218,22 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
|
|||||||
* allow a specific index to be changed.
|
* allow a specific index to be changed.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ( NULL == table->addr[index] ) {
|
if ( NULL == table->addr[element_index] ) {
|
||||||
table->addr[index] = value;
|
table->addr[element_index] = value;
|
||||||
/* mark element as free, if NULL element */
|
/* mark element as free, if NULL element */
|
||||||
if( NULL == value ) {
|
if( NULL == value ) {
|
||||||
if (index < table->lowest_free) {
|
if (element_index < table->lowest_free) {
|
||||||
table->lowest_free = index;
|
table->lowest_free = element_index;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
table->number_free--;
|
table->number_free--;
|
||||||
/* Reset lowest_free if required */
|
/* Reset lowest_free if required */
|
||||||
if ( index == table->lowest_free ) {
|
if ( element_index == table->lowest_free ) {
|
||||||
orte_std_cntr_t i;
|
orte_std_cntr_t i;
|
||||||
|
|
||||||
table->lowest_free=table->size;
|
table->lowest_free=table->size;
|
||||||
for ( i=index; i<table->size; i++) {
|
for ( i=element_index; i<table->size; i++) {
|
||||||
if ( NULL == table->addr[i] ){
|
if ( NULL == table->addr[i] ){
|
||||||
table->lowest_free = i;
|
table->lowest_free = i;
|
||||||
break;
|
break;
|
||||||
@ -243,21 +243,21 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
table->addr[index] = value;
|
table->addr[element_index] = value;
|
||||||
/* mark element as free, if NULL element */
|
/* mark element as free, if NULL element */
|
||||||
if( NULL == value ) {
|
if( NULL == value ) {
|
||||||
if (index < table->lowest_free) {
|
if (element_index < table->lowest_free) {
|
||||||
table->lowest_free = index;
|
table->lowest_free = element_index;
|
||||||
}
|
}
|
||||||
table->number_free++;
|
table->number_free++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Reset lowest_free if required */
|
/* Reset lowest_free if required */
|
||||||
if ( index == table->lowest_free ) {
|
if ( element_index == table->lowest_free ) {
|
||||||
orte_std_cntr_t i;
|
orte_std_cntr_t i;
|
||||||
|
|
||||||
table->lowest_free=table->size;
|
table->lowest_free=table->size;
|
||||||
for ( i=index; i<table->size; i++) {
|
for ( i=element_index; i<table->size; i++) {
|
||||||
if ( NULL == table->addr[i] ){
|
if ( NULL == table->addr[i] ){
|
||||||
table->lowest_free = i;
|
table->lowest_free = i;
|
||||||
break;
|
break;
|
||||||
@ -273,7 +273,7 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
|
|||||||
" table %p (size %ld, lowest free %ld, number free %ld)"
|
" table %p (size %ld, lowest free %ld, number free %ld)"
|
||||||
" addr[%d] = %p\n",
|
" addr[%d] = %p\n",
|
||||||
table, table->size, table->lowest_free, table->number_free,
|
table, table->size, table->lowest_free, table->number_free,
|
||||||
index, table->addr[index]);
|
element_index, table->addr[element_index]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
@ -285,7 +285,7 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
|
|||||||
* in use, reserve it.
|
* in use, reserve it.
|
||||||
*
|
*
|
||||||
* @param array Pointer to array (IN)
|
* @param array Pointer to array (IN)
|
||||||
* @param index Index of element to be tested (IN)
|
* @param element_index Index of element to be tested (IN)
|
||||||
* @param value New value to be set at element index (IN)
|
* @param value New value to be set at element index (IN)
|
||||||
*
|
*
|
||||||
* @return true/false True if element could be reserved
|
* @return true/false True if element could be reserved
|
||||||
@ -295,7 +295,7 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
|
|||||||
* a value, unless the previous value is NULL ( equiv. to free ).
|
* a value, unless the previous value is NULL ( equiv. to free ).
|
||||||
*/
|
*/
|
||||||
bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
||||||
orte_std_cntr_t index, void *value)
|
orte_std_cntr_t element_index, void *value)
|
||||||
{
|
{
|
||||||
assert(table != NULL);
|
assert(table != NULL);
|
||||||
|
|
||||||
@ -304,12 +304,12 @@ bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
|||||||
" table %p (size %ld, lowest free %ld, number free %ld)"
|
" table %p (size %ld, lowest free %ld, number free %ld)"
|
||||||
" addr[%d] = %p\n",
|
" addr[%d] = %p\n",
|
||||||
table, table->size, table->lowest_free, table->number_free,
|
table, table->size, table->lowest_free, table->number_free,
|
||||||
index, table->addr[index]);
|
element_index, table->addr[element_index]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* expand table if required to set a specific index */
|
/* expand table if required to set a specific index */
|
||||||
OPAL_THREAD_LOCK(&(table->lock));
|
OPAL_THREAD_LOCK(&(table->lock));
|
||||||
if ( index < table->size && table->addr[index] != NULL ) {
|
if ( element_index < table->size && table->addr[element_index] != NULL ) {
|
||||||
/* This element is already in use */
|
/* This element is already in use */
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
return false;
|
return false;
|
||||||
@ -317,7 +317,7 @@ bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
|||||||
|
|
||||||
/* Do we need to grow the table? */
|
/* Do we need to grow the table? */
|
||||||
|
|
||||||
if (table->size <= index) {
|
if (table->size <= element_index) {
|
||||||
if (!grow_table(table)) {
|
if (!grow_table(table)) {
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
return false;
|
return false;
|
||||||
@ -327,14 +327,14 @@ bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
|||||||
/*
|
/*
|
||||||
* allow a specific index to be changed.
|
* allow a specific index to be changed.
|
||||||
*/
|
*/
|
||||||
table->addr[index] = value;
|
table->addr[element_index] = value;
|
||||||
table->number_free--;
|
table->number_free--;
|
||||||
/* Reset lowest_free if required */
|
/* Reset lowest_free if required */
|
||||||
if ( index == table->lowest_free ) {
|
if ( element_index == table->lowest_free ) {
|
||||||
orte_std_cntr_t i;
|
orte_std_cntr_t i;
|
||||||
|
|
||||||
table->lowest_free = table->size;
|
table->lowest_free = table->size;
|
||||||
for ( i=index; i<table->size; i++) {
|
for ( i=element_index; i<table->size; i++) {
|
||||||
if ( NULL == table->addr[i] ){
|
if ( NULL == table->addr[i] ){
|
||||||
table->lowest_free = i;
|
table->lowest_free = i;
|
||||||
break;
|
break;
|
||||||
@ -347,7 +347,7 @@ bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
|||||||
" table %p (size %ld, lowest free %ld, number free %ld)"
|
" table %p (size %ld, lowest free %ld, number free %ld)"
|
||||||
" addr[%d] = %p\n",
|
" addr[%d] = %p\n",
|
||||||
table, table->size, table->lowest_free, table->number_free,
|
table, table->size, table->lowest_free, table->number_free,
|
||||||
index, table->addr[index]);
|
element_index, table->addr[element_index]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
|
@ -97,36 +97,36 @@ ORTE_DECLSPEC int orte_pointer_array_init(orte_pointer_array_t **array,
|
|||||||
* @param (OUT) Index of inserted array element.
|
* @param (OUT) Index of inserted array element.
|
||||||
* @return Return value less than zero indicates an error.
|
* @return Return value less than zero indicates an error.
|
||||||
*/
|
*/
|
||||||
ORTE_DECLSPEC int orte_pointer_array_add(orte_std_cntr_t *index, orte_pointer_array_t *array, void *ptr);
|
ORTE_DECLSPEC int orte_pointer_array_add(orte_std_cntr_t *element_index, orte_pointer_array_t *array, void *ptr);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the value of an element in array
|
* Set the value of an element in array
|
||||||
* Automatically extend array if required.
|
* Automatically extend array if required.
|
||||||
*
|
*
|
||||||
* @param array Pointer to array (IN)
|
* @param array Pointer to array (IN)
|
||||||
* @param index Index of element to be reset (IN)
|
* @param element_index Index of element to be reset (IN)
|
||||||
* @param value New value to be set at element index (IN)
|
* @param value New value to be set at element index (IN)
|
||||||
*
|
*
|
||||||
* @return Error code. (-1) indicates an error.
|
* @return Error code. (-1) indicates an error.
|
||||||
*/
|
*/
|
||||||
ORTE_DECLSPEC int orte_pointer_array_set_item(orte_pointer_array_t *array,
|
ORTE_DECLSPEC int orte_pointer_array_set_item(orte_pointer_array_t *array,
|
||||||
orte_std_cntr_t index, void *value);
|
orte_std_cntr_t element_index, void *value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of an element in array
|
* Get the value of an element in array
|
||||||
*
|
*
|
||||||
* @param array Pointer to array (IN)
|
* @param array Pointer to array (IN)
|
||||||
* @param index Index of element to be returned (IN)
|
* @param element_index Index of element to be returned (IN)
|
||||||
*
|
*
|
||||||
* @return Error code. NULL indicates an error.
|
* @return Error code. NULL indicates an error.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void *orte_pointer_array_get_item(orte_pointer_array_t *table,
|
static inline void *orte_pointer_array_get_item(orte_pointer_array_t *table,
|
||||||
orte_std_cntr_t index)
|
orte_std_cntr_t element_index)
|
||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
OPAL_THREAD_LOCK(&(table->lock));
|
OPAL_THREAD_LOCK(&(table->lock));
|
||||||
p = table->addr[index];
|
p = table->addr[element_index];
|
||||||
OPAL_THREAD_UNLOCK(&(table->lock));
|
OPAL_THREAD_UNLOCK(&(table->lock));
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -211,7 +211,7 @@ static inline void orte_pointer_array_free_clear(orte_pointer_array_t *array)
|
|||||||
* in use, reserve it.
|
* in use, reserve it.
|
||||||
*
|
*
|
||||||
* @param array Pointer to array (IN)
|
* @param array Pointer to array (IN)
|
||||||
* @param index Index of element to be tested (IN)
|
* @param element_index Index of element to be tested (IN)
|
||||||
* @param value New value to be set at element index (IN)
|
* @param value New value to be set at element index (IN)
|
||||||
*
|
*
|
||||||
* @return true/false True if element could be reserved
|
* @return true/false True if element could be reserved
|
||||||
@ -221,7 +221,7 @@ static inline void orte_pointer_array_free_clear(orte_pointer_array_t *array)
|
|||||||
* a value, unless the previous value is NULL ( equiv. to free ).
|
* a value, unless the previous value is NULL ( equiv. to free ).
|
||||||
*/
|
*/
|
||||||
ORTE_DECLSPEC bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
ORTE_DECLSPEC bool orte_pointer_array_test_and_set_item (orte_pointer_array_t *table,
|
||||||
orte_std_cntr_t index,
|
orte_std_cntr_t element_index,
|
||||||
void *value);
|
void *value);
|
||||||
#if defined(c_plusplus) || defined(__cplusplus)
|
#if defined(c_plusplus) || defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ ORTE_DECLSPEC int orte_value_array_set_size(orte_value_array_t* array, orte_std_
|
|||||||
* Retrieve an item from the array by reference.
|
* Retrieve an item from the array by reference.
|
||||||
*
|
*
|
||||||
* @param array The input array (IN).
|
* @param array The input array (IN).
|
||||||
* @param index The array index (IN).
|
* @param item_index The array index (IN).
|
||||||
*
|
*
|
||||||
* @return ptr Pointer to the requested item.
|
* @return ptr Pointer to the requested item.
|
||||||
*
|
*
|
||||||
@ -158,11 +158,11 @@ ORTE_DECLSPEC int orte_value_array_set_size(orte_value_array_t* array, orte_std_
|
|||||||
* array size, the array is grown to satisfy the request.
|
* array size, the array is grown to satisfy the request.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline void* orte_value_array_get_item(orte_value_array_t *array, orte_std_cntr_t index)
|
static inline void* orte_value_array_get_item(orte_value_array_t *array, orte_std_cntr_t item_index)
|
||||||
{
|
{
|
||||||
if(index >= array->array_size && orte_value_array_set_size(array, index+1) != ORTE_SUCCESS)
|
if(item_index >= array->array_size && orte_value_array_set_size(array, item_index+1) != ORTE_SUCCESS)
|
||||||
return NULL;
|
return NULL;
|
||||||
return array->array_items + (index * array->array_item_sizeof);
|
return array->array_items + (item_index * array->array_item_sizeof);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,13 +198,13 @@ static inline void* orte_value_array_get_item(orte_value_array_t *array, orte_st
|
|||||||
* copied into the array by value.
|
* copied into the array by value.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline int orte_value_array_set_item(orte_value_array_t *array, orte_std_cntr_t index, const void* item)
|
static inline int orte_value_array_set_item(orte_value_array_t *array, orte_std_cntr_t item_index, const void* item)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
if(index >= array->array_size &&
|
if(item_index >= array->array_size &&
|
||||||
(rc = orte_value_array_set_size(array, index+1)) != ORTE_SUCCESS)
|
(rc = orte_value_array_set_size(array, item_index+1)) != ORTE_SUCCESS)
|
||||||
return rc;
|
return rc;
|
||||||
memcpy(array->array_items + (index * array->array_item_sizeof), item, array->array_item_sizeof);
|
memcpy(array->array_items + (item_index * array->array_item_sizeof), item, array->array_item_sizeof);
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ static inline int orte_value_array_append_item(orte_value_array_t *array, const
|
|||||||
* Remove a specific item from the array.
|
* Remove a specific item from the array.
|
||||||
*
|
*
|
||||||
* @param array The input array (IN).
|
* @param array The input array (IN).
|
||||||
* @param index The index to remove, which must be less than
|
* @param item_index The index to remove, which must be less than
|
||||||
* the current array size (IN).
|
* the current array size (IN).
|
||||||
*
|
*
|
||||||
* @return ORTE error code.
|
* @return ORTE error code.
|
||||||
@ -241,17 +241,17 @@ static inline int orte_value_array_append_item(orte_value_array_t *array, const
|
|||||||
* All elements following this index are shifted down.
|
* All elements following this index are shifted down.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static inline int orte_value_array_remove_item(orte_value_array_t *array, orte_std_cntr_t index)
|
static inline int orte_value_array_remove_item(orte_value_array_t *array, orte_std_cntr_t item_index)
|
||||||
{
|
{
|
||||||
#if OMPI_ENABLE_DEBUG
|
#if OMPI_ENABLE_DEBUG
|
||||||
if (index >= array->array_size) {
|
if (item_index >= array->array_size) {
|
||||||
opal_output(0, "orte_value_array_remove_item: invalid index %d\n", index);
|
opal_output(0, "orte_value_array_remove_item: invalid index %d\n", item_index);
|
||||||
return ORTE_ERR_BAD_PARAM;
|
return ORTE_ERR_BAD_PARAM;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
memmove(array->array_items+(array->array_item_sizeof * index),
|
memmove(array->array_items+(array->array_item_sizeof * item_index),
|
||||||
array->array_items+(array->array_item_sizeof * (index+1)),
|
array->array_items+(array->array_item_sizeof * (item_index+1)),
|
||||||
array->array_item_sizeof * (array->array_size - index - 1));
|
array->array_item_sizeof * (array->array_size - item_index - 1));
|
||||||
array->array_size--;
|
array->array_size--;
|
||||||
return ORTE_SUCCESS;
|
return ORTE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user