Blame src/mpi_t/enum_get_item.c

Packit 0848f5
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit 0848f5
/*
Packit 0848f5
 *  (C) 2011 by Argonne National Laboratory.
Packit 0848f5
 *      See COPYRIGHT in top-level directory.
Packit 0848f5
 */
Packit 0848f5
Packit 0848f5
#include "mpiimpl.h"
Packit 0848f5
Packit 0848f5
/* -- Begin Profiling Symbol Block for routine MPI_T_enum_get_item */
Packit 0848f5
#if defined(HAVE_PRAGMA_WEAK)
Packit 0848f5
#pragma weak MPI_T_enum_get_item = PMPI_T_enum_get_item
Packit 0848f5
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
Packit 0848f5
#pragma _HP_SECONDARY_DEF PMPI_T_enum_get_item  MPI_T_enum_get_item
Packit 0848f5
#elif defined(HAVE_PRAGMA_CRI_DUP)
Packit 0848f5
#pragma _CRI duplicate MPI_T_enum_get_item as PMPI_T_enum_get_item
Packit 0848f5
#elif defined(HAVE_WEAK_ATTRIBUTE)
Packit 0848f5
int MPI_T_enum_get_item(MPI_T_enum enumtype, int indx, int *value, char *name, int *name_len) __attribute__((weak,alias("PMPI_T_enum_get_item")));
Packit 0848f5
#endif
Packit 0848f5
/* -- End Profiling Symbol Block */
Packit 0848f5
Packit 0848f5
/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
Packit 0848f5
   the MPI routines */
Packit 0848f5
#ifndef MPICH_MPI_FROM_PMPI
Packit 0848f5
#undef MPI_T_enum_get_item
Packit 0848f5
#define MPI_T_enum_get_item PMPI_T_enum_get_item
Packit 0848f5
#endif /* MPICH_MPI_FROM_PMPI */
Packit 0848f5
Packit 0848f5
#undef FUNCNAME
Packit 0848f5
#define FUNCNAME MPI_T_enum_get_item
Packit 0848f5
#undef FCNAME
Packit 0848f5
#define FCNAME MPL_QUOTE(FUNCNAME)
Packit 0848f5
/*@
Packit 0848f5
MPI_T_enum_get_item - Get the information about an item in an enumeration
Packit 0848f5
Packit 0848f5
Input/Output Parameters:
Packit 0848f5
. name_len - length of the string and/or buffer for name (integer)
Packit 0848f5
Packit 0848f5
Input Parameters:
Packit 0848f5
. enumtype - enumeration to be queried (handle)
Packit 0848f5
Packit 0848f5
Output Parameters:
Packit 0848f5
+ index - number of the value to be queried in this enumeration (integer)
Packit 0848f5
. value - variable value (integer)
Packit 0848f5
- name - buffer to return the string containing the name of the enumeration item (string)
Packit 0848f5
Packit 0848f5
.N ThreadSafe
Packit 0848f5
Packit 0848f5
.N Errors
Packit 0848f5
.N MPI_SUCCESS
Packit 0848f5
.N MPI_T_ERR_NOT_INITIALIZED
Packit 0848f5
.N MPI_T_ERR_INVALID_HANDLE
Packit 0848f5
.N MPI_T_ERR_INVALID_ITEM
Packit 0848f5
@*/
Packit 0848f5
int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name, int *name_len)
Packit 0848f5
{
Packit 0848f5
    int mpi_errno = MPI_SUCCESS;
Packit 0848f5
    enum_item_t *item;
Packit 0848f5
Packit 0848f5
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_ENUM_GET_ITEM);
Packit 0848f5
    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
Packit 0848f5
    MPIR_T_THREAD_CS_ENTER();
Packit 0848f5
    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_ENUM_GET_ITEM);
Packit 0848f5
Packit 0848f5
    /* Validate parameters */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
        MPID_BEGIN_ERROR_CHECKS
Packit 0848f5
        {
Packit 0848f5
            MPIR_ERRTEST_ENUM_HANDLE(enumtype, mpi_errno);
Packit 0848f5
            MPIR_ERRTEST_ENUM_ITEM(enumtype, index, mpi_errno);
Packit 0848f5
            MPIR_ERRTEST_ARGNULL(value, "value", mpi_errno);
Packit 0848f5
            /* Do not do TEST_ARGNULL for name or name_len, since this is
Packit 0848f5
             * permitted per MPI_T standard.
Packit 0848f5
             */
Packit 0848f5
        }
Packit 0848f5
        MPID_END_ERROR_CHECKS
Packit 0848f5
    }
Packit 0848f5
#   endif /* HAVE_ERROR_CHECKING */
Packit 0848f5
Packit 0848f5
    /* ... body of routine ...  */
Packit 0848f5
Packit 0848f5
    item = (enum_item_t *)utarray_eltptr(enumtype->items, index);
Packit 0848f5
    *value = item->value;
Packit 0848f5
    MPIR_T_strncpy(name, item->name, name_len);
Packit 0848f5
Packit 0848f5
    /* ... end of body of routine ... */
Packit 0848f5
Packit 0848f5
fn_exit:
Packit 0848f5
    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_T_ENUM_GET_ITEM);
Packit 0848f5
    MPIR_T_THREAD_CS_EXIT();
Packit 0848f5
    return mpi_errno;
Packit 0848f5
Packit 0848f5
fn_fail:
Packit 0848f5
    /* --BEGIN ERROR HANDLING-- */
Packit 0848f5
#   ifdef HAVE_ERROR_CHECKING
Packit 0848f5
    {
Packit 0848f5
        mpi_errno = MPIR_Err_create_code(
Packit 0848f5
            mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
Packit 0848f5
            "**mpi_t_enum_get_item", "**mpi_t_enum_get_item %p %d %p %p %p",
Packit 0848f5
            enumtype, index, value, name, name_len);
Packit 0848f5
    }
Packit 0848f5
#   endif
Packit 0848f5
    mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
Packit 0848f5
    goto fn_exit;
Packit 0848f5
    /* --END ERROR HANDLING-- */
Packit 0848f5
}