-/* Copyright (c) 2008, 2009, 2010. The SimGrid Team.
+/* Copyright (c) 2008-2014. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "xbt/log.h"
#include "xbt/dict.h"
#include "xbt/ex.h"
+#include "xbt/xbt_os_time.h"
#include "surf/surf.h"
#include "surf/surf_private.h"
return strcmp(name1, name2);
}
-int parse_cmdline(int *timings, int *downgrade, char **platformFile, int argc, char **argv)
+static int parse_cmdline(int *timings, int *downgrade, char **platformFile, int argc, char **argv)
{
int wrong_option = 0;
int i;
return wrong_option;
}
+static void create_environment(xbt_os_timer_t parse_time, const char *platformFile)
+{
+ xbt_ex_t e;
+ TRY {
+ xbt_os_cputimer_start(parse_time);
+ SD_create_environment(platformFile);
+ xbt_os_cputimer_stop(parse_time);
+ }
+ CATCH(e) {
+ xbt_die("Error while loading %s: %s", platformFile, e.msg);
+ }
+}
+
int main(int argc, char **argv)
{
char *platformFile = NULL;
char *src,*dst,*key,*data;
sg_routing_edge_t value1;
sg_routing_edge_t value2;
- xbt_ex_t e;
const SD_workstation_t *hosts;
const SD_link_t *links;
xbt_os_timer_t parse_time = xbt_os_timer_new();
+#ifdef _XBT_WIN32
+ setbuf(stderr, NULL);
+ setbuf(stdout, NULL);
+#else
setvbuf(stdout, NULL, _IOLBF, 0);
+#endif
SD_init(&argc, argv);
link_ctn = link_ctn_v2;
}
- TRY {
- xbt_os_timer_start(parse_time);
- SD_create_environment(platformFile);
- xbt_os_timer_stop(parse_time);
- }
- CATCH(e) {
- xbt_die("Error while loading %s: %s",platformFile,e.msg);
- }
+ create_environment(parse_time, platformFile);
if (timings) {
XBT_INFO("Parsing time: %fs (%d hosts, %d links)",
// Routers
xbt_lib_foreach(as_router_lib, cursor_src, key, value1) {
- if(((sg_routing_edge_t)xbt_lib_get_or_null(as_router_lib, key,
- ROUTING_ASR_LEVEL))->rc_type == SURF_NETWORK_ELEMENT_ROUTER)
+ if(surf_routing_edge_get_rc_type(xbt_lib_get_or_null(as_router_lib, key,
+ ROUTING_ASR_LEVEL)) == SURF_NETWORK_ELEMENT_ROUTER)
{
printf(" <router id=\"%s\"/>\n",key);
}
{
void *link = xbt_dynar_get_as(route,i,void *);
- char *link_name = xbt_strdup(((surf_resource_t)link)->name);
+ char *link_name = xbt_strdup(surf_resource_name(link));
printf("<%s id=\"%s\"/>",link_ctn,link_name);
free(link_name);
}
{
void *link = xbt_dynar_get_as(route,i,void *);
- char *link_name = xbt_strdup(((surf_resource_t)link)->name);
+ char *link_name = xbt_strdup(surf_resource_name(link));
printf("<%s id=\"%s\"/>",link_ctn,link_name);
free(link_name);
}
{
void *link = xbt_dynar_get_as(route,i,void *);
- char *link_name = xbt_strdup(((surf_resource_t)link)->name);
+ char *link_name = xbt_strdup(surf_resource_name(link));
printf("<%s id=\"%s\"/>",link_ctn,link_name);
free(link_name);
}
{
void *link = xbt_dynar_get_as(route,i,void *);
- char *link_name = xbt_strdup(((surf_resource_t)link)->name);
+ char *link_name = xbt_strdup(surf_resource_name(link));
printf("<%s id=\"%s\"/>",link_ctn,link_name);
free(link_name);
}
printf("</platform>\n");
}
SD_exit();
+ xbt_os_timer_free(parse_time);
return 0;
}