1
1

- 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.
Этот коммит содержится в:
Rainer Keller 2007-01-19 19:48:06 +00:00
родитель e934272f3e
Коммит 125ba1acfa
12 изменённых файлов: 153 добавлений и 142 удалений

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

@ -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,
bool flush_entries_read, bool *queue_empty, ptrdiff_t offset)
{
int index = 0,clearIndex, i;
int old_fifo_index, clearIndex, i;
void **q_ptr;
ompi_cb_fifo_ctl_t *h_ptr, *t_ptr;
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 */
index = t_ptr->fifo_index;
read_from_tail = (void *)q_ptr[index];
old_fifo_index = t_ptr->fifo_index;
read_from_tail = (void *)q_ptr[old_fifo_index];
opal_atomic_rmb();
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 */
if ( (t_ptr->num_to_clear == fifo->lazy_free_frequency) ||
flush_entries_read ) {
clearIndex = index - t_ptr->num_to_clear + 1;
clearIndex = old_fifo_index - t_ptr->num_to_clear + 1;
clearIndex &= fifo->mask;
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;
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 */
if ( 0 >= size_of_fifo) {
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;
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;
index = h_ptr->fifo_index;
/* make sure the head is pointing at a free element */
ptr=fifo->queue;
if (ptr[index] == OMPI_CB_FREE) {
slot = index;
old_fifo_index = h_ptr->fifo_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();
ptr[slot] = data;
(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;
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;
ptr=fifo->queue;
index = h_ptr->fifo_index;
old_fifo_index = h_ptr->fifo_index;
/* try and reserve slot */
if ( OMPI_CB_FREE == ptr[index] ) {
ptr[index] = OMPI_CB_RESERVED;
return_value = index;
if ( OMPI_CB_FREE == ptr[old_fifo_index] ) {
slot = old_fifo_index;
ptr[old_fifo_index] = OMPI_CB_RESERVED;
(h_ptr->fifo_index)++;
(h_ptr->fifo_index) &= fifo->mask;
}
/* 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,
bool flush_entries_read, bool *queue_empty)
{
int index = 0,clearIndex, i;
int old_fifo_index, clearIndex, i;
volatile void **q_ptr;
ompi_cb_fifo_ctl_t *h_ptr, *t_ptr;
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 */
index = t_ptr->fifo_index;
read_from_tail = (void *)q_ptr[index];
old_fifo_index = t_ptr->fifo_index;
read_from_tail = (void *)q_ptr[old_fifo_index];
opal_atomic_rmb();
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 */
if ( (t_ptr->num_to_clear == fifo->lazy_free_frequency) ||
flush_entries_read ) {
clearIndex = index - t_ptr->num_to_clear + 1;
clearIndex = old_fifo_index - t_ptr->num_to_clear + 1;
clearIndex &= fifo->mask;
for (i = 0; i < t_ptr->num_to_clear; i++) {

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

@ -95,22 +95,22 @@ OMPI_DECLSPEC int ompi_pointer_array_set_item(ompi_pointer_array_t *array,
/**
* Get the value of an element in array
*
* @param array Pointer to array (IN)
* @param index Index of element to be returned (IN)
* @param array Pointer to array (IN)
* @param element_index Index of element to be returned (IN)
*
* @return Error code. NULL indicates an error.
*/
static inline void *ompi_pointer_array_get_item(ompi_pointer_array_t *table,
int index)
int element_index)
{
void *p;
if( table->size <= index ) {
if( table->size <= element_index ) {
return NULL;
}
OPAL_THREAD_LOCK(&(table->lock));
p = table->addr[index];
p = table->addr[element_index];
OPAL_THREAD_UNLOCK(&(table->lock));
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 )
{
int index = 0;
int element_index = 0;
/* We dont have to check for the end as we always put an END_LOOP
* at the end of all datatype descriptions.
*/
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 ) \

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

@ -741,7 +741,8 @@ static int rebuild_communicator_list (mqs_process *proc)
mqs_image * image = mqs_get_image (proc);
mpi_image_info *i_info = (mpi_image_info *)mqs_get_image_info (image);
communicator_t **commp, *old;
int commcount = 0, i;
int commcount = 0;
int i;
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_ptr;
@ -826,7 +827,7 @@ static int rebuild_communicator_list (mqs_process *proc)
communicator_t ** comm_array =
(communicator_t **) mqs_malloc(commcount * sizeof (communicator_t *));
communicator_t *comm = p_info->communicator_list;
int i;
for (i=0; i<commcount; i++, comm=comm->next)
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.
*
* @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(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",
index, array->arr_size);
item_index, array->arr_size);
return 0;
}
#endif
return &array->bml_btls[index];
return &array->bml_btls[item_index];
}
/**
* Return the next LRU index in the array.
*
* @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)
{

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

@ -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);
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);
if(bml_btl->btl == btl) {
memset(bml_btl, 0, sizeof(mca_bml_base_btl_t));
mca_bml_base_btl_t* search_bml_btl = mca_bml_base_btl_array_get_index(&bml_endpoint->btl_send, n_index);
if(search_bml_btl->btl == btl) {
memset(search_bml_btl, 0, sizeof(mca_bml_base_btl_t));
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)) {
origin_check_dt = origin_datatype;
} else {
int i, index = -1, num_found = 0;
int i, found_index = -1, num_found = 0;
uint64_t mask = 1;
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
if (origin_datatype->bdt_used & mask) {
num_found++;
index = i;
found_index = i;
}
mask *= 2;
}
if (index < 0 || num_found > 1) {
if (found_index < 0 || num_found > 1) {
/* this is an erroneous datatype. Let
ompi_op_is_valid tell the user that */
OMPI_ERRHANDLER_RETURN(MPI_ERR_TYPE, win, MPI_ERR_TYPE, FUNC_NAME);
} else {
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)) {
op_check_dt = target_datatype;
} else {
int i, index = -1, num_found = 0;
int i, found_index = -1, num_found = 0;
uint64_t mask = 1;
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
if (target_datatype->bdt_used & mask) {
num_found++;
index = i;
found_index = i;
}
mask *= 2;
}
if (index < 0 || num_found > 1) {
if (found_index < 0 || num_found > 1) {
/* this is an erroneous datatype. Let
ompi_op_is_valid tell the user that */
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
constness... */
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)) {
op_check_dt = target_datatype;
} else {
int i, index = -1, num_found = 0;
int i, found_index = -1, num_found = 0;
uint64_t mask = 1;
for (i = 0 ; i < DT_MAX_PREDEFINED ; ++i) {
if (target_datatype->bdt_used & mask) {
num_found++;
index = i;
found_index = i;
}
mask *= 2;
}
if (index < 0 || num_found > 1) {
if (found_index < 0 || num_found > 1) {
/* this is an erroneous datatype. Let
ompi_op_is_valid tell the user that */
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
constness... */
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)) {

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

@ -149,20 +149,20 @@ OPAL_DECLSPEC int opal_value_array_set_size(opal_value_array_t* array, size_t si
/**
* Retrieve an item from the array by reference.
*
* @param array The input array (IN).
* @param index The array index (IN).
* @param array The input array (IN).
* @param item_index The array index (IN).
*
* @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.
*/
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 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.
*/
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;
if(index >= array->array_size &&
(rc = opal_value_array_set_size(array, index+1)) != OPAL_SUCCESS)
if(item_index >= array->array_size &&
(rc = opal_value_array_set_size(array, item_index+1)) != OPAL_SUCCESS)
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;
}
@ -232,26 +232,26 @@ static inline int opal_value_array_append_item(opal_value_array_t *array, const
/**
* Remove a specific item from the array.
*
* @param array The input array (IN).
* @param index The index to remove, which must be less than
* the current array size (IN).
* @param array The input array (IN).
* @param item_index The index to remove, which must be less than
* the current array size (IN).
*
* @return OMPI error code.
*
* 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 (index >= array->array_size) {
opal_output(0, "opal_value_array_remove_item: invalid index %d\n", index);
if (item_index >= array->array_size) {
opal_output(0, "opal_value_array_remove_item: invalid index %d\n", item_index);
return OPAL_ERR_BAD_PARAM;
}
#endif
memmove(array->array_items+(array->array_item_sizeof * index),
array->array_items+(array->array_item_sizeof * (index+1)),
array->array_item_sizeof * (array->array_size - index - 1));
memmove(array->array_items+(array->array_item_sizeof * item_index),
array->array_items+(array->array_item_sizeof * (item_index+1)),
array->array_item_sizeof * (array->array_size - item_index - 1));
array->array_size--;
return OPAL_SUCCESS;
}

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

@ -91,7 +91,7 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
const struct timespec *abstime)
{
struct timeval tv;
struct timeval abs;
struct timeval absolute;
int rc = 0;
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
rc = pthread_cond_timedwait(&c->c_cond, &m->m_lock_pthread, abstime);
#else
abs.tv_sec = abstime->tv_sec;
abs.tv_usec = abstime->tv_nsec * 1000;
absolute.tv_sec = abstime->tv_sec;
absolute.tv_usec = abstime->tv_nsec * 1000;
gettimeofday(&tv,NULL);
while (c->c_signaled == 0 &&
(tv.tv_sec <= abs.tv_sec ||
(tv.tv_sec == abs.tv_sec && tv.tv_usec < abs.tv_usec))) {
(tv.tv_sec <= absolute.tv_sec ||
(tv.tv_sec == absolute.tv_sec && tv.tv_usec < absolute.tv_usec))) {
opal_mutex_unlock(m);
opal_progress();
gettimeofday(&tv,NULL);
@ -112,12 +112,12 @@ static inline int opal_condition_timedwait(opal_condition_t *c,
}
#endif
} else {
abs.tv_sec = abstime->tv_sec;
abs.tv_usec = abstime->tv_nsec * 1000;
absolute.tv_sec = abstime->tv_sec;
absolute.tv_usec = abstime->tv_nsec * 1000;
gettimeofday(&tv,NULL);
while (c->c_signaled == 0 &&
(tv.tv_sec <= abs.tv_sec ||
(tv.tv_sec == abs.tv_sec && tv.tv_usec < abs.tv_usec))) {
(tv.tv_sec <= absolute.tv_sec ||
(tv.tv_sec == absolute.tv_sec && tv.tv_usec < absolute.tv_usec))) {
opal_progress();
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)
{
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(opal_using_threads()) {
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)
{
orte_std_cntr_t i, index;
orte_std_cntr_t i, element_index;
if (0) {
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
*/
index = table->lowest_free;
assert(table->addr[index] == NULL);
table->addr[index] = ptr;
element_index = table->lowest_free;
assert(table->addr[element_index] == NULL);
table->addr[element_index] = ptr;
table->number_free--;
if (table->number_free > 0) {
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)"
" addr[%d] = %p\n",
table, table->size, table->lowest_free, table->number_free,
index, ptr);
element_index, ptr);
}
OPAL_THREAD_UNLOCK(&(table->lock));
*location = index;
*location = element_index;
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.
*/
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)
{
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)"
" addr[%d] = %p\n",
table, table->size, table->lowest_free, table->number_free,
index, table->addr[index]);
element_index, table->addr[element_index]);
#endif
/* expand table if required to set a specific index */
OPAL_THREAD_LOCK(&(table->lock));
if (table->size <= index) {
if (table->size <= element_index) {
if (!grow_table(table)) {
OPAL_THREAD_UNLOCK(&(table->lock));
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.
*/
if ( NULL == table->addr[index] ) {
table->addr[index] = value;
if ( NULL == table->addr[element_index] ) {
table->addr[element_index] = value;
/* mark element as free, if NULL element */
if( NULL == value ) {
if (index < table->lowest_free) {
table->lowest_free = index;
if (element_index < table->lowest_free) {
table->lowest_free = element_index;
}
}
else {
table->number_free--;
/* Reset lowest_free if required */
if ( index == table->lowest_free ) {
if ( element_index == table->lowest_free ) {
orte_std_cntr_t i;
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] ){
table->lowest_free = i;
break;
@ -243,21 +243,21 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
}
}
else {
table->addr[index] = value;
table->addr[element_index] = value;
/* mark element as free, if NULL element */
if( NULL == value ) {
if (index < table->lowest_free) {
table->lowest_free = index;
if (element_index < table->lowest_free) {
table->lowest_free = element_index;
}
table->number_free++;
}
else {
/* Reset lowest_free if required */
if ( index == table->lowest_free ) {
if ( element_index == table->lowest_free ) {
orte_std_cntr_t i;
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] ){
table->lowest_free = i;
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)"
" addr[%d] = %p\n",
table, table->size, table->lowest_free, table->number_free,
index, table->addr[index]);
element_index, table->addr[element_index]);
#endif
OPAL_THREAD_UNLOCK(&(table->lock));
@ -284,9 +284,9 @@ int orte_pointer_array_set_item(orte_pointer_array_t *table, orte_std_cntr_t ind
* Test whether a certain element is already in use. If not yet
* in use, reserve it.
*
* @param array Pointer to array (IN)
* @param index Index of element to be tested (IN)
* @param value New value to be set at element index (IN)
* @param array Pointer to array (IN)
* @param element_index Index of element to be tested (IN)
* @param value New value to be set at element index (IN)
*
* @return true/false True if element could be reserved
* False if element could not be reserved (e.g.in use).
@ -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 ).
*/
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);
@ -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)"
" addr[%d] = %p\n",
table, table->size, table->lowest_free, table->number_free,
index, table->addr[index]);
element_index, table->addr[element_index]);
#endif
/* expand table if required to set a specific index */
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 */
OPAL_THREAD_UNLOCK(&(table->lock));
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? */
if (table->size <= index) {
if (table->size <= element_index) {
if (!grow_table(table)) {
OPAL_THREAD_UNLOCK(&(table->lock));
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.
*/
table->addr[index] = value;
table->addr[element_index] = value;
table->number_free--;
/* Reset lowest_free if required */
if ( index == table->lowest_free ) {
if ( element_index == table->lowest_free ) {
orte_std_cntr_t i;
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] ){
table->lowest_free = i;
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)"
" addr[%d] = %p\n",
table, table->size, table->lowest_free, table->number_free,
index, table->addr[index]);
element_index, table->addr[element_index]);
#endif
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.
* @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
* Automatically extend array if required.
*
* @param array Pointer to array (IN)
* @param index Index of element to be reset (IN)
* @param value New value to be set at element index (IN)
* @param array Pointer to array (IN)
* @param element_index Index of element to be reset (IN)
* @param value New value to be set at element index (IN)
*
* @return Error code. (-1) indicates an error.
*/
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
*
* @param array Pointer to array (IN)
* @param index Index of element to be returned (IN)
* @param array Pointer to array (IN)
* @param element_index Index of element to be returned (IN)
*
* @return Error code. NULL indicates an error.
*/
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;
OPAL_THREAD_LOCK(&(table->lock));
p = table->addr[index];
p = table->addr[element_index];
OPAL_THREAD_UNLOCK(&(table->lock));
return p;
}
@ -210,9 +210,9 @@ static inline void orte_pointer_array_free_clear(orte_pointer_array_t *array)
* Test whether a certain element is already in use. If not yet
* in use, reserve it.
*
* @param array Pointer to array (IN)
* @param index Index of element to be tested (IN)
* @param value New value to be set at element index (IN)
* @param array Pointer to array (IN)
* @param element_index Index of element to be tested (IN)
* @param value New value to be set at element index (IN)
*
* @return true/false True if element could be reserved
* False if element could not be reserved (e.g., in use).
@ -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 ).
*/
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);
#if defined(c_plusplus) || defined(__cplusplus)
}

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

@ -149,8 +149,8 @@ ORTE_DECLSPEC int orte_value_array_set_size(orte_value_array_t* array, orte_std_
/**
* Retrieve an item from the array by reference.
*
* @param array The input array (IN).
* @param index The array index (IN).
* @param array The input array (IN).
* @param item_index The array index (IN).
*
* @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.
*/
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 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.
*/
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;
if(index >= array->array_size &&
(rc = orte_value_array_set_size(array, index+1)) != ORTE_SUCCESS)
if(item_index >= array->array_size &&
(rc = orte_value_array_set_size(array, item_index+1)) != ORTE_SUCCESS)
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;
}
@ -232,26 +232,26 @@ static inline int orte_value_array_append_item(orte_value_array_t *array, const
/**
* Remove a specific item from the array.
*
* @param array The input array (IN).
* @param index The index to remove, which must be less than
* the current array size (IN).
* @param array The input array (IN).
* @param item_index The index to remove, which must be less than
* the current array size (IN).
*
* @return ORTE error code.
*
* 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 (index >= array->array_size) {
opal_output(0, "orte_value_array_remove_item: invalid index %d\n", index);
if (item_index >= array->array_size) {
opal_output(0, "orte_value_array_remove_item: invalid index %d\n", item_index);
return ORTE_ERR_BAD_PARAM;
}
#endif
memmove(array->array_items+(array->array_item_sizeof * index),
array->array_items+(array->array_item_sizeof * (index+1)),
array->array_item_sizeof * (array->array_size - index - 1));
memmove(array->array_items+(array->array_item_sizeof * item_index),
array->array_items+(array->array_item_sizeof * (item_index+1)),
array->array_item_sizeof * (array->array_size - item_index - 1));
array->array_size--;
return ORTE_SUCCESS;
}