static double sg_host_get_available_at(sg_host_t host)
{
- HostAttribute attr = (HostAttribute) sg_host_user(host);
+ HostAttribute attr = (HostAttribute)sg_host_get_data(host);
return attr->available_at;
}
static void sg_host_set_available_at(sg_host_t host, double time)
{
- HostAttribute attr = (HostAttribute) sg_host_user(host);
+ HostAttribute attr = (HostAttribute)sg_host_get_data(host);
attr->available_at = time;
- sg_host_user_set(host, attr);
+ sg_host_set_data(host, attr);
}
static SD_task_t sg_host_get_last_scheduled_task( sg_host_t host){
- HostAttribute attr = (HostAttribute) sg_host_user(host);
+ HostAttribute attr = (HostAttribute)sg_host_get_data(host);
return attr->last_scheduled_task;
}
static void sg_host_set_last_scheduled_task(sg_host_t host, SD_task_t task){
- HostAttribute attr = (HostAttribute) sg_host_user(host);
+ HostAttribute attr = (HostAttribute)sg_host_get_data(host);
attr->last_scheduled_task=task;
- sg_host_user_set(host, attr);
+ sg_host_set_data(host, attr);
}
static xbt_dynar_t get_ready_tasks(xbt_dynar_t dax)
SD_create_environment(argv[1]);
/* Allocating the host attribute */
- int total_nhosts = sg_host_count();
+ unsigned int total_nhosts = sg_host_count();
sg_host_t *hosts = sg_host_list();
for (cursor = 0; cursor < total_nhosts; cursor++)
- sg_host_user_set(hosts[cursor], xbt_new0(struct _HostAttribute, 1));
+ sg_host_set_data(hosts[cursor], xbt_new0(struct _HostAttribute, 1));
/* load the DAX file */
xbt_dynar_t dax = SD_daxload(argv[2]);
xbt_dynar_free_container(&dax);
for (cursor = 0; cursor < total_nhosts; cursor++) {
- free(sg_host_user(hosts[cursor]));
- sg_host_user_set(hosts[cursor], NULL);
+ free(sg_host_get_data(hosts[cursor]));
+ sg_host_set_data(hosts[cursor], NULL);
}
xbt_free(hosts);
// ========== User Data ==============
/** @brief Return the user data of a #sg_host_t.
*
- * This functions returns the user data associated to @a host if it is possible.
+ * This functions returns the user data associated to @a host if any.
*/
-XBT_PUBLIC void* sg_host_user(sg_host_t host);
+XBT_PUBLIC void* sg_host_get_data(sg_host_t host);
+XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_get_data()") XBT_PUBLIC void* sg_host_user(sg_host_t host);
/** @brief Set the user data of a #sg_host_t.
*
- * This functions attach @a data to @a host if it is possible.
+ * This functions attach @a data to @a host.
*/
-XBT_PUBLIC void sg_host_user_set(sg_host_t host, void* userdata);
-XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
+XBT_PUBLIC void sg_host_set_data(sg_host_t host, void* userdata);
+XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_set_data()") XBT_PUBLIC
+ void sg_host_user_set(sg_host_t host, void* userdata);
+XBT_ATTRIB_DEPRECATED_v327("Please use sg_host_set_data(h, NULL)") XBT_PUBLIC void sg_host_user_destroy(sg_host_t host);
// ========= storage related functions ============
/** @brief Return the list of mount point names on an host.
} // namespace s4u
} // namespace simgrid
-extern int USER_HOST_LEVEL;
-
#endif /* SIMGRID_S4U_HOST_HPP */
}
void* MSG_host_get_data(sg_host_t host)
{
- return sg_host_user(host);
+ return sg_host_get_data(host);
}
void MSG_host_set_data(sg_host_t host, void* data)
{
- return sg_host_user_set(host, data);
+ return sg_host_set_data(host, data);
}
xbt_dict_t MSG_host_get_mounted_storage_list(sg_host_t host)
{
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_host, s4u, "Logging specific to the S4U hosts");
XBT_LOG_EXTERNAL_CATEGORY(surf_route);
-int USER_HOST_LEVEL = -1;
-
namespace simgrid {
namespace xbt {
template class Extendable<s4u::Host>;
// ========= Layering madness ==============*
// ========== User data Layer ==========
-void* sg_host_user(sg_host_t host)
+void* sg_host_get_data(sg_host_t host)
+{
+ return host->get_data();
+}
+void sg_host_set_data(sg_host_t host, void* userdata)
+{
+ host->set_data(userdata);
+}
+void* sg_host_user(sg_host_t host) // deprecated
{
- return host->extension(USER_HOST_LEVEL);
+ return host->get_data();
}
-void sg_host_user_set(sg_host_t host, void* userdata)
+void sg_host_user_set(sg_host_t host, void* userdata) // deprecated
{
- host->extension_set(USER_HOST_LEVEL, userdata);
+ host->set_data(userdata);
}
-void sg_host_user_destroy(sg_host_t host)
+void sg_host_user_destroy(sg_host_t host) // deprecated
{
- host->extension_set(USER_HOST_LEVEL, nullptr);
+ host->set_data(nullptr);
}
// ========= storage related functions ============
#include "src/simgrid/version.h"
#include "src/surf/HostImpl.hpp"
#include "src/surf/xml/platf.hpp"
+#include "src/xbt_modinter.h" /* whether initialization was already done */
#include "surf/surf.hpp"
#include "xbt/module.h"
void surf_init(int *argc, char **argv)
{
- if (USER_HOST_LEVEL != -1) // Already initialized
+ if (xbt_initialized > 0)
return;
- XBT_DEBUG("Create all Libs");
- USER_HOST_LEVEL = simgrid::s4u::Host::extension_create(nullptr);
-
xbt_init(argc, argv);
sg_config_init(argc, argv);
/** @brief Initialize the xbt mechanisms. */
void xbt_init(int *argc, char **argv)
{
- simgrid::xbt::install_exception_handler();
-
xbt_initialized++;
if (xbt_initialized > 1) {
XBT_DEBUG("XBT has been initialized %d times.", xbt_initialized);
return;
}
+ simgrid::xbt::install_exception_handler();
+
xbt_binary_name = argv[0];
xbt_cmdline = xbt_dynar_new(sizeof(char*), NULL);
for (int i = 0; i < *argc; i++)