+#include "src/simix/smx_private.hpp"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(sg_host, sd, "Logging specific to sg_hosts");
+
+size_t sg_host_count()
+{
+ return xbt_dict_length(host_list);
+}
+/** @brief Returns the host list
+ *
+ * Uses sg_host_count() to know the array size.
+ *
+ * \return an array of \ref sg_host_t containing all the hosts in the platform.
+ * \remark The host order in this array is generally different from the
+ * creation/declaration order in the XML platform (we use a hash table
+ * internally).
+ * \see sg_host_count()
+ */
+sg_host_t *sg_host_list(void) {
+ xbt_assert(sg_host_count() > 0, "There is no host!");
+ return (sg_host_t*)xbt_dynar_to_array(sg_hosts_as_dynar());
+}
+
+const char *sg_host_get_name(sg_host_t host)
+{
+ return host->name().c_str();
+}
+
+void* sg_host_extension_get(sg_host_t host, size_t ext)
+{
+ return host->extension(ext);
+}
+
+size_t sg_host_extension_create(void(*deleter)(void*))
+{
+ return simgrid::s4u::Host::extension_create(deleter);
+}
+
+sg_host_t sg_host_by_name(const char *name)
+{
+ return simgrid::s4u::Host::by_name_or_null(name);
+}
+
+sg_host_t sg_host_by_name_or_create(const char *name)
+{
+ return simgrid::s4u::Host::by_name_or_create(name);
+}
+
+xbt_dynar_t sg_hosts_as_dynar(void)
+{
+ xbt_dynar_t res = xbt_dynar_new(sizeof(sg_host_t),NULL);
+
+ xbt_dict_cursor_t cursor = nullptr;
+ const char* name = nullptr;
+ simgrid::s4u::Host* host = nullptr;
+ xbt_dict_foreach(host_list, cursor, name, host)
+ if (host && host->pimpl_netcard && host->pimpl_netcard->isHost())
+ xbt_dynar_push(res, &host);
+ return res;
+}
+
+// ========= Layering madness ==============*
+
+#include "src/surf/cpu_interface.hpp"
+#include "src/surf/surf_routing.hpp"
+
+// ========== User data Layer ==========
+void *sg_host_user(sg_host_t host) {
+ return host->extension(USER_HOST_LEVEL);
+}
+void sg_host_user_set(sg_host_t host, void* userdata) {
+ host->extension_set(USER_HOST_LEVEL,userdata);
+}
+void sg_host_user_destroy(sg_host_t host) {
+ host->extension_set(USER_HOST_LEVEL, nullptr);
+}
+
+// ========== MSG Layer ==============
+msg_host_priv_t sg_host_msg(sg_host_t host) {
+ return (msg_host_priv_t) host->extension(MSG_HOST_LEVEL);
+}
+void sg_host_msg_set(sg_host_t host, msg_host_priv_t smx_host) {
+ host->extension_set(MSG_HOST_LEVEL, smx_host);