root/ompi/mpi/tool/enum_get_item.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. MPI_T_enum_get_item

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2012-2013 Los Alamos National Security, LLC. All rights
   4  *                         reserved.
   5  * Copyright (c) 2014 Cisco Systems, Inc.  All rights reserved.
   6  * Copyright (c) 2017      IBM Corporation. All rights reserved.
   7  * $COPYRIGHT$
   8  *
   9  * Additional copyrights may follow
  10  *
  11  * $HEADER$
  12  */
  13 
  14 #include "ompi/mpi/tool/mpit-internal.h"
  15 
  16 #if OPAL_HAVE_WEAK_SYMBOLS && OMPI_PROFILING_DEFINES
  17 #pragma weak MPI_T_enum_get_item = PMPI_T_enum_get_item
  18 #endif
  19 
  20 #if OMPI_PROFILING_DEFINES
  21 #include "ompi/mpi/tool/profile/defines.h"
  22 #endif
  23 
  24 
  25 int MPI_T_enum_get_item(MPI_T_enum enumtype, int index, int *value, char *name,
  26                         int *name_len)
  27 {
  28     const char *tmp;
  29     int rc, count;
  30 
  31     if (!mpit_is_initialized ()) {
  32         return MPI_T_ERR_NOT_INITIALIZED;
  33     }
  34 
  35     ompi_mpit_lock ();
  36 
  37     do {
  38         rc = enumtype->get_count (enumtype, &count);
  39         if (OPAL_SUCCESS != rc) {
  40             rc = MPI_ERR_OTHER;
  41             break;
  42         }
  43 
  44         if (index >= count) {
  45             rc = MPI_T_ERR_INVALID_INDEX;
  46             break;
  47         }
  48 
  49         rc = enumtype->get_value(enumtype, index, value, &tmp);
  50         if (OPAL_SUCCESS != rc) {
  51             rc = MPI_ERR_OTHER;
  52             break;
  53         }
  54 
  55         mpit_copy_string(name, name_len, tmp);
  56     } while (0);
  57 
  58     ompi_mpit_unlock ();
  59 
  60     return rc;
  61 }

/* [<][>][^][v][top][bottom][index][help] */