enum_get_info.c 3.03 KB
Newer Older
1
2
3
4
5
6
7
8
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
/*
 *  (C) 2011 by Argonne National Laboratory.
 *      See COPYRIGHT in top-level directory.
 */

#include "mpiimpl.h"

9
/* -- Begin Profiling Symbol Block for routine MPI_T_enum_get_info */
10
#if defined(HAVE_PRAGMA_WEAK)
11
#pragma weak MPI_T_enum_get_info = PMPI_T_enum_get_info
12
#elif defined(HAVE_PRAGMA_HP_SEC_DEF)
13
#pragma _HP_SECONDARY_DEF PMPI_T_enum_get_info  MPI_T_enum_get_info
14
#elif defined(HAVE_PRAGMA_CRI_DUP)
15
#pragma _CRI duplicate MPI_T_enum_get_info as PMPI_T_enum_get_info
16
17
#elif defined(HAVE_WEAK_ATTRIBUTE)
int MPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len) __attribute__((weak,alias("PMPI_T_enum_get_info")));
18
19
20
21
22
23
#endif
/* -- End Profiling Symbol Block */

/* Define MPICH_MPI_FROM_PMPI if weak symbols are not supported to build
   the MPI routines */
#ifndef MPICH_MPI_FROM_PMPI
24
25
#undef MPI_T_enum_get_info
#define MPI_T_enum_get_info PMPI_T_enum_get_info
26
27
28
#endif /* MPICH_MPI_FROM_PMPI */

#undef FUNCNAME
29
#define FUNCNAME MPI_T_enum_get_info
30
31
32
#undef FCNAME
#define FCNAME MPIU_QUOTE(FUNCNAME)
/*@
33
MPI_T_enum_get_info - Get the information about an enumeration
34
35
36
37
38
39
40
41
42
43
44
45
46
47

Input/Output Parameters:
. name_len - length of the string and/or buffer for name (integer)

Input Parameters:
. enumtype - enumeration to be queried (handle)

Output Parameters:
+ num - number of discrete values represented by this enumeration (integer)
- name - buffer to return the string containing the name of the enumeration (string)

.N ThreadSafe

.N Errors
48
49
50
.N MPI_SUCCESS
.N MPI_T_ERR_NOT_INITIALIZED
.N MPI_T_ERR_INVALID_HANDLE
51
@*/
52
int MPI_T_enum_get_info(MPI_T_enum enumtype, int *num, char *name, int *name_len)
53
54
55
{
    int mpi_errno = MPI_SUCCESS;

56
    MPID_MPI_STATE_DECL(MPID_STATE_MPI_T_ENUM_GET_INFO);
Junchao Zhang's avatar
Junchao Zhang committed
57
    MPIR_ERRTEST_MPIT_INITIALIZED(mpi_errno);
58
    MPIR_T_THREAD_CS_ENTER();
59
    MPID_MPI_FUNC_ENTER(MPID_STATE_MPI_T_ENUM_GET_INFO);
60

61
    /* Validate parameters */
62
63
64
65
#   ifdef HAVE_ERROR_CHECKING
    {
        MPID_BEGIN_ERROR_CHECKS
        {
Junchao Zhang's avatar
Junchao Zhang committed
66
            MPIR_ERRTEST_ENUM_HANDLE(enumtype, mpi_errno);
67
            MPIR_ERRTEST_ARGNULL(num, "num", mpi_errno);
68
69
70
            /* Do not do _TEST_ARGNULL for name or name_len, since this is
             * permitted per MPI_T standard.
             */
71
72
73
74
75
76
77
        }
        MPID_END_ERROR_CHECKS
    }
#   endif /* HAVE_ERROR_CHECKING */

    /* ... body of routine ...  */

78
79
    *num = utarray_len(enumtype->items);
    MPIR_T_strncpy(name, enumtype->name, name_len);
80
81
82
83

    /* ... end of body of routine ... */

fn_exit:
84
    MPID_MPI_FUNC_EXIT(MPID_STATE_MPI_T_ENUM_GET_INFO);
85
    MPIR_T_THREAD_CS_EXIT();
86
87
88
89
90
91
92
93
    return mpi_errno;

fn_fail:
    /* --BEGIN ERROR HANDLING-- */
#   ifdef HAVE_ERROR_CHECKING
    {
        mpi_errno = MPIR_Err_create_code(
            mpi_errno, MPIR_ERR_RECOVERABLE, FCNAME, __LINE__, MPI_ERR_OTHER,
94
95
            "**mpi_t_enum_get_info", "**mpi_t_enum_get_info %p %p %p %p",
            enumtype, num, name, name_len);
96
97
98
99
100
101
    }
#   endif
    mpi_errno = MPIR_Err_return_comm(NULL, FCNAME, mpi_errno);
    goto fn_exit;
    /* --END ERROR HANDLING-- */
}