root/ompi/mpi/c/file_set_errhandler.c

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

DEFINITIONS

This source file includes following definitions.
  1. MPI_File_set_errhandler

   1 /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2004-2005 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) 2008      Cisco Systems, Inc.  All rights reserved.
  14  * Copyright (c) 2015-2017 Research Organization for Information Science
  15  *                         and Technology (RIST). All rights reserved.
  16  * Copyright (c) 2016-2017 Los Alamos National Security, LLC. All rights
  17  *                         reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  */
  24 
  25 #include "ompi_config.h"
  26 
  27 #include "ompi/mpi/c/bindings.h"
  28 #include "ompi/runtime/params.h"
  29 #include "ompi/errhandler/errhandler.h"
  30 #include "ompi/file/file.h"
  31 
  32 #if OMPI_BUILD_MPI_PROFILING
  33 #if OPAL_HAVE_WEAK_SYMBOLS
  34 #pragma weak MPI_File_set_errhandler = PMPI_File_set_errhandler
  35 #endif
  36 #define MPI_File_set_errhandler PMPI_File_set_errhandler
  37 #endif
  38 
  39 static const char FUNC_NAME[] = "MPI_File_set_errhandler";
  40 
  41 
  42 int MPI_File_set_errhandler( MPI_File file, MPI_Errhandler errhandler)
  43 {
  44     MPI_Errhandler tmp;
  45 
  46     OPAL_CR_NOOP_PROGRESS();
  47 
  48     /* Error checking */
  49 
  50     if (MPI_PARAM_CHECK) {
  51         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
  52 
  53         /* Note that MPI-2:9.7 (p265 in the ps; p261 in the pdf)
  54            explicitly says that you are allowed to set the error
  55            handler on MPI_FILE_NULL */
  56 
  57         if (NULL == file) {
  58             return OMPI_ERRHANDLER_INVOKE(MPI_FILE_NULL, MPI_ERR_FILE,
  59                                           FUNC_NAME);
  60         } else if (NULL == errhandler ||
  61                    MPI_ERRHANDLER_NULL == errhandler ||
  62                    (OMPI_ERRHANDLER_TYPE_FILE != errhandler->eh_mpi_object_type &&
  63                     OMPI_ERRHANDLER_TYPE_PREDEFINED != errhandler->eh_mpi_object_type) ) {
  64             return OMPI_ERRHANDLER_INVOKE(file, MPI_ERR_ARG, FUNC_NAME);
  65         }
  66     }
  67 
  68     /* Prepare the new error handler */
  69     OBJ_RETAIN(errhandler);
  70 
  71     OPAL_THREAD_LOCK(&file->f_lock);
  72     /* Ditch the old errhandler, and decrement its refcount. */
  73     tmp = file->error_handler;
  74     file->error_handler = errhandler;
  75     OBJ_RELEASE(tmp);
  76     OPAL_THREAD_UNLOCK(&file->f_lock);
  77 
  78     /* All done */
  79     return MPI_SUCCESS;
  80 }

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