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-2008 The University of Tennessee and The University
7  *                         of Tennessee Research Foundation.  All rights
8  *                         reserved.
9  * Copyright (c) 2004-2008 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) 2006      Cisco Systems, Inc.  All rights reserved.
14  * Copyright (c) 2006-2008 University of Houston.  All rights reserved.
15  * Copyright (c) 2013      Los Alamos National Security, LLC.  All rights
16  *                         reserved.
17  * Copyright (c) 2015      Research Organization for Information Science
18  *                         and Technology (RIST). All rights reserved.
19  * $COPYRIGHT$
20  *
21  * Additional copyrights may follow
22  *
23  * $HEADER$
24  */
25 #include "ompi_config.h"
26 #include <stdio.h>
27 
28 #include "ompi/mpi/c/bindings.h"
29 #include "ompi/runtime/params.h"
30 #include "ompi/communicator/communicator.h"
31 #include "ompi/errhandler/errhandler.h"
32 #include "ompi/memchecker.h"
33 
34 #if OMPI_BUILD_MPI_PROFILING
35 #if OPAL_HAVE_WEAK_SYMBOLS
36 #pragma weak MPI_Comm_idup = PMPI_Comm_idup
37 #endif
38 #define MPI_Comm_idup PMPI_Comm_idup
39 #endif
40 
41 static const char FUNC_NAME[] = "MPI_Comm_idup";
42 
MPI_Comm_idup(MPI_Comm comm,MPI_Comm * newcomm,MPI_Request * request)43 int MPI_Comm_idup(MPI_Comm comm, MPI_Comm *newcomm, MPI_Request *request)
44 {
45     int rc;
46 
47     MEMCHECKER(
48         memchecker_comm(comm);
49     );
50 
51     /* argument checking */
52     if ( MPI_PARAM_CHECK ) {
53         OMPI_ERR_INIT_FINALIZE(FUNC_NAME);
54 
55         if (ompi_comm_invalid (comm))
56             return OMPI_ERRHANDLER_INVOKE(MPI_COMM_WORLD, MPI_ERR_COMM,
57                                           FUNC_NAME);
58 
59         if ( NULL == newcomm )
60             return OMPI_ERRHANDLER_INVOKE(comm, MPI_ERR_ARG,
61                                           FUNC_NAME);
62     }
63 
64     OPAL_CR_ENTER_LIBRARY();
65 
66     rc = ompi_comm_idup (comm, newcomm, request);
67     OMPI_ERRHANDLER_RETURN(rc, comm, rc, FUNC_NAME);
68 }
69 
70