This source file includes following definitions.
- MPI_Comm_set_errhandler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #include "ompi_config.h"
24 #include <stdio.h>
25
26 #include "ompi/mpi/c/bindings.h"
27 #include "ompi/runtime/params.h"
28 #include "ompi/communicator/communicator.h"
29 #include "ompi/errhandler/errhandler.h"
30 #include "ompi/memchecker.h"
31
32 #if OMPI_BUILD_MPI_PROFILING
33 #if OPAL_HAVE_WEAK_SYMBOLS
34 #pragma weak MPI_Comm_set_errhandler = PMPI_Comm_set_errhandler
35 #endif
36 #define MPI_Comm_set_errhandler PMPI_Comm_set_errhandler
37 #endif
38
39 static const char FUNC_NAME[] = "MPI_Comm_set_errhandler";
40
41
42 int MPI_Comm_set_errhandler(MPI_Comm comm, MPI_Errhandler errhandler)
43 {
44 MPI_Errhandler tmp;
45
46
47 MEMCHECKER(
48 memchecker_comm(comm);
49 );
50
51 OPAL_CR_NOOP_PROGRESS();
52
53
54
55 if (MPI_PARAM_CHECK) {
56 OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
57 if (ompi_comm_invalid(comm)) {
58 return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
59 FUNC_NAME);
60 } else if (NULL == errhandler ||
61 MPI_ERRHANDLER_NULL == errhandler ||
62 ( OMPI_ERRHANDLER_TYPE_COMM != errhandler->eh_mpi_object_type &&
63 OMPI_ERRHANDLER_TYPE_PREDEFINED != errhandler->eh_mpi_object_type) ) {
64 return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
65 FUNC_NAME);
66 }
67 }
68
69
70 OBJ_RETAIN(errhandler);
71
72 OPAL_THREAD_LOCK(&(comm->c_lock));
73
74 tmp = comm->error_handler;
75 comm->error_handler = errhandler;
76 OBJ_RELEASE(tmp);
77 OPAL_THREAD_UNLOCK(&(comm->c_lock));
78
79
80 return MPI_SUCCESS;
81 }