I used the following command: (the '**' means recursion in ZSH)
sed -i -e 's/\([^_]\s*\)NULL/\1nullptr/g' src/**/*.cpp
We check for the underscore to avoid replacing MPI_*_NULL
// instance will get a fresh (reinitialized) state. Is this what we want?
this->pimpl_ = simcall_process_create(
name, std::move(code), nullptr, host->name().c_str(),
// instance will get a fresh (reinitialized) state. Is this what we want?
this->pimpl_ = simcall_process_create(
name, std::move(code), nullptr, host->name().c_str(),
}
s4u::Actor::~Actor() {}
}
s4u::Actor::~Actor() {}
void s4u::Actor::kill(int pid) {
msg_process_t process = SIMIX_process_from_PID(pid);
void s4u::Actor::kill(int pid) {
msg_process_t process = SIMIX_process_from_PID(pid);
+ if(process != nullptr) {
simcall_process_kill(process);
} else {
std::ostringstream oss;
simcall_process_kill(process);
} else {
std::ostringstream oss;
}
e_smx_state_t execute(double flops) {
}
e_smx_state_t execute(double flops) {
- smx_synchro_t s = simcall_execution_start(NULL,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
+ smx_synchro_t s = simcall_execution_start(nullptr,flops,1.0/*priority*/,0./*bound*/, 0L/*affinity*/);
return simcall_execution_wait(s);
}
void* recv(Mailbox &chan) {
return simcall_execution_wait(s);
}
void* recv(Mailbox &chan) {
Comm c = Comm::recv_init(chan);
c.setDstData(&res,sizeof(res));
c.wait();
Comm c = Comm::recv_init(chan);
c.setDstData(&res,sizeof(res));
c.wait();
- xbt_dict_cursor_t cursor = NULL;
+ xbt_dict_cursor_t cursor = nullptr;
char *key;
AS_t elem;
xbt_dict_foreach(children_, cursor, key, elem) {
char *key;
AS_t elem;
xbt_dict_foreach(children_, cursor, key, elem) {
xbt_dynar_t As::hosts()
{
xbt_dynar_t As::hosts()
{
- xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), NULL);
+ xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t), nullptr);
for (unsigned int index = 0; index < xbt_dynar_length(vertices_); index++) {
simgrid::surf::NetCard *card = xbt_dynar_get_as(vertices_, index, simgrid::surf::NetCard*);
simgrid::s4u::Host *host = simgrid::s4u::Host::by_name_or_null(card->name());
for (unsigned int index = 0; index < xbt_dynar_length(vertices_); index++) {
simgrid::surf::NetCard *card = xbt_dynar_get_as(vertices_, index, simgrid::surf::NetCard*);
simgrid::s4u::Host *host = simgrid::s4u::Host::by_name_or_null(card->name());
xbt_dynar_push(res, &host);
}
return res;
xbt_dynar_push(res, &host);
}
return res;
void s4u::Comm::setSrcData(void * buff) {
xbt_assert(state_==inited);
void s4u::Comm::setSrcData(void * buff) {
xbt_assert(state_==inited);
- xbt_assert(dstBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+ xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
srcBuff_ = buff;
}
void s4u::Comm::setSrcDataSize(size_t size){
srcBuff_ = buff;
}
void s4u::Comm::setSrcDataSize(size_t size){
void s4u::Comm::setSrcData(void * buff, size_t size) {
xbt_assert(state_==inited);
void s4u::Comm::setSrcData(void * buff, size_t size) {
xbt_assert(state_==inited);
- xbt_assert(dstBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+ xbt_assert(dstBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
srcBuff_ = buff;
srcBuffSize_ = size;
}
void s4u::Comm::setDstData(void ** buff) {
xbt_assert(state_==inited);
srcBuff_ = buff;
srcBuffSize_ = size;
}
void s4u::Comm::setDstData(void ** buff) {
xbt_assert(state_==inited);
- xbt_assert(srcBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+ xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
dstBuff_ = buff;
}
size_t s4u::Comm::getDstDataSize(){
dstBuff_ = buff;
}
size_t s4u::Comm::getDstDataSize(){
void s4u::Comm::setDstData(void ** buff, size_t size) {
xbt_assert(state_==inited);
void s4u::Comm::setDstData(void ** buff, size_t size) {
xbt_assert(state_==inited);
- xbt_assert(srcBuff_ == NULL, "Cannot set the src and dst buffers at the same time");
+ xbt_assert(srcBuff_ == nullptr, "Cannot set the src and dst buffers at the same time");
dstBuff_ = buff;
dstBuffSize_ = size;
}
dstBuff_ = buff;
dstBuffSize_ = size;
}
void s4u::Comm::start() {
xbt_assert(state_ == inited);
void s4u::Comm::start() {
xbt_assert(state_ == inited);
- if (srcBuff_ != NULL) { // Sender side
+ if (srcBuff_ != nullptr) { // Sender side
pimpl_ = simcall_comm_isend(sender_, mailbox_->getInferior(), remains_, rate_,
srcBuff_, srcBuffSize_,
matchFunction_, cleanFunction_, copyDataFunction_,
userData_, detached_);
pimpl_ = simcall_comm_isend(sender_, mailbox_->getInferior(), remains_, rate_,
srcBuff_, srcBuffSize_,
matchFunction_, cleanFunction_, copyDataFunction_,
userData_, detached_);
- } else if (dstBuff_ != NULL) { // Receiver side
+ } else if (dstBuff_ != nullptr) { // Receiver side
pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getInferior(), dstBuff_, &dstBuffSize_,
matchFunction_, copyDataFunction_,
userData_, rate_);
pimpl_ = simcall_comm_irecv(receiver_, mailbox_->getInferior(), dstBuff_, &dstBuffSize_,
matchFunction_, copyDataFunction_,
userData_, rate_);
if (state_ == started)
simcall_comm_wait(pimpl_, -1/*timeout*/);
else {// p_state == inited. Save a simcall and do directly a blocking send/recv
if (state_ == started)
simcall_comm_wait(pimpl_, -1/*timeout*/);
else {// p_state == inited. Save a simcall and do directly a blocking send/recv
- if (srcBuff_ != NULL) {
+ if (srcBuff_ != nullptr) {
simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_,
srcBuff_, srcBuffSize_,
matchFunction_, copyDataFunction_,
simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_,
srcBuff_, srcBuffSize_,
matchFunction_, copyDataFunction_,
}
// It's not started yet. Do it in one simcall
}
// It's not started yet. Do it in one simcall
- if (srcBuff_ != NULL) {
+ if (srcBuff_ != nullptr) {
simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_,
srcBuff_, srcBuffSize_,
matchFunction_, copyDataFunction_,
simcall_comm_send(sender_, mailbox_->getInferior(), remains_, rate_,
srcBuff_, srcBuffSize_,
matchFunction_, copyDataFunction_,
if(!strcmp(current->name(), name))
return current;
if(!strcmp(current->name(), name))
return current;
- xbt_dict_cursor_t cursor = NULL;
+ xbt_dict_cursor_t cursor = nullptr;
char *key;
AS_t elem;
xbt_dict_foreach(current->children(), cursor, key, elem) {
simgrid::s4u::As *tmp = asByNameRecursive(elem, name);
char *key;
AS_t elem;
xbt_dict_foreach(current->children(), cursor, key, elem) {
simgrid::s4u::As *tmp = asByNameRecursive(elem, name);
return tmp;
}
return nullptr;
return tmp;
}
return nullptr;
Host* host = by_name_or_null(name);
if (host == nullptr) {
host = new Host(name);
Host* host = by_name_or_null(name);
if (host == nullptr) {
host = new Host(name);
- xbt_dict_set(host_list, name, host, NULL);
+ xbt_dict_set(host_list, name, host, nullptr);
}
return host;
}
Host *Host::current(){
smx_process_t smx_proc = SIMIX_process_self();
}
return host;
}
Host *Host::current(){
smx_process_t smx_proc = SIMIX_process_self();
+ if (smx_proc == nullptr)
xbt_die("Cannot call Host::current() from the maestro context");
return SIMIX_process_get_host(smx_proc);
}
xbt_die("Cannot call Host::current() from the maestro context");
return SIMIX_process_get_host(smx_proc);
}
}
boost::unordered_map<std::string, Storage*> const& Host::mountedStorages() {
}
boost::unordered_map<std::string, Storage*> const& Host::mountedStorages() {
+ if (mounts == nullptr) {
mounts = new boost::unordered_map<std::string, Storage*> ();
xbt_dict_t dict = this->mountedStoragesAsDict();
mounts = new boost::unordered_map<std::string, Storage*> ();
xbt_dict_t dict = this->mountedStoragesAsDict();
-/** Retrieve the property value (or NULL if not set) */
+/** Retrieve the property value (or nullptr if not set) */
const char*Host::property(const char*key) {
simgrid::surf::HostImpl* surf_host = this->extension<simgrid::surf::HostImpl>();
return surf_host->getProperty(key);
const char*Host::property(const char*key) {
simgrid::surf::HostImpl* surf_host = this->extension<simgrid::surf::HostImpl>();
return surf_host->getProperty(key);
return pimpl_;
}
Storage &Storage::byName(const char*name) {
return pimpl_;
}
Storage &Storage::byName(const char*name) {
- s4u::Storage *res = NULL;
+ s4u::Storage *res = nullptr;
try {
res = storages_->at(name);
} catch (std::out_of_range& e) {
smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name);
try {
res = storages_->at(name);
} catch (std::out_of_range& e) {
smx_storage_t inferior = xbt_lib_get_elm_or_null(storage_lib,name);
+ if (inferior == nullptr)
xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name);
res = new Storage(name,inferior);
xbt_die("Storage %s does not exist. Please only use the storages that are defined in your platform.", name);
res = new Storage(name,inferior);