#define JED_SIMGRID_PLATFORM_H_
#include <simgrid/forward.h>
-#include <xbt/dynar.h>
#include <memory>
#include <string>
XBT_PUBLIC void log_exception(e_xbt_log_priority_t priority, const char* context, std::exception const& exception);
XBT_PUBLIC void install_exception_handler();
-}
-}
+
+} // namespace xbt
+} // namespace simgrid
XBT_PUBLIC int xbt_getpid(void);
-/* Get the name of the UNIX process englobing the world */
-XBT_PUBLIC_DATA char* xbt_binary_name;
+SG_END_DECL
+
+#ifdef __cplusplus
+#include <string>
+#include <vector>
+namespace simgrid {
+namespace xbt {
+/* Get the name of the UNIX process englobing the world */
+XBT_PUBLIC_DATA std::string binary_name;
/** Contains all the parameters we got from the command line (including argv[0]) */
-XBT_PUBLIC_DATA xbt_dynar_t xbt_cmdline;
+XBT_PUBLIC_DATA std::vector<std::string> cmdline;
-SG_END_DECL
+} // namespace xbt
+} // namespace simgrid
+#endif
#endif /* XBT_VIRTU_H */
JavaContextFactory::JavaContextFactory() : ContextFactory()
{
- xbt_assert(xbt_binary_name && strcmp(xbt_binary_name, "java") == 0); // Set by Java_org_simgrid_msg_Msg_init
+ xbt_assert(xbt::binary_name == "java");
}
JavaContextFactory::~JavaContextFactory()=default;
argc += static_cast<int>(env->GetArrayLength(jargs));
xbt_assert(argc > 0);
- // Need a static storage because the XBT layer saves the arguments in xbt_binary_name and xbt_cmdline.
+ // Need a static storage because the XBT layer saves the arguments in xbt::binary_name and xbt::cmdline.
static std::vector<std::string> args;
args.reserve(argc);
#include "simgrid/version.h"
#include "src/instr/instr_private.hpp"
#include "surf/surf.hpp"
-#include "xbt/virtu.h" /* xbt_cmdline */
+#include "xbt/virtu.h" /* xbt::cmdline */
#include <fstream>
#include <string>
tracing_file << "#This file was generated using SimGrid-" << SIMGRID_VERSION_MAJOR << "." << SIMGRID_VERSION_MINOR
<< "." << SIMGRID_VERSION_PATCH << std::endl;
tracing_file << "#[";
- unsigned int cpt;
- char* str;
- xbt_dynar_foreach (xbt_cmdline, cpt, str) {
+ for (auto str : simgrid::xbt::cmdline) {
tracing_file << str << " ";
}
tracing_file << "]" << std::endl;
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/jedule/jedule.hpp"
-#include "src/simdag/simdag_private.hpp"
-
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/NetZone.hpp"
+#include "src/simdag/simdag_private.hpp"
#if SIMGRID_HAVE_JEDULE
void jedule_sd_dump(const char * filename)
{
if (my_jedule) {
- char *fname;
+ std::string fname;
if (not filename) {
- fname = bprintf("%s.jed", xbt_binary_name);
+ fname = simgrid::xbt::binary_name + ".jed";
} else {
- fname = xbt_strdup(filename);
+ fname = filename;
}
- FILE *fh = fopen(fname, "w");
+ FILE* fh = fopen(fname.c_str(), "w");
my_jedule->write_output(fh);
fclose(fh);
- xbt_free(fname);
}
}
#endif
static void smpi_get_executable_global_size()
{
char buffer[PATH_MAX];
- char* full_name = realpath(xbt_binary_name, buffer);
- xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'", xbt_binary_name);
+ char* full_name = realpath(simgrid::xbt::binary_name.c_str(), buffer);
+ xbt_assert(full_name != nullptr, "Could not resolve real path of binary file '%s'",
+ simgrid::xbt::binary_name.c_str());
std::vector<simgrid::xbt::VmMap> map = simgrid::xbt::get_memory_map(getpid());
for (auto i = map.begin(); i != map.end() ; ++i) {
#if HAVE_UNISTD_H
# include <unistd.h>
#endif
+#include <string>
+#include <vector>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(module, xbt, "module handling");
XBT_LOG_NEW_CATEGORY(smpi, "All SMPI categories"); /* lives here even if that's a bit odd to solve linking issues: this is used in xbt_log_file_appender to detect whether SMPI is used (and thus whether we should unbench the writing to disk) */
-char *xbt_binary_name = NULL; /* Name of the system process containing us (mandatory to retrieve neat backtraces) */
-xbt_dynar_t xbt_cmdline = NULL; /* all we got in argv */
+namespace simgrid {
+namespace xbt {
+std::string binary_name; /* Name of the system process containing us (mandatory to retrieve neat backtraces) */
+std::vector<std::string> cmdline; /* all we got in argv */
+} // namespace xbt
+} // namespace simgrid
int xbt_initialized = 0;
simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
return;
xbt_initialized--;
xbt_dict_postexit();
- xbt_dynar_free(&xbt_cmdline);
xbt_log_postexit();
#if SIMGRID_HAVE_MC
mmalloc_postexit();
simgrid::xbt::install_exception_handler();
- xbt_binary_name = argv[0];
- xbt_cmdline = xbt_dynar_new(sizeof(char*), NULL);
+ simgrid::xbt::binary_name = argv[0];
for (int i = 0; i < *argc; i++)
- xbt_dynar_push(xbt_cmdline,&(argv[i]));
+ simgrid::xbt::cmdline.push_back(argv[i]);
xbt_log_init(argc, argv);
}