Blame src/include/mpir_errhandler.h

Packit Service c5cf8c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit Service c5cf8c
/*
Packit Service c5cf8c
 *  (C) 2001 by Argonne National Laboratory.
Packit Service c5cf8c
 *      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
 *
Packit Service c5cf8c
 */
Packit Service c5cf8c
Packit Service c5cf8c
#ifndef MPIR_ERRHANDLER_H_INCLUDED
Packit Service c5cf8c
#define MPIR_ERRHANDLER_H_INCLUDED
Packit Service c5cf8c
Packit Service c5cf8c
/*E
Packit Service c5cf8c
  errhandler_fn - MPIR Structure to hold an error handler function
Packit Service c5cf8c
Packit Service c5cf8c
  Notes:
Packit Service c5cf8c
  The MPI-1 Standard declared only the C version of this, implicitly
Packit Service c5cf8c
  assuming that 'int' and 'MPI_Fint' were the same.
Packit Service c5cf8c
Packit Service c5cf8c
  Since Fortran does not have a C-style variable number of arguments
Packit Service c5cf8c
  interface, the Fortran interface simply accepts two arguments.  Some
Packit Service c5cf8c
  calling conventions for Fortran (particularly under Windows) require
Packit Service c5cf8c
  this.
Packit Service c5cf8c
Packit Service c5cf8c
  Module:
Packit Service c5cf8c
  ErrHand-DS
Packit Service c5cf8c
Packit Service c5cf8c
  Questions:
Packit Service c5cf8c
  What do we want to do about C++?  Do we want a hook for a routine that can
Packit Service c5cf8c
  be called to throw an exception in C++, particularly if we give C++ access
Packit Service c5cf8c
  to this structure?  Does the C++ handler need to be different (not part
Packit Service c5cf8c
  of the union)?
Packit Service c5cf8c
Packit Service c5cf8c
  E*/
Packit Service c5cf8c
typedef union errhandler_fn {
Packit Service c5cf8c
    void (*C_Comm_Handler_function) (MPI_Comm *, int *, ...);
Packit Service c5cf8c
    void (*F77_Handler_function) (MPI_Fint *, MPI_Fint *);
Packit Service c5cf8c
    void (*C_Win_Handler_function) (MPI_Win *, int *, ...);
Packit Service c5cf8c
    void (*C_File_Handler_function) (MPI_File *, int *, ...);
Packit Service c5cf8c
} errhandler_fn;
Packit Service c5cf8c
Packit Service c5cf8c
/*S
Packit Service c5cf8c
  MPIR_Errhandler - Description of the error handler structure
Packit Service c5cf8c
Packit Service c5cf8c
  Notes:
Packit Service c5cf8c
  Device-specific information may indicate whether the error handler is active;
Packit Service c5cf8c
  this can help prevent infinite recursion in error handlers caused by
Packit Service c5cf8c
  user-error without requiring the user to be as careful.  We might want to
Packit Service c5cf8c
  make this part of the interface so that the 'MPI_xxx_call_errhandler'
Packit Service c5cf8c
  routines would check.
Packit Service c5cf8c
Packit Service c5cf8c
  It is useful to have a way to indicate that the errhandler is no longer
Packit Service c5cf8c
  valid, to help catch the case where the user has freed the errhandler but
Packit Service c5cf8c
  is still using a copy of the 'MPI_Errhandler' value.  We may want to
Packit Service c5cf8c
  define the 'id' value for deleted errhandlers.
Packit Service c5cf8c
Packit Service c5cf8c
  Module:
Packit Service c5cf8c
  ErrHand-DS
Packit Service c5cf8c
  S*/
Packit Service c5cf8c
typedef struct MPIR_Errhandler {
Packit Service c5cf8c
    MPIR_OBJECT_HEADER;         /* adds handle and ref_count fields */
Packit Service c5cf8c
    MPIR_Lang_t language;
Packit Service c5cf8c
    MPII_Object_kind kind;
Packit Service c5cf8c
    errhandler_fn errfn;
Packit Service c5cf8c
    /* Other, device-specific information */
Packit Service c5cf8c
#ifdef MPID_DEV_ERRHANDLER_DECL
Packit Service c5cf8c
     MPID_DEV_ERRHANDLER_DECL
Packit Service c5cf8c
#endif
Packit Service c5cf8c
} MPIR_Errhandler;
Packit Service c5cf8c
extern MPIR_Object_alloc_t MPIR_Errhandler_mem;
Packit Service c5cf8c
/* Preallocated errhandler objects */
Packit Service c5cf8c
#define MPIR_ERRHANDLER_N_BUILTIN 3
Packit Service c5cf8c
extern MPIR_Errhandler MPIR_Errhandler_builtin[];
Packit Service c5cf8c
extern MPIR_Errhandler MPIR_Errhandler_direct[];
Packit Service c5cf8c
Packit Service c5cf8c
/* We never reference count the builtin error handler objects, regardless of how
Packit Service c5cf8c
 * we decide to reference count the other predefined objects.  If we get to the
Packit Service c5cf8c
 * point where we never reference count *any* of the builtin objects then we
Packit Service c5cf8c
 * should probably remove these checks and let them fall through to the checks
Packit Service c5cf8c
 * for BUILTIN down in the MPIR_Object_* routines. */
Packit Service c5cf8c
#define MPIR_Errhandler_add_ref(_errhand)                               \
Packit Service c5cf8c
    do {                                                                  \
Packit Service c5cf8c
        if (HANDLE_GET_KIND((_errhand)->handle) != HANDLE_KIND_BUILTIN) { \
Packit Service c5cf8c
            MPIR_Object_add_ref(_errhand);                              \
Packit Service c5cf8c
        }                                                                 \
Packit Service c5cf8c
    } while (0)
Packit Service c5cf8c
#define MPIR_Errhandler_release_ref(_errhand, _inuse)                   \
Packit Service c5cf8c
    do {                                                                  \
Packit Service c5cf8c
        if (HANDLE_GET_KIND((_errhand)->handle) != HANDLE_KIND_BUILTIN) { \
Packit Service c5cf8c
            MPIR_Object_release_ref((_errhand), (_inuse));              \
Packit Service c5cf8c
        }                                                                 \
Packit Service c5cf8c
        else {                                                            \
Packit Service c5cf8c
            *(_inuse) = 1;                                                \
Packit Service c5cf8c
        }                                                                 \
Packit Service c5cf8c
    } while (0)
Packit Service c5cf8c
Packit Service c5cf8c
void MPIR_Errhandler_free(MPIR_Errhandler * errhan_ptr);
Packit Service c5cf8c
Packit Service c5cf8c
#endif /* MPIR_ERRHANDLER_H_INCLUDED */