OpenMPI  0.1.1
errcode-internal.h
Go to the documentation of this file.
1 /* -*- Mode: C; c-basic-offset:4 ; -*- */
2 /*
3  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4  * University Research and Technology
5  * Corporation. All rights reserved.
6  * Copyright (c) 2004-2007 The University of Tennessee and The University
7  * of Tennessee Research Foundation. All rights
8  * reserved.
9  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10  * University of Stuttgart. All rights reserved.
11  * Copyright (c) 2004-2005 The Regents of the University of California.
12  * All rights reserved.
13  * Copyright (c) 2010 Cisco Systems, Inc. All rights reserved.
14  * Copyright (c) 2010 Oracle and/or its affiliates. All rights reserved.
15  * $COPYRIGHT$
16  *
17  * Additional copyrights may follow
18  *
19  * $HEADER$
20  */
21 /** @file **/
22 
23 #ifndef OMPI_ERRCODE_INTERN_H
24 #define OMPI_ERRCODE_INTERN_H
25 
26 #include "ompi_config.h"
27 
28 #include "mpi.h"
29 #include "ompi/constants.h"
30 #include "opal/class/opal_object.h"
32 #include "opal/util/opal_sos.h"
33 
34 #define OMPI_MAX_ERROR_STRING 64
35 
36 BEGIN_C_DECLS
37 
38 /**
39  * Back-end type for MPI error codes
40  */
42  opal_object_t super;
43  int code;
44  int mpi_code;
45  int index;
46  char errstring[OMPI_MAX_ERROR_STRING];
47 };
49 
50 OMPI_DECLSPEC extern opal_pointer_array_t ompi_errcodes_intern;
51 OMPI_DECLSPEC extern int ompi_errcode_intern_lastused;
52 
53 /**
54  * Return the MPI errcode for a given internal error code. This
55  * function guarantees to return a non-OPAL_SOS-encoded error code.
56  */
57 static inline int ompi_errcode_get_mpi_code(int errcode)
58 {
59  int ret = MPI_ERR_UNKNOWN;
60  int i;
62 
63  /* Transmogrify, if necessary */
64  errcode = OPAL_SOS_GET_ERROR_CODE(errcode);
65 
66  /* If the errcode is >= 0, then it's already an MPI error code, so
67  just return it. */
68  if (errcode >= 0) {
69  return errcode;
70  }
71 
72  /* Otherwise, it's an internal OMPI code and we need to translate
73  it */
74  for (i = 0; i < ompi_errcode_intern_lastused; i++) {
75  errc = (ompi_errcode_intern_t *)opal_pointer_array_get_item(&ompi_errcodes_intern, i);
76  if (errc->code == errcode) {
77  ret = errc->mpi_code;
78  break;
79  }
80  }
81  return ret;
82 }
83 
84 /**
85  * Initialize the error codes
86  *
87  * @returns OMPI_SUCCESS Upon success
88  * @returns OMPI_ERROR Otherwise
89  *
90  * Invoked from ompi_mpi_init(); sets up all static MPI error codes,
91  */
92 int ompi_errcode_intern_init(void);
93 
94 /**
95  * Finalize the error codes.
96  *
97  * @returns OMPI_SUCCESS Always
98  *
99  * Invokes from ompi_mpi_finalize(); tears down the error code array.
100  */
102 
103 END_C_DECLS
104 
105 #endif /* OMPI_ERRCODE_INTERNAL_H */
Back-end type for MPI error codes.
Definition: errcode-internal.h:41
dynamic pointer array
Definition: opal_pointer_array.h:45
int ompi_errcode_intern_init(void)
Initialize the error codes.
Definition: errcode-internal.c:54
int ompi_errcode_intern_finalize(void)
Finalize the error codes.
Definition: errcode-internal.c:199
static void * opal_pointer_array_get_item(opal_pointer_array_t *table, int element_index)
Get the value of an element in array.
Definition: opal_pointer_array.h:125
See opal_bitmap.h for an explanation of why there is a split between OPAL and ORTE for this generic c...
static int ompi_errcode_get_mpi_code(int errcode)
Return the MPI errcode for a given internal error code.
Definition: errcode-internal.h:57
Base object.
Definition: opal_object.h:182
A simple C-language object-oriented system with single inheritance and ownership-based memory managem...