From b3f2daa8ba97d28b224597331ac3b8d9a719aa30 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Wed, 15 Feb 2017 17:27:37 +0100 Subject: [PATCH] make the C and Fortran interfaces of SMPI as extern C also in the code This is useless because they are also marked as such in the header files, but sonar only notices if they are marked in the implementation too. Also do some tiny changes to please sonar. --- src/smpi/smpi_f77.cpp | 4 +++- src/smpi/smpi_mpi.cpp | 2 ++ src/smpi/smpi_pmpi.cpp | 2 ++ teshsuite/smpi/type-vector/type-vector.c | 10 +++++----- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/smpi/smpi_f77.cpp b/src/smpi/smpi_f77.cpp index 8e59d00489..17ed153abd 100644 --- a/src/smpi/smpi_f77.cpp +++ b/src/smpi/smpi_f77.cpp @@ -10,7 +10,6 @@ #include "private.h" #include "xbt.h" - //TODO : remove all this. static xbt_dict_t comm_lookup = nullptr; static xbt_dict_t group_lookup = nullptr; @@ -252,6 +251,8 @@ type smpi_##name##_f2c(int id){\ return smpi_f2c(id, name##_lookup);\ } +extern "C" { // This should really use the C linkage to be usable from Fortran + SMPI_F2C_C2F(MPI_Comm, comm) SMPI_F2C_C2F(MPI_Group, group) SMPI_F2C_C2F(MPI_Request, request) @@ -1770,3 +1771,4 @@ void mpi_file_write_ ( int* fh, void* buf, int* count, int* datatype, MPI_Status *ierr= MPI_File_write(reinterpret_cast(*fh), buf, *count, smpi_type_f2c(*datatype), status); } +} // extern "C" diff --git a/src/smpi/smpi_mpi.cpp b/src/smpi/smpi_mpi.cpp index f462a32db5..2ca0704bfa 100644 --- a/src/smpi/smpi_mpi.cpp +++ b/src/smpi/smpi_mpi.cpp @@ -30,6 +30,7 @@ return P##name args2 ; \ /* MPI User level calls */ +extern "C" { // Obviously, the C MPI interface should use the C linkage WRAPPED_PMPI_CALL(double, MPI_Wtick,(void),()) WRAPPED_PMPI_CALL(double, MPI_Wtime,(void),()) @@ -316,3 +317,4 @@ UNIMPLEMENTED_WRAPPED_PMPI_CALL(int,MPI_Win_unlock,(int rank, MPI_Win win),(rank UNIMPLEMENTED_WRAPPED_PMPI_CALL(MPI_Errhandler, MPI_Errhandler_f2c,(MPI_Fint errhandler),(errhandler)) UNIMPLEMENTED_WRAPPED_PMPI_CALL(MPI_Fint, MPI_Errhandler_c2f,(MPI_Errhandler errhandler),(errhandler)) +} // extern "C" diff --git a/src/smpi/smpi_pmpi.cpp b/src/smpi/smpi_pmpi.cpp index e51c138b6d..0cb559ce3c 100644 --- a/src/smpi/smpi_pmpi.cpp +++ b/src/smpi/smpi_pmpi.cpp @@ -22,6 +22,7 @@ void TRACE_smpi_set_category(const char *category) } /* PMPI User level calls */ +extern "C" { // Obviously, the C MPI interface should use the C linkage int PMPI_Init(int *argc, char ***argv) { @@ -3345,3 +3346,4 @@ int PMPI_Pack_size(int incount, MPI_Datatype datatype, MPI_Comm comm, int* size) return MPI_SUCCESS; } +} // extern "C" diff --git a/teshsuite/smpi/type-vector/type-vector.c b/teshsuite/smpi/type-vector/type-vector.c index 2a9a129e60..77255aefa7 100644 --- a/teshsuite/smpi/type-vector/type-vector.c +++ b/teshsuite/smpi/type-vector/type-vector.c @@ -9,7 +9,7 @@ #define SIZE 4 int main(int argc, char **argv) { - int rank, i, j; + int rank; double a[SIZE][SIZE] = {{0}}; MPI_Datatype columntype; @@ -21,16 +21,16 @@ int main(int argc, char **argv) { MPI_Type_commit(&columntype); if (rank == 0) { - for(i=0; i