From 113ce723e18ac713c6b0aeb9c11d98e05df635fc Mon Sep 17 00:00:00 2001 From: Jeff Squyres Date: Sat, 23 Oct 2004 19:24:00 +0000 Subject: [PATCH] Convert all ompi_bitmap_t and ompi_pointer_array_t indexing from size_t to int. This is in recognition of the fact that these two classes are primarily used for fortran<-->c convertsion of various entities (attributes, MPI objects), and MPI defines that an int must be used to hold MPI fortran handles. Hence, why use size_t internally? See the comment in src/class/ompi_pointer_array.h for a better description. Mixed in a few attribute fixes in this commit as well. This commit, therefore: - converts the indexing from size_t to int - changes all locations in the code that I could find that used size_t as the interface to ompi_bitmap_t or ompi_pointer_array_t - convert to use OMPI_FINT_2_INT / OMPI_INT_2_FINT macros in various src/mpi/c/*f2c.c and src/mpi/c/*c2f.c files - check the return code of ompi_comm_free() to ensure that everything worked properly before returning MPI_SUCCESS - unified all src/mpi/c/*f2c.c functions (i.e., they all do the same thing) - tie up some loose ends w.r.t. MPI_Request handling in fortran; set the req_f_to_c_index to MPI_UNDEFINED when it does not have a fortran index - still need to add a configure test to find OMPI_FORTRAN_HANDLE_MAX for ompi_bitmap.c and ompi_pointer_array.c (hard-wired to INT_MAX right now) - re-organized, consolidated, and unified some ompi_pointer_array.c code -- fixed a few minor bugs w.r.t. lowest_free (could have left some unintentional holes in the array) This commit was SVN r3302. --- src/class/ompi_bitmap.c | 61 ++++++++---- src/class/ompi_bitmap.h | 24 +++-- src/class/ompi_pointer_array.c | 168 ++++++++++++++++++--------------- src/class/ompi_pointer_array.h | 67 ++++++++----- src/datatype/datatype.h | 2 +- src/errhandler/errhandler.h | 2 +- src/mpi/c/comm_c2f.c | 15 ++- src/mpi/c/comm_f2c.c | 3 +- src/mpi/c/comm_free.c | 13 ++- src/mpi/c/errhandler_c2f.c | 5 +- src/mpi/c/errhandler_f2c.c | 3 +- src/mpi/c/file_c2f.c | 7 +- src/mpi/c/file_f2c.c | 3 +- src/mpi/c/group_c2f.c | 20 ++-- src/mpi/c/group_f2c.c | 7 +- src/mpi/c/info_c2f.c | 18 +--- src/mpi/c/info_f2c.c | 3 +- src/mpi/c/op_c2f.c | 19 ++-- src/mpi/c/op_f2c.c | 4 +- src/mpi/c/request_c2f.c | 11 +-- src/mpi/c/request_f2c.c | 6 +- src/mpi/c/status_c2f.c | 12 +-- src/mpi/c/status_f2c.c | 2 +- src/mpi/c/type_c2f.c | 17 ++-- src/mpi/c/type_f2c.c | 4 +- src/mpi/c/win_c2f.c | 11 ++- src/mpi/c/win_f2c.c | 2 +- src/request/request.c | 1 + src/request/request.h | 7 +- src/util/show_help.c | 5 +- 30 files changed, 278 insertions(+), 244 deletions(-) diff --git a/src/class/ompi_bitmap.c b/src/class/ompi_bitmap.c index d50763422f..905261e740 100644 --- a/src/class/ompi_bitmap.c +++ b/src/class/ompi_bitmap.c @@ -5,6 +5,8 @@ #include "ompi_config.h" #include +#include +#define OMPI_FORTRAN_HANDLE_MAX INT_MAX #include "include/constants.h" #include "class/ompi_bitmap.h" @@ -38,11 +40,11 @@ ompi_bitmap_destruct(ompi_bitmap_t *bm) int -ompi_bitmap_init(ompi_bitmap_t *bm, size_t size) +ompi_bitmap_init(ompi_bitmap_t *bm, int size) { - size_t actual_size; + int actual_size; - if (((int)size <= 0) || (NULL == bm)) { + if ((size <= 0) || (size > OMPI_FORTRAN_HANDLE_MAX) || (NULL == bm)) { return OMPI_ERR_BAD_PARAM; } @@ -62,11 +64,12 @@ ompi_bitmap_init(ompi_bitmap_t *bm, size_t size) int -ompi_bitmap_set_bit(ompi_bitmap_t *bm, size_t bit) +ompi_bitmap_set_bit(ompi_bitmap_t *bm, int bit) { - size_t index, offset, new_size, i; + int index, offset, new_size, i; + size_t new_size_large; - if ((bit < 0) || (NULL == bm)) { + if ((bit < 0) || (bit > OMPI_FORTRAN_HANDLE_MAX) || (NULL == bm)) { return OMPI_ERR_BAD_PARAM; } @@ -74,15 +77,36 @@ ompi_bitmap_set_bit(ompi_bitmap_t *bm, size_t bit) offset = bit % SIZE_OF_CHAR; if (index >= bm->array_size) { + + /* If we're already full, return "No vacancy!" */ + + if (bm->array_size >= OMPI_FORTRAN_HANDLE_MAX) { + return OMPI_ERR_OUT_OF_RESOURCE; + } + /* We need to allocate more space for the bitmap, since we are out of range. We dont throw any error here, because this is valid and we simply expand the bitmap */ - new_size = (index / bm->array_size + 1 ) * bm->array_size; - /* New size is just a multiple of the original size to fit in - the index */ + new_size_large = (index / bm->array_size + 1 ) * bm->array_size; - bm->bitmap = (unsigned char *) realloc(bm->bitmap, new_size); + /* Check to be sure that we still have less than + OMPI_FORTRAN_HANDLE_MAX bits */ + + if (new_size_large > OMPI_FORTRAN_HANDLE_MAX) { + new_size_large = OMPI_FORTRAN_HANDLE_MAX; + } + + /* Note that new_size is guaranteed to be <= + OMPI_FORTRAN_HANDLE_MAX, which is guaranteed to fit in a + [signed] int. */ + + new_size = (int) new_size_large; + + /* New size is just a multiple of the original size to fit in + the index. */ + + bm->bitmap = (unsigned char *) realloc(bm->bitmap, (int) new_size); if (NULL == bm->bitmap) { return OMPI_ERR_OUT_OF_RESOURCE; } @@ -105,9 +129,9 @@ ompi_bitmap_set_bit(ompi_bitmap_t *bm, size_t bit) int -ompi_bitmap_clear_bit(ompi_bitmap_t *bm, size_t bit) +ompi_bitmap_clear_bit(ompi_bitmap_t *bm, int bit) { - size_t index, offset; + int index, offset; if ((bit < 0) || (bit > bm->legal_numbits - 1) || (NULL == bm)) { return OMPI_ERR_BAD_PARAM; @@ -126,9 +150,9 @@ ompi_bitmap_clear_bit(ompi_bitmap_t *bm, size_t bit) int -ompi_bitmap_is_set_bit(ompi_bitmap_t *bm, size_t bit) +ompi_bitmap_is_set_bit(ompi_bitmap_t *bm, int bit) { - size_t index, offset; + int index, offset; if ((bit < 0) || (bit > bm->legal_numbits - 1) || (NULL == bm)) { return OMPI_ERR_BAD_PARAM; @@ -164,7 +188,7 @@ ompi_bitmap_clear_all_bits(ompi_bitmap_t *bm) int ompi_bitmap_set_all_bits(ompi_bitmap_t *bm) { - size_t i; + int i; if (NULL == bm) { return OMPI_ERR_BAD_PARAM; @@ -178,9 +202,9 @@ ompi_bitmap_set_all_bits(ompi_bitmap_t *bm) int -ompi_bitmap_find_and_set_first_unset_bit(ompi_bitmap_t *bm, size_t *position) +ompi_bitmap_find_and_set_first_unset_bit(ompi_bitmap_t *bm, int *position) { - size_t i = 0; + int i = 0; unsigned char temp; unsigned char all_ones = 0xff; @@ -197,8 +221,7 @@ ompi_bitmap_find_and_set_first_unset_bit(ompi_bitmap_t *bm, size_t *position) if (i == bm->array_size) { /* increase the bitmap size then */ *position = bm->array_size * SIZE_OF_CHAR; - ompi_bitmap_set_bit(bm, *position); - return OMPI_SUCCESS; + return ompi_bitmap_set_bit(bm, *position); } /* This one has an unset bit, find its bit number */ diff --git a/src/class/ompi_bitmap.h b/src/class/ompi_bitmap.h index adc1b181f0..5d1727dd4a 100644 --- a/src/class/ompi_bitmap.h +++ b/src/class/ompi_bitmap.h @@ -13,14 +13,20 @@ * bit is set -- so the valid functions are set_bit and * find_and_set_bit. Other functions like clear, if passed a bit * outside the initialized range will result in an error. + * + * Since these bitmaps are only used to track fortran handles (which + * MPI defines to be int's), it is assumed that we can never have more + * than OMPI_FORTRAN_HANDLE_MAX (which is min(INT_MAX, fortran + * INTEGER max)). */ #ifndef OMPI_BITMAP_H #define OMPI_BITMAP_H +#include "ompi_config.h" + #include -#include "ompi_config.h" #include "include/types.h" #include "class/ompi_object.h" @@ -30,8 +36,8 @@ extern "C" { struct ompi_bitmap_t { ompi_object_t super; /**< Subclass of ompi_object_t */ unsigned char *bitmap; /**< The actual bitmap array of characters */ - size_t array_size; /**< The actual array size that maintains the bitmap */ - size_t legal_numbits; /**< The number of bits which are legal (the + int array_size; /**< The actual array size that maintains the bitmap */ + int legal_numbits; /**< The number of bits which are legal (the actual bitmap may contain more bits, since it needs to be rounded to the nearest char */ @@ -50,7 +56,7 @@ OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_bitmap_t); * @return OMPI error code or success * */ -OMPI_DECLSPEC int ompi_bitmap_init (ompi_bitmap_t *bm, size_t size); +OMPI_DECLSPEC int ompi_bitmap_init (ompi_bitmap_t *bm, int size); /** @@ -63,7 +69,7 @@ OMPI_DECLSPEC int ompi_bitmap_init (ompi_bitmap_t *bm, size_t size); * @return OMPI error code or success * */ -OMPI_DECLSPEC int ompi_bitmap_set_bit(ompi_bitmap_t *bm, size_t bit); +OMPI_DECLSPEC int ompi_bitmap_set_bit(ompi_bitmap_t *bm, int bit); /** @@ -75,7 +81,7 @@ OMPI_DECLSPEC int ompi_bitmap_set_bit(ompi_bitmap_t *bm, size_t bit); * @return OMPI error code if the bit is out of range, else success * */ -OMPI_DECLSPEC int ompi_bitmap_clear_bit(ompi_bitmap_t *bm, size_t bit); +OMPI_DECLSPEC int ompi_bitmap_clear_bit(ompi_bitmap_t *bm, int bit); /** @@ -88,7 +94,7 @@ OMPI_DECLSPEC int ompi_bitmap_clear_bit(ompi_bitmap_t *bm, size_t bit); * 0 if the bit is not set * */ -OMPI_DECLSPEC int ompi_bitmap_is_set_bit(ompi_bitmap_t *bm, size_t bit); +OMPI_DECLSPEC int ompi_bitmap_is_set_bit(ompi_bitmap_t *bm, int bit); /** @@ -100,7 +106,7 @@ OMPI_DECLSPEC int ompi_bitmap_is_set_bit(ompi_bitmap_t *bm, size_t bit); * @return err OMPI_SUCCESS on success */ OMPI_DECLSPEC int ompi_bitmap_find_and_set_first_unset_bit(ompi_bitmap_t *bm, - size_t *position); + int *position); /** @@ -130,7 +136,7 @@ OMPI_DECLSPEC int ompi_bitmap_set_all_bits(ompi_bitmap_t *bm); * @return OMPI error code if bm is NULL * */ -static inline size_t ompi_bitmap_size(ompi_bitmap_t *bm) +static inline int ompi_bitmap_size(ompi_bitmap_t *bm) { return (NULL == bm) ? 0 : bm->legal_numbits; } diff --git a/src/class/ompi_pointer_array.c b/src/class/ompi_pointer_array.c index 0697a73e9a..a3489d9c37 100644 --- a/src/class/ompi_pointer_array.c +++ b/src/class/ompi_pointer_array.c @@ -1,34 +1,31 @@ - /* * $HEADER$ */ -/** - * Utility functions to manage fortran <-> c opaque object translation - */ - #include "ompi_config.h" #include #include #include +#include +#define OMPI_FORTRAN_HANDLE_MAX INT_MAX + #include "include/constants.h" #include "class/ompi_pointer_array.h" #include "util/output.h" -static void ompi_pointer_array_construct(ompi_pointer_array_t *); -static void ompi_pointer_array_destruct(ompi_pointer_array_t *); enum { TABLE_INIT = 1, TABLE_GROW = 2 }; -ompi_class_t ompi_pointer_array_t_class = { - "ompi_pointer_array_t", - OBJ_CLASS(ompi_object_t), - (ompi_construct_t) ompi_pointer_array_construct, - (ompi_destruct_t) ompi_pointer_array_destruct -}; +static void ompi_pointer_array_construct(ompi_pointer_array_t *); +static void ompi_pointer_array_destruct(ompi_pointer_array_t *); +static bool grow_table(ompi_pointer_array_t *table, size_t soft, size_t hard); -/** +OBJ_CLASS_INSTANCE(ompi_pointer_array_t, ompi_object_t, + ompi_pointer_array_construct, + ompi_pointer_array_destruct); + +/* * ompi_pointer_array constructor */ void ompi_pointer_array_construct(ompi_pointer_array_t *array) @@ -40,17 +37,17 @@ void ompi_pointer_array_construct(ompi_pointer_array_t *array) array->addr = 0; } -/** +/* * ompi_pointer_array destructor */ -void ompi_pointer_array_destruct(ompi_pointer_array_t *array){ - +void ompi_pointer_array_destruct(ompi_pointer_array_t *array) +{ /* free table */ - if( NULL != array->addr) + if( NULL != array->addr) { free(array->addr); + } OBJ_DESTRUCT(&array->lock); - return; } /** @@ -61,11 +58,11 @@ void ompi_pointer_array_destruct(ompi_pointer_array_t *array){ * * @return Array index where ptr is inserted or OMPI_ERROR if it fails */ -size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr) +int ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr) { void **p; - size_t i; - size_t index; + int i; + int index; if (0) { ompi_output(0,"ompi_pointer_array_add: IN: " @@ -89,10 +86,10 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr) ompi_output(0,"ompi_pointer_array_add: INIT: table %p\n", table); } - p = (void **)malloc(TABLE_INIT * sizeof(void *)); + p = (void **) malloc(TABLE_INIT * sizeof(void *)); if (p == NULL) { - OMPI_THREAD_UNLOCK(&(table->lock)); - return OMPI_ERROR; + OMPI_THREAD_UNLOCK(&(table->lock)); + return OMPI_ERROR; } table->lowest_free = 0; table->number_free = TABLE_INIT; @@ -104,26 +101,12 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr) } else if (table->number_free == 0) { - /* - * grow table - */ + /* need to grow table */ - if (0) { - ompi_output(0,"ompi_pointer_array_add: GROW: table %p growing %d -> %d\n", - table, table->size, table->size * TABLE_GROW); - } - - p = (void **)realloc(table->addr, TABLE_GROW * table->size * sizeof(void *)); - if (p == NULL) { - OMPI_THREAD_UNLOCK(&(table->lock)); - return OMPI_ERROR; - } - table->lowest_free = table->size; - table->number_free += (TABLE_GROW - 1) * table->size; - table->size *= TABLE_GROW; - table->addr = p; - for (i = table->lowest_free; i < table->size; i++) { - table->addr[i] = NULL; + if (!grow_table(table, table->size * TABLE_GROW, + OMPI_FORTRAN_HANDLE_MAX)) { + OMPI_THREAD_UNLOCK(&(table->lock)); + return OMPI_ERR_OUT_OF_RESOURCE; } } @@ -163,7 +146,6 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr) } OMPI_THREAD_UNLOCK(&(table->lock)); - return index; } @@ -178,8 +160,8 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *table, void *ptr) * * Assumption: NULL element is free element. */ -int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index, - void * value) +int ompi_pointer_array_set_item(ompi_pointer_array_t *table, int index, + void * value) { assert(table != NULL); @@ -192,20 +174,14 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index, #endif /* expand table if required to set a specific index */ + OMPI_THREAD_LOCK(&(table->lock)); - if(table->size <= index) { - size_t i, new_size = (((index / TABLE_GROW) + 1) * TABLE_GROW); - void *p = realloc(table->addr, new_size * sizeof(void *)); - if (p == NULL) { + if (table->size <= index) { + if (!grow_table(table, ((index / TABLE_GROW) + 1) * TABLE_GROW, + index)) { OMPI_THREAD_UNLOCK(&(table->lock)); return OMPI_ERROR; - } - table->number_free += new_size - table->size; - table->addr = (void **) p; - for (i = table->size; i < new_size; i++) { - table->addr[i] = NULL; } - table->size = new_size; } /* @@ -224,7 +200,7 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index, table->number_free--; /* Reset lowest_free if required */ if ( index == table->lowest_free ) { - size_t i; + int i; table->lowest_free=table->size; for ( i=index; isize; i++) { @@ -248,7 +224,7 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index, else { /* Reset lowest_free if required */ if ( index == table->lowest_free ) { - size_t i; + int i; table->lowest_free=table->size; for ( i=index; isize; i++) { @@ -288,11 +264,9 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *table, size_t index, * In contrary to array_set, this function does not allow to overwrite * a value, unless the previous value is NULL ( equiv. to free ). */ -int ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, size_t index, - void *value) +bool ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, + int index, void *value) { - int flag=true; - assert(table != NULL); assert(index >= 0); @@ -308,24 +282,18 @@ int ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, size_t in OMPI_THREAD_LOCK(&(table->lock)); if ( index < table->size && table->addr[index] != NULL ) { /* This element is already in use */ - flag = false; OMPI_THREAD_UNLOCK(&(table->lock)); - return flag; + return false; } - if(table->size <= index) { - size_t i, new_size = (((index / TABLE_GROW) + 1) * TABLE_GROW); - void *p = realloc(table->addr, new_size * sizeof(void *)); - if (p == NULL) { + /* Do we need to grow the table? */ + + if (table->size <= index) { + if (!grow_table(table, (((index / TABLE_GROW) + 1) * TABLE_GROW), + index)) { OMPI_THREAD_UNLOCK(&(table->lock)); - return OMPI_ERROR; - } - table->number_free += new_size - table->size; - table->addr = (void **)p; - for (i = table->size; i < new_size; i++) { - table->addr[i] = NULL; + return false; } - table->size = new_size; } /* @@ -335,7 +303,7 @@ int ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, size_t in table->number_free--; /* Reset lowest_free if required */ if ( index == table->lowest_free ) { - size_t i; + int i; table->lowest_free = table->size; for ( i=index; isize; i++) { @@ -355,5 +323,49 @@ int ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, size_t in #endif OMPI_THREAD_UNLOCK(&(table->lock)); - return flag; + return true; +} + + +static bool grow_table(ompi_pointer_array_t *table, size_t soft, size_t hard) +{ + size_t new_size; + int i, new_size_int; + void *p; + + /* Ensure that we have room to grow -- stay less than + OMPI_FORTRAN_HANDLE_MAX. Note that OMPI_FORTRAN_HANDLE_MAX + is min(INT_MAX, fortran INTEGER max), so it's guaranteed to + fit within a [signed] int. */ + + if (table->size >= OMPI_FORTRAN_HANDLE_MAX) { + return false; + } + if (soft > OMPI_FORTRAN_HANDLE_MAX) { + if (hard > OMPI_FORTRAN_HANDLE_MAX) { + return false; + } else { + new_size = hard; + } + } else { + new_size = soft; + } + + p = (void **) realloc(table->addr, new_size * sizeof(void *)); + if (p == NULL) { + return false; + } + + /* We've already established (above) that the arithimetic + below will be less than OMPI_FORTRAN_HANDLE_MAX */ + + new_size_int = (int) new_size; + table->number_free += new_size_int - table->size; + table->addr = p; + for (i = table->size; i < new_size_int; ++i) { + table->addr[i] = NULL; + } + table->size = new_size_int; + + return true; } diff --git a/src/class/ompi_pointer_array.h b/src/class/ompi_pointer_array.h index 69525685b9..2850156b37 100644 --- a/src/class/ompi_pointer_array.h +++ b/src/class/ompi_pointer_array.h @@ -1,39 +1,57 @@ /* * $HEADER$ */ +/** @file + * + * Utility functions to manage fortran <-> c opaque object + * translation. Note that since MPI defines fortran handles as + * [signed] int's, we use int everywhere in here where you would + * normally expect size_t. There's some code that makes sure indices + * don't go above FORTRAN_HANDLE_MAX (which is min(INT_MAX, fortran + * INTEGER max)), just to be sure. + */ #ifndef OMPI_POINTER_ARRAY_H #define OMPI_POINTER_ARRAY_H +#include "ompi_config.h" + #include "threads/mutex.h" #include "class/ompi_object.h" #if defined(c_plusplus) || defined(__cplusplus) extern "C" { #endif -/* - * typedefs - */ -typedef struct ompi_pointer_array_t ompi_pointer_array_t; -OMPI_DECLSPEC extern ompi_class_t ompi_pointer_array_t_class; -/* +/** * dynamic pointer array */ struct ompi_pointer_array_t { - /* base class */ + /** base class */ ompi_object_t super; - /* synchronization object */ + /** synchronization object */ ompi_mutex_t lock; - /* index of lowest free element */ - size_t lowest_free; - /* number of fee elements in the list */ - size_t number_free; - /* size of list, i.e. number of elements in addr */ - size_t size; - /* pointer to array of pointers */ + /** Index of lowest free element. NOTE: This is only an + optimization to know where to search for the first free slot. + It does \em not necessarily imply indices all above this index + are not taken! */ + int lowest_free; + /** number of fee elements in the list */ + int number_free; + /** size of list, i.e. number of elements in addr */ + int size; + /** pointer to array of pointers */ void **addr; }; +/** + * Convenience typedef + */ +typedef struct ompi_pointer_array_t ompi_pointer_array_t; +/** + * Class declaration + */ +OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_pointer_array_t); + /** @@ -43,9 +61,9 @@ struct ompi_pointer_array_t { * @param ptr Pointer value (IN) * * @return Index of inserted array element. Return value of - * (size_t)(-1) indicates an error. + * (-1) indicates an error. */ -size_t ompi_pointer_array_add(ompi_pointer_array_t *array, void *ptr); +int ompi_pointer_array_add(ompi_pointer_array_t *array, void *ptr); /** * Set the value of an element in array @@ -57,7 +75,7 @@ size_t ompi_pointer_array_add(ompi_pointer_array_t *array, void *ptr); * @return Error code. (-1) indicates an error. */ int ompi_pointer_array_set_item(ompi_pointer_array_t *array, - size_t index, void *value); + int index, void *value); /** * Get the value of an element in array @@ -68,7 +86,8 @@ int ompi_pointer_array_set_item(ompi_pointer_array_t *array, * @return Error code. NULL indicates an error. */ -static inline void *ompi_pointer_array_get_item(ompi_pointer_array_t *table, size_t index) +static inline void *ompi_pointer_array_get_item(ompi_pointer_array_t *table, + int index) { void *p; OMPI_THREAD_LOCK(&(table->lock)); @@ -88,11 +107,12 @@ static inline void *ompi_pointer_array_get_item(ompi_pointer_array_t *table, siz * Simple inline function to return the size of the array in order to * hide the member field from external users. */ -static inline size_t ompi_pointer_array_get_size(ompi_pointer_array_t *array) +static inline int ompi_pointer_array_get_size(ompi_pointer_array_t *array) { return array->size; } + /** * Test whether a certain element is already in use. If not yet * in use, reserve it. @@ -102,13 +122,14 @@ static inline size_t ompi_pointer_array_get_size(ompi_pointer_array_t *array) * @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). + * False if element could not be reserved (e.g., in use). * * In contrary to array_set, this function does not allow to overwrite * a value, unless the previous value is NULL ( equiv. to free ). */ -int ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, size_t index, - void *value); +bool ompi_pointer_array_test_and_set_item (ompi_pointer_array_t *table, + int index, + void *value); #if defined(c_plusplus) || defined(__cplusplus) } #endif diff --git a/src/datatype/datatype.h b/src/datatype/datatype.h index 89e067333c..8059be1382 100644 --- a/src/datatype/datatype.h +++ b/src/datatype/datatype.h @@ -88,7 +88,7 @@ typedef struct ompi_datatype_t { /* Attribute fields */ ompi_hash_table_t *d_keyhash; - size_t d_f_to_c_index; + int d_f_to_c_index; char name[MPI_MAX_OBJECT_NAME]; dt_type_desc_t desc; /**< the data description */ dt_type_desc_t opt_desc; /**< short description of the data used when conversion is useless diff --git a/src/errhandler/errhandler.h b/src/errhandler/errhandler.h index 0db0495641..dc90bc2e02 100644 --- a/src/errhandler/errhandler.h +++ b/src/errhandler/errhandler.h @@ -72,7 +72,7 @@ struct ompi_errhandler_t { ompi_errhandler_fortran_handler_fn_t *eh_fort_fn; /* index in Fortran <-> C translation array */ - size_t eh_f_to_c_index; + int eh_f_to_c_index; }; typedef struct ompi_errhandler_t ompi_errhandler_t; diff --git a/src/mpi/c/comm_c2f.c b/src/mpi/c/comm_c2f.c index 0afb93ec3d..15e0ad881f 100644 --- a/src/mpi/c/comm_c2f.c +++ b/src/mpi/c/comm_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -22,17 +23,13 @@ static const char FUNC_NAME[] = "MPI_Comm_c2f"; MPI_Fint MPI_Comm_c2f(MPI_Comm comm) { - ompi_communicator_t *cptr=(ompi_communicator_t *)comm; - if ( MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - - /* mapping an invalid handle to a null handle */ - /* not invoking an error handler */ - if ( ompi_comm_invalid (cptr)) { - cptr = (ompi_communicator_t *) MPI_COMM_NULL; - } + + if (ompi_comm_invalid (comm)) { + comm = MPI_COMM_NULL; + } } - return ((MPI_Fint) comm->c_f_to_c_index); + return OMPI_INT_2_FINT(comm->c_f_to_c_index); } diff --git a/src/mpi/c/comm_f2c.c b/src/mpi/c/comm_f2c.c index f2956e80f4..4ce775fdbd 100644 --- a/src/mpi/c/comm_f2c.c +++ b/src/mpi/c/comm_f2c.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -22,7 +23,7 @@ static const char FUNC_NAME[] = "MPI_Comm_f2c"; MPI_Comm MPI_Comm_f2c(MPI_Fint comm) { - size_t o_index= (size_t) comm; + int o_index= OMPI_FINT_2_INT(comm); if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); diff --git a/src/mpi/c/comm_free.c b/src/mpi/c/comm_free.c index 8e7c71b50e..3fb291f936 100644 --- a/src/mpi/c/comm_free.c +++ b/src/mpi/c/comm_free.c @@ -19,19 +19,22 @@ static const char FUNC_NAME[] = "MPI_Comm_free"; -int MPI_Comm_free(MPI_Comm *comm) { - +int MPI_Comm_free(MPI_Comm *comm) +{ + int ret; + if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if ( NULL == *comm || MPI_COMM_WORLD == *comm || - MPI_COMM_SELF == *comm || ompi_comm_invalid (*comm)) + MPI_COMM_SELF == *comm || ompi_comm_invalid (*comm)) { return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM, FUNC_NAME); + } } - ompi_comm_free ( comm ); + ret = ompi_comm_free ( comm ); + OMPI_ERRHANDLER_CHECK(ret, *comm, ret, FUNC_NAME); - *comm = MPI_COMM_NULL; return MPI_SUCCESS; } diff --git a/src/mpi/c/errhandler_c2f.c b/src/mpi/c/errhandler_c2f.c index deb4bc4d4f..73d0e0a435 100644 --- a/src/mpi/c/errhandler_c2f.c +++ b/src/mpi/c/errhandler_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -32,10 +33,10 @@ MPI_Fint MPI_Errhandler_c2f(MPI_Errhandler errhandler) /* not invoking an error handler */ if (NULL == errhandler || OMPI_ERRHANDLER_TYPE_COMM != errhandler->eh_mpi_object_type) { - errhandler = MPI_ERRHANDLER_NULL; + errhandler = MPI_ERRHANDLER_NULL; } } - return (MPI_Fint) errhandler->eh_f_to_c_index; + return OMPI_INT_2_FINT(errhandler->eh_f_to_c_index); } diff --git a/src/mpi/c/errhandler_f2c.c b/src/mpi/c/errhandler_f2c.c index 4ce7dce54f..d49b701ed6 100644 --- a/src/mpi/c/errhandler_f2c.c +++ b/src/mpi/c/errhandler_f2c.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -22,7 +23,7 @@ static const char FUNC_NAME[] = "MPI_Errhandler_f2c"; MPI_Errhandler MPI_Errhandler_f2c(MPI_Fint errhandler_f) { - size_t eh_index = (size_t) errhandler_f; + int eh_index = OMPI_FINT_2_INT(errhandler_f); /* Error checking */ diff --git a/src/mpi/c/file_c2f.c b/src/mpi/c/file_c2f.c index a981332920..3fc09d0734 100644 --- a/src/mpi/c/file_c2f.c +++ b/src/mpi/c/file_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" #include "file/file.h" @@ -26,11 +27,9 @@ MPI_Fint MPI_File_c2f(MPI_File file) if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); if (ompi_file_invalid(file)) { - return (MPI_Fint) OMPI_ERRHANDLER_INVOKE(MPI_FILE_NULL, - MPI_ERR_FILE, - FUNC_NAME); + file = MPI_FILE_NULL; } } - return (MPI_Fint) file->f_f_to_c_index; + return OMPI_INT_2_FINT(file->f_f_to_c_index); } diff --git a/src/mpi/c/file_f2c.c b/src/mpi/c/file_f2c.c index b107afb87c..b062702920 100644 --- a/src/mpi/c/file_f2c.c +++ b/src/mpi/c/file_f2c.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" #include "file/file.h" @@ -23,7 +24,7 @@ static const char FUNC_NAME[] = "MPI_File_f2c"; MPI_File MPI_File_f2c(MPI_Fint file_f) { - size_t file_index = (size_t) file_f; + int file_index = OMPI_FINT_2_INT(file_f); if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); diff --git a/src/mpi/c/group_c2f.c b/src/mpi/c/group_c2f.c index d58599c417..5e14726041 100644 --- a/src/mpi/c/group_c2f.c +++ b/src/mpi/c/group_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "group/group.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -21,24 +22,15 @@ static const char FUNC_NAME[] = "MPI_Group_c2f"; -MPI_Fint MPI_Group_c2f(MPI_Group group) { - - /* local variables */ - ompi_group_t *group_c; - - /* error checking */ - if( MPI_PARAM_CHECK ) { +MPI_Fint MPI_Group_c2f(MPI_Group group) +{ + if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - /* mapping an invalid handle to a null handle */ - /* not invoking an error handler */ - if( (NULL == group) ) { - group = MPI_GROUP_NULL; + group = MPI_GROUP_NULL; } } - group_c=(ompi_group_t *)group; - - return (MPI_Fint) (group_c->grp_f_to_c_index) ; + return OMPI_INT_2_FINT(group->grp_f_to_c_index) ; } diff --git a/src/mpi/c/group_f2c.c b/src/mpi/c/group_f2c.c index 6465322cfd..9102119bd0 100644 --- a/src/mpi/c/group_f2c.c +++ b/src/mpi/c/group_f2c.c @@ -3,8 +3,10 @@ */ #include "ompi_config.h" + #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "group/group.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -22,10 +24,7 @@ static const char FUNC_NAME[] = "MPI_Group_f2c"; MPI_Group MPI_Group_f2c(MPI_Fint group_f) { - /* local variables */ - size_t group_index; - - group_index = (size_t) group_f; + int group_index = OMPI_FINT_2_INT(group_f); if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); diff --git a/src/mpi/c/info_c2f.c b/src/mpi/c/info_c2f.c index 0a36d4b0ba..d48daf1070 100644 --- a/src/mpi/c/info_c2f.c +++ b/src/mpi/c/info_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "class/ompi_list.h" #include "info/info.h" #include "errhandler/errhandler.h" @@ -22,28 +23,15 @@ static const char FUNC_NAME[] = "MPI_Info_c2f"; -/** - * Converts info into a fortan handle - * - * @param info The C handle which has to be converted - * @retval Fortran handle corresponding to info. - * - * If info is a valid C handle, the MPI_Info_c2f returns a valid - * fortran handle to the same MPI_INFO object. - */ MPI_Fint MPI_Info_c2f(MPI_Info info) { - /* check the arguments */ if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - /* mapping an invalid handle to a null handle */ - /* not invoking an error handler */ if (NULL == info || ompi_info_is_freed(info)) { - info = MPI_INFO_NULL; + info = MPI_INFO_NULL; } } - /* return the index */ - return (MPI_Fint)(info->i_f_to_c_index); + return OMPI_INT_2_FINT(info->i_f_to_c_index); } diff --git a/src/mpi/c/info_f2c.c b/src/mpi/c/info_f2c.c index 5e31d8d23e..ddba2059e9 100644 --- a/src/mpi/c/info_f2c.c +++ b/src/mpi/c/info_f2c.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "class/ompi_list.h" #include "info/info.h" #include "errhandler/errhandler.h" @@ -30,7 +31,7 @@ static const char FUNC_NAME[] = "MPI_Info_f2c"; */ MPI_Info MPI_Info_f2c(MPI_Fint info) { - size_t info_index = (size_t) info; + int info_index = OMPI_FINT_2_INT(info); /* check the arguments */ diff --git a/src/mpi/c/op_c2f.c b/src/mpi/c/op_c2f.c index 825f54e440..4d6f5ef532 100644 --- a/src/mpi/c/op_c2f.c +++ b/src/mpi/c/op_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "op/op.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -23,19 +24,13 @@ static const char FUNC_NAME[] = "MPI_Op_c2f"; MPI_Fint MPI_Op_c2f(MPI_Op op) { - /* Error checking */ + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - - /* mapping an invalid handle to a null handle */ - /* not invoking an error handler */ - if (NULL == op) { - op = MPI_OP_NULL; + if (NULL == op) { + op = MPI_OP_NULL; + } } - } - /* All done */ - - return (MPI_Fint) op->o_f_to_c_index; + return OMPI_INT_2_FINT(op->o_f_to_c_index); } diff --git a/src/mpi/c/op_f2c.c b/src/mpi/c/op_f2c.c index fce123e794..09b14b313d 100644 --- a/src/mpi/c/op_f2c.c +++ b/src/mpi/c/op_f2c.c @@ -2,10 +2,10 @@ * $HEADER$ */ #include "ompi_config.h" -#include #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "op/op.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -23,7 +23,7 @@ static const char FUNC_NAME[] = "MPI_Op_f2c"; MPI_Op MPI_Op_f2c(MPI_Fint op_f) { - size_t op_index = (size_t) op_f; + int op_index = OMPI_FINT_2_INT(op_f); /* Error checking */ diff --git a/src/mpi/c/request_c2f.c b/src/mpi/c/request_c2f.c index 4b0b7a3d50..9ef6cf03e3 100644 --- a/src/mpi/c/request_c2f.c +++ b/src/mpi/c/request_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "request/request.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -23,13 +24,9 @@ static const char FUNC_NAME[] = "MPI_Request_f2c"; MPI_Fint MPI_Request_c2f(MPI_Request request) { - /* error checking */ - if( MPI_PARAM_CHECK ) { + if ( MPI_PARAM_CHECK ) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - /* mapping an invalid handle to a null handle */ - /* not invoking an error handler */ - if (NULL == request) { request = MPI_REQUEST_NULL; } @@ -48,10 +45,10 @@ MPI_Fint MPI_Request_c2f(MPI_Request request) fortran integer. */ - if (-1 == request->req_f_to_c_index) { + if (MPI_UNDEFINED == request->req_f_to_c_index) { request->req_f_to_c_index = ompi_pointer_array_add(&ompi_request_f_to_c_table, request); } - return (MPI_Fint) (request->req_f_to_c_index) ; + return OMPI_INT_2_FINT(request->req_f_to_c_index) ; } diff --git a/src/mpi/c/request_f2c.c b/src/mpi/c/request_f2c.c index 67fe6e3f8c..d745598f7e 100644 --- a/src/mpi/c/request_f2c.c +++ b/src/mpi/c/request_f2c.c @@ -2,10 +2,10 @@ * $HEADER$ */ #include "ompi_config.h" -#include #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "request/request.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" @@ -23,9 +23,7 @@ static const char FUNC_NAME[] = "MPI_Request_f2c"; MPI_Request MPI_Request_f2c(MPI_Fint request) { - size_t request_index; - - request_index = (size_t) request; + int request_index = OMPI_FINT_2_INT(request); if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); diff --git a/src/mpi/c/status_c2f.c b/src/mpi/c/status_c2f.c index baa63e591a..d88c544531 100644 --- a/src/mpi/c/status_c2f.c +++ b/src/mpi/c/status_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "mpi/f77/constants.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" @@ -36,13 +37,10 @@ int MPI_Status_c2f(MPI_Status *c_status, MPI_Fint *f_status) } } - /* We can't use OMPI_INT_2_FINT here because of some complications - with include files. :-( So just do the casting manually. */ - - f_status[0] = (MPI_Fint) c_status->MPI_SOURCE; - f_status[1] = (MPI_Fint) c_status->MPI_TAG; - f_status[2] = (MPI_Fint) c_status->MPI_ERROR; - f_status[3] = (MPI_Fint) c_status->_count; + f_status[0] = OMPI_INT_2_FINT(c_status->MPI_SOURCE); + f_status[1] = OMPI_INT_2_FINT(c_status->MPI_TAG); + f_status[2] = OMPI_INT_2_FINT(c_status->MPI_ERROR); + f_status[3] = OMPI_INT_2_FINT(c_status->_count); return MPI_SUCCESS; } diff --git a/src/mpi/c/status_f2c.c b/src/mpi/c/status_f2c.c index 499cf7d153..822c4b941f 100644 --- a/src/mpi/c/status_f2c.c +++ b/src/mpi/c/status_f2c.c @@ -2,10 +2,10 @@ * $HEADER$ */ #include "ompi_config.h" -#include #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "mpi/f77/constants.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" diff --git a/src/mpi/c/type_c2f.c b/src/mpi/c/type_c2f.c index 9e19bf2dce..fabe01888c 100644 --- a/src/mpi/c/type_c2f.c +++ b/src/mpi/c/type_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "datatype/datatype.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" @@ -23,17 +24,13 @@ static const char FUNC_NAME[] = "MPI_Type_c2f"; MPI_Fint MPI_Type_c2f(MPI_Datatype datatype) { - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - /* mapping an invalid handle to a null handle */ - /* not invoking an error handler */ - if (NULL == datatype) { - datatype = MPI_DATATYPE_NULL; + if (NULL == datatype) { + datatype = MPI_DATATYPE_NULL; + } } - } - /* Simple */ - - return (MPI_Fint)(datatype->d_f_to_c_index); + return OMPI_INT_2_FINT(datatype->d_f_to_c_index); } diff --git a/src/mpi/c/type_f2c.c b/src/mpi/c/type_f2c.c index 9626cadbcb..d7a16d797a 100644 --- a/src/mpi/c/type_f2c.c +++ b/src/mpi/c/type_f2c.c @@ -2,10 +2,10 @@ * $HEADER$ */ #include "ompi_config.h" -#include #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "errhandler/errhandler.h" #include "communicator/communicator.h" #include "datatype/datatype.h" @@ -23,7 +23,7 @@ static const char FUNC_NAME[] = "MPI_Type_f2c"; MPI_Datatype MPI_Type_f2c(MPI_Fint datatype) { - size_t datatype_index = (size_t) datatype; + int datatype_index = OMPI_FINT_2_INT(datatype); if (MPI_PARAM_CHECK) { OMPI_ERR_INIT_FINALIZE(FUNC_NAME); diff --git a/src/mpi/c/win_c2f.c b/src/mpi/c/win_c2f.c index 4208e0d674..e45983f29c 100644 --- a/src/mpi/c/win_c2f.c +++ b/src/mpi/c/win_c2f.c @@ -6,6 +6,7 @@ #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" @@ -22,11 +23,11 @@ static const char FUNC_NAME[] = "MPI_Win_c2f"; MPI_Fint MPI_Win_c2f(MPI_Win win) { - if (MPI_PARAM_CHECK) { - OMPI_ERR_INIT_FINALIZE(FUNC_NAME); - } + if (MPI_PARAM_CHECK) { + OMPI_ERR_INIT_FINALIZE(FUNC_NAME); + } - /* This function is not yet implemented */ + /* This function is not yet implemented */ - return (MPI_Fint) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); + return (MPI_Fint) OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_OTHER, FUNC_NAME); } diff --git a/src/mpi/c/win_f2c.c b/src/mpi/c/win_f2c.c index 7cb5a44ef0..cd514c0c57 100644 --- a/src/mpi/c/win_f2c.c +++ b/src/mpi/c/win_f2c.c @@ -2,10 +2,10 @@ * $HEADER$ */ #include "ompi_config.h" -#include #include "mpi.h" #include "mpi/c/bindings.h" +#include "mpi/f77/fint_2_int.h" #include "communicator/communicator.h" #include "errhandler/errhandler.h" diff --git a/src/request/request.c b/src/request/request.c index c2ab7a3ef4..a3a2f5fdcf 100644 --- a/src/request/request.c +++ b/src/request/request.c @@ -22,6 +22,7 @@ static void ompi_request_construct(ompi_request_t* req) req->req_fini = NULL; req->req_free = NULL; req->req_cancel = NULL; + req->req_f_to_c_index = MPI_UNDEFINED; } static void ompi_request_destruct(ompi_request_t* req) diff --git a/src/request/request.h b/src/request/request.h index 87a7c90130..3b0b59638a 100644 --- a/src/request/request.h +++ b/src/request/request.h @@ -96,8 +96,8 @@ typedef struct ompi_request_t ompi_request_t; do { \ (request)->req_state = OMPI_REQUEST_INACTIVE; \ (request)->req_complete = false; \ - (request)->req_f_to_c_index = -1; \ - } while(0); + (request)->req_f_to_c_index = MPI_UNDEFINED; \ + } while (0); /** * Finalize a request. This is a macro to avoid function call @@ -113,9 +113,10 @@ typedef struct ompi_request_t ompi_request_t; #define OMPI_REQUEST_FINI(request) \ do { \ (request)->req_state = OMPI_REQUEST_INVALID; \ - if (-1 != (request)->req_f_to_c_index) { \ + if (MPI_UNDEFINED != (request)->req_f_to_c_index) { \ ompi_pointer_array_set_item(&ompi_request_f_to_c_table, \ (request)->req_f_to_c_index, NULL); \ + (request)->req_f_to_c_index = MPI_UNDEFINED; \ } \ } while (0); diff --git a/src/util/show_help.c b/src/util/show_help.c index 7a319cf456..ad642200e4 100644 --- a/src/util/show_help.c +++ b/src/util/show_help.c @@ -233,7 +233,8 @@ static int output(bool want_error_header, ompi_pointer_array_t *lines, const char *base, const char *topic, va_list arglist) { - size_t i, len; + int i; + size_t len; char *tmp, *concat, *formatted; /* See how much space we need */ @@ -297,7 +298,7 @@ static int output(bool want_error_header, ompi_pointer_array_t *lines, */ static int destroy_message(ompi_pointer_array_t *lines) { - size_t i; + int i; char *tmp; for (i = 0; i < ompi_pointer_array_get_size(lines); ++i) {