X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/7945dd060a9ae14801914ef3be75f4abf083039b..1509a50e35dbcad0fe6c99e059fb5b2aba1143f2:/src/smpi/bindings/smpi_pmpi.cpp diff --git a/src/smpi/bindings/smpi_pmpi.cpp b/src/smpi/bindings/smpi_pmpi.cpp index 49b2b370ee..933894a518 100644 --- a/src/smpi/bindings/smpi_pmpi.cpp +++ b/src/smpi/bindings/smpi_pmpi.cpp @@ -10,7 +10,7 @@ #include "smpi_comm.hpp" #include "smpi_datatype_derived.hpp" #include "smpi_status.hpp" -#include "src/simix/ActorImpl.hpp" +#include "src/kernel/actor/ActorImpl.hpp" #include "src/smpi/include/smpi_actor.hpp" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_pmpi, smpi, "Logging specific to SMPI (pmpi)"); @@ -31,7 +31,7 @@ void TRACE_smpi_set_category(const char *category) /* PMPI User level calls */ -int PMPI_Init(int *argc, char ***argv) +int PMPI_Init(int*, char***) { xbt_assert(simgrid::s4u::Engine::is_initialized(), "Your MPI program was not properly initialized. The easiest is to use smpirun to start it."); @@ -142,7 +142,7 @@ double PMPI_Wtick() return sg_maxmin_precision; } -int PMPI_Address(void *location, MPI_Aint * address) +int PMPI_Address(const void* location, MPI_Aint* address) { if (address==nullptr) { return MPI_ERR_ARG; @@ -152,7 +152,7 @@ int PMPI_Address(void *location, MPI_Aint * address) } } -int PMPI_Get_address(void *location, MPI_Aint * address) +int PMPI_Get_address(const void *location, MPI_Aint * address) { return PMPI_Address(location, address); } @@ -167,7 +167,7 @@ int PMPI_Get_processor_name(char *name, int *resultlen) return MPI_SUCCESS; } -int PMPI_Get_count(MPI_Status * status, MPI_Datatype datatype, int *count) +int PMPI_Get_count(const MPI_Status * status, MPI_Datatype datatype, int *count) { if (status == nullptr || count == nullptr) { return MPI_ERR_ARG; @@ -214,17 +214,16 @@ int PMPI_Error_class(int errorcode, int* errorclass) { return MPI_SUCCESS; } -int PMPI_Error_string(int errorcode, char* string, int* resultlen){ - if (errorcode<0 || string ==nullptr){ +int PMPI_Error_string(int errorcode, char* string, int* resultlen) +{ + static const char* smpi_error_string[] = {FOREACH_ERROR(GENERATE_STRING)}; + constexpr int nerrors = (sizeof smpi_error_string) / (sizeof smpi_error_string[0]); + if (errorcode < 0 || errorcode >= nerrors || string == nullptr) return MPI_ERR_ARG; - } else { - static const char *smpi_error_string[] = { - FOREACH_ERROR(GENERATE_STRING) - }; - *resultlen = strlen(smpi_error_string[errorcode]); - strncpy(string, smpi_error_string[errorcode], *resultlen); - return MPI_SUCCESS; - } + + int len = snprintf(string, MPI_MAX_ERROR_STRING, "%s", smpi_error_string[errorcode]); + *resultlen = std::min(len, MPI_MAX_ERROR_STRING - 1); + return MPI_SUCCESS; } int PMPI_Keyval_create(MPI_Copy_function* copy_fn, MPI_Delete_function* delete_fn, int* keyval, void* extra_state) {