#include <sys/mman.h> // PROT_*
#include <memory>
+#include <string>
using simgrid::mc::remote;
int open_vm(pid_t pid, int flags)
{
- const size_t buffer_size = 30;
- char buffer[buffer_size];
- int res = snprintf(buffer, buffer_size, "/proc/%lli/mem", (long long)pid);
- if (res < 0 || (size_t)res >= buffer_size) {
- errno = ENAMETOOLONG;
- return -1;
- }
- return open(buffer, flags);
+ std::string buffer = "/proc/" + std::to_string(pid) + "/mem";
+ return open(buffer.c_str(), flags);
}
// ***** RemoteSimulation
#include "smpi_win.hpp"
#include "src/smpi/include/smpi_actor.hpp"
+#include <string>
+
static int running_processes = 0;
void smpi_init_fortran_types()
size--;
name++;
}
- char* tname = xbt_new(char,size+1);
- strncpy(tname, name, size);
- tname[size]='\0';
- *ierr = MPI_Win_set_name(simgrid::smpi::Win::f2c(*win), tname);
- xbt_free(tname);
+ std::string tname(name, size);
+ *ierr = MPI_Win_set_name(simgrid::smpi::Win::f2c(*win), tname.c_str());
}
void mpi_win_get_name_(int* win, char* name, int* len, int* ierr)
keylen--;
key++;
}
- char* tkey = xbt_new(char,keylen+1);
- strncpy(tkey, key, keylen);
- tkey[keylen]='\0';
+ std::string tkey(key, keylen);
while(value[valuelen-1]==' ')
valuelen--;
valuelen--;
value++;
}
- char* tvalue = xbt_new(char,valuelen+1);
- strncpy(tvalue, value, valuelen);
- tvalue[valuelen]='\0';
+ std::string tvalue(value, valuelen);
- *ierr = MPI_Info_set( simgrid::smpi::Info::f2c(*info), tkey, tvalue);
- xbt_free(tkey);
- xbt_free(tvalue);
+ *ierr = MPI_Info_set(simgrid::smpi::Info::f2c(*info), tkey.c_str(), tvalue.c_str());
}
void mpi_info_get_(int* info, char* key, int* valuelen, char* value, int* flag, int* ierr, unsigned int keylen)
keylen--;
key++;
}
- char* tkey = xbt_new(char,keylen+1);
- strncpy(tkey, key, keylen);
- tkey[keylen]='\0';
- *ierr = MPI_Info_get(simgrid::smpi::Info::f2c(*info),tkey,*valuelen, value, flag);
- xbt_free(tkey);
+ std::string tkey(key, keylen);
+ *ierr = MPI_Info_get(simgrid::smpi::Info::f2c(*info), tkey.c_str(), *valuelen, value, flag);
if(*flag!=0){
int replace=0;
for (int i = 0; i < *valuelen; i++) {
keylen--;
key++;
}
- char* tkey = xbt_new(char, keylen+1);
- strncpy(tkey, key, keylen);
- tkey[keylen]='\0';
- *ierr = MPI_Info_get_valuelen( simgrid::smpi::Info::f2c(*info), tkey, valuelen, flag);
- xbt_free(tkey);
+ std::string tkey(key, keylen);
+ *ierr = MPI_Info_get_valuelen(simgrid::smpi::Info::f2c(*info), tkey.c_str(), valuelen, flag);
}
void mpi_info_delete_ (int* info, char *key, int* ierr, unsigned int keylen){
keylen--;
key++;
}
- char* tkey = xbt_new(char, keylen+1);
- strncpy(tkey, key, keylen);
- tkey[keylen]='\0';
- *ierr = MPI_Info_delete(simgrid::smpi::Info::f2c(*info), tkey);
- xbt_free(tkey);
+ std::string tkey(key, keylen);
+ *ierr = MPI_Info_delete(simgrid::smpi::Info::f2c(*info), tkey.c_str());
}
void mpi_info_get_nkeys_ ( int* info, int *nkeys, int* ierr){
#include "smpi_errhandler.hpp"
#include "smpi_info.hpp"
+#include <string>
+
extern "C" { // This should really use the C linkage to be usable from Fortran
void mpi_comm_rank_(int* comm, int* rank, int* ierr) {
int count;
for(count=MPI_MAX_OBJECT_NAME-1; count>=0 && name[count]==' '; count--);
count+=1;
- char* tname = xbt_new(char, count+1);
- strncpy(tname, name, count);
- tname[count]='\0';
- *ierr = MPI_Comm_set_name (simgrid::smpi::Comm::f2c(*comm), tname);
- xbt_free(tname);
+ std::string tname(name, count);
+ *ierr = MPI_Comm_set_name(simgrid::smpi::Comm::f2c(*comm), tname.c_str());
}
void mpi_comm_dup_with_info_ (int* comm, int* info, int* newcomm, int* ierr){
#include "smpi_comm.hpp"
#include "smpi_datatype.hpp"
+#include <string>
+
extern "C" { // This should really use the C linkage to be usable from Fortran
void mpi_type_extent_(int* datatype, MPI_Aint * extent, int* ierr){
}
}
-void mpi_type_set_name_ (int* datatype, char * name, int* ierr, int size){
- char* tname = xbt_new(char, size+1);
- strncpy(tname, name, size);
- tname[size]='\0';
- *ierr = MPI_Type_set_name(simgrid::smpi::Datatype::f2c(*datatype), tname);
- xbt_free(tname);
+void mpi_type_set_name_(int* datatype, char* name, int* ierr, int size)
+{
+ std::string tname(name, size);
+ *ierr = MPI_Type_set_name(simgrid::smpi::Datatype::f2c(*datatype), tname.c_str());
}
void mpi_type_get_name_ (int* datatype, char * name, int* len, int* ierr){