From: Christian Heinrich Date: Tue, 21 Jul 2015 10:20:22 +0000 (+0200) Subject: [SURF] Callbacks now use the INITIALIZER macros X-Git-Tag: v3_12~438^2~42 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/3bcec4e865accfb7659d7431b5bc21121429b681 [SURF] Callbacks now use the INITIALIZER macros - Callbacks such as s_sg_platf_link_cbarg_t were not at all correctly initialized before; this was fixed! - Several initializers used valid C99 initializer syntax; however, this is not supported by C++. Hence, these initializers were changed to simple lists. See also https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html for more details on this issue. --- diff --git a/include/simgrid/platf.h b/include/simgrid/platf.h index 4da5c79b18..580cb27d41 100644 --- a/include/simgrid/platf.h +++ b/include/simgrid/platf.h @@ -124,16 +124,9 @@ typedef struct { } s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t; #define SG_PLATF_HOST_INITIALIZER { \ - .id = NULL,\ - .power_peak = 0,\ - .core_amount = 1.,\ - .power_scale = 1,\ - .initial_state = SURF_RESOURCE_ON,\ - .power_trace = NULL,\ - .state_trace = NULL,\ - .coord = NULL,\ - .properties = NULL\ - } + NULL, 0, 1, 1, 1., NULL, SURF_RESOURCE_ON, NULL, \ + NULL, NULL \ +} typedef struct { const char* id; @@ -163,15 +156,8 @@ typedef struct { } s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t; #define SG_PLATF_LINK_INITIALIZER {\ - .id = NULL,\ - .bandwidth = 0.,\ - .bandwidth_trace = NULL,\ - .latency = 0.,\ - .latency_trace = NULL,\ - .state = SURF_RESOURCE_ON,\ - .state_trace = NULL,\ - .policy = SURF_LINK_SHARED,\ - .properties = NULL\ + NULL, 0., NULL, 0., NULL, SURF_RESOURCE_ON, \ + NULL, SURF_LINK_SHARED, NULL \ } typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t; @@ -186,7 +172,7 @@ typedef struct s_sg_platf_peer_cbarg { tmgr_trace_t state_trace; } s_sg_platf_peer_cbarg_t; -#define SG_PLATF_PEER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL} typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t; typedef struct s_sg_platf_route_cbarg { @@ -198,7 +184,7 @@ typedef struct s_sg_platf_route_cbarg { xbt_dynar_t link_list; } s_sg_platf_route_cbarg_t; -#define SG_PLATF_ROUTE_INITIALIZER {TRUE,NULL,NULL,NULL,NULL,NULL} +#define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL} typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t; typedef struct s_sg_platf_cluster_cbarg { @@ -225,8 +211,11 @@ typedef struct s_sg_platf_cluster_cbarg { const char* state_trace; } s_sg_platf_cluster_cbarg_t; -#define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL \ - ,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \ + ,1.,1.,0.,0.,0.,0.,0. \ + ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \ + SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \ + ,NULL} typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t; typedef struct s_sg_platf_cabinet_cbarg { @@ -239,7 +228,7 @@ typedef struct s_sg_platf_cabinet_cbarg { double lat; } s_sg_platf_cabinet_cbarg_t; -#define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,NULL} +#define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0} typedef struct { const char* id; @@ -250,7 +239,7 @@ typedef struct { const char* attach; } s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t; -#define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL} +#define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL} typedef struct { const char* id; @@ -262,7 +251,7 @@ typedef struct { sg_size_t size; } s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t; -#define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL} +#define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL} typedef struct { const char* type_id; @@ -294,7 +283,7 @@ typedef struct s_sg_platf_trace_cbarg { const char *pc_data; } s_sg_platf_trace_cbarg_t; -#define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,NULL,NULL} +#define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL} typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t; typedef struct s_sg_platf_trace_connect_cbarg { @@ -303,7 +292,7 @@ typedef struct s_sg_platf_trace_connect_cbarg { const char *element; } s_sg_platf_trace_connect_cbarg_t; -#define SG_PLATF_TRACE_CONNECT_INITIALIZER {NULL,NULL,NULL} +#define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL} typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t; typedef struct s_sg_platf_process_cbarg { diff --git a/src/surf/platf_generator.c b/src/surf/platf_generator.c index dab3cd50cb..a011a523ea 100644 --- a/src/surf/platf_generator.c +++ b/src/surf/platf_generator.c @@ -616,8 +616,8 @@ void platf_generate(void) { sg_platf_host_cbarg_t host_parameters; sg_platf_cluster_cbarg_t cluster_parameters; sg_platf_link_cbarg_t link_parameters; - s_sg_platf_router_cbarg_t router_parameters; /* This one is not a pointer! */ - s_sg_platf_route_cbarg_t route_parameters; /* neither this one! */ + s_sg_platf_router_cbarg_t router_parameters = SG_PLATF_ROUTER_INITIALIZER; /* This one is not a pointer! */ + s_sg_platf_route_cbarg_t route_parameters = SG_PLATF_ROUTE_INITIALIZER; /* neither this one! */ router_parameters.coord = NULL; route_parameters.symmetrical = FALSE; diff --git a/src/surf/surf_routing.cpp b/src/surf/surf_routing.cpp index 4a381dcb89..67ec97d655 100644 --- a/src/surf/surf_routing.cpp +++ b/src/surf/surf_routing.cpp @@ -528,7 +528,7 @@ static void elements_father(sg_routing_edge_t src, sg_routing_edge_t dst, static void _get_route_and_latency(RoutingEdgePtr src, RoutingEdgePtr dst, xbt_dynar_t * links, double *latency) { - s_sg_platf_route_cbarg_t route; + s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER; memset(&route,0,sizeof(route)); xbt_assert(src && dst, "bad parameters for \"_get_route_latency\" method"); @@ -758,21 +758,21 @@ static void routing_parse_cabinet(sg_platf_cabinet_cbarg_t cabinet) surf_parse_error("Malformed radical"); break; } - s_sg_platf_host_cbarg_t host; + s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; memset(&host, 0, sizeof(host)); host.initial_state = SURF_RESOURCE_ON; host.pstate = 0; host.power_scale = 1.0; host.core_amount = 1; - s_sg_platf_link_cbarg_t link; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; memset(&link, 0, sizeof(link)); link.state = SURF_RESOURCE_ON; link.policy = SURF_LINK_FULLDUPLEX; link.latency = cabinet->lat; link.bandwidth = cabinet->bw; - s_sg_platf_host_link_cbarg_t host_link; + s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER; memset(&host_link, 0, sizeof(host_link)); for (i = start; i <= end; i++) { @@ -810,8 +810,8 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) xbt_dict_t patterns = NULL; int rankId=0; - s_sg_platf_host_cbarg_t host; - s_sg_platf_link_cbarg_t link; + s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; unsigned int iter; int start, end, i; @@ -1021,7 +1021,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster) XBT_DEBUG(" "); XBT_DEBUG("", cluster->router_id); char *newid = NULL; - s_sg_platf_router_cbarg_t router; + s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER; memset(&router, 0, sizeof(router)); router.id = cluster->router_id; router.coord = ""; @@ -1083,7 +1083,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) current_routing->p_linkUpDownList = xbt_dynar_new(sizeof(s_surf_parsing_link_up_down_t),NULL); XBT_DEBUG("", host_id, peer->power); - s_sg_platf_host_cbarg_t host; + s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; memset(&host, 0, sizeof(host)); host.initial_state = SURF_RESOURCE_ON; host.id = host_id; @@ -1099,7 +1099,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) host.core_amount = 1; sg_platf_new_host(&host); - s_sg_platf_link_cbarg_t link; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; memset(&link, 0, sizeof(link)); link.state = SURF_RESOURCE_ON; link.policy = SURF_LINK_SHARED; @@ -1120,7 +1120,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) sg_platf_new_link(&link); XBT_DEBUG("", host_id,link_up,link_down); - s_sg_platf_host_link_cbarg_t host_link; + s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER; memset(&host_link, 0, sizeof(host_link)); host_link.id = host_id; host_link.link_up = link_up; @@ -1128,7 +1128,7 @@ static void routing_parse_peer(sg_platf_peer_cbarg_t peer) sg_platf_new_host_link(&host_link); XBT_DEBUG("", router_id); - s_sg_platf_router_cbarg_t router; + s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER; memset(&router, 0, sizeof(router)); router.id = router_id; router.coord = peer->coord; diff --git a/src/surf/surf_routing_cluster.cpp b/src/surf/surf_routing_cluster.cpp index 02c11ba7b1..91427cd2e7 100644 --- a/src/surf/surf_routing_cluster.cpp +++ b/src/surf/surf_routing_cluster.cpp @@ -142,7 +142,7 @@ void AsCluster::getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges) } void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int , int position){ - s_sg_platf_link_cbarg_t link; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; s_surf_parsing_link_up_down_t info; char* link_id = bprintf("%s_link_%d", cluster->id, id); diff --git a/src/surf/surf_routing_cluster_fat_tree.cpp b/src/surf/surf_routing_cluster_fat_tree.cpp index 2421ea5496..01bee9a1b4 100644 --- a/src/surf/surf_routing_cluster_fat_tree.cpp +++ b/src/surf/surf_routing_cluster_fat_tree.cpp @@ -492,7 +492,7 @@ void AsClusterFatTree::generateDotFile(const string& filename) const { FatTreeNode::FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level, int position) : id(id), level(level), position(position) { - s_sg_platf_link_cbarg_t linkTemplate; + s_sg_platf_link_cbarg_t linkTemplate = SG_PLATF_LINK_INITIALIZER; if(cluster->limiter_link) { memset(&linkTemplate, 0, sizeof(linkTemplate)); linkTemplate.bandwidth = cluster->limiter_link; @@ -526,7 +526,7 @@ FatTreeLink::FatTreeLink(sg_platf_cluster_cbarg_t cluster, FatTreeNode *upNode) : upNode(upNode), downNode(downNode) { static int uniqueId = 0; - s_sg_platf_link_cbarg_t linkTemplate; + s_sg_platf_link_cbarg_t linkTemplate = SG_PLATF_LINK_INITIALIZER; memset(&linkTemplate, 0, sizeof(linkTemplate)); linkTemplate.bandwidth = cluster->bw; linkTemplate.latency = cluster->lat; diff --git a/src/surf/surf_routing_cluster_torus.cpp b/src/surf/surf_routing_cluster_torus.cpp index 52d0c35960..33dc8cc174 100644 --- a/src/surf/surf_routing_cluster_torus.cpp +++ b/src/surf/surf_routing_cluster_torus.cpp @@ -42,7 +42,7 @@ AsClusterTorus::~AsClusterTorus() void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position){ - s_sg_platf_link_cbarg_t link; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; char* link_id; unsigned int j = 0; /** diff --git a/src/surf/surfxml_parse.c b/src/surf/surfxml_parse.c index 3ec4f971a6..c1add14f0f 100644 --- a/src/surf/surfxml_parse.c +++ b/src/surf/surfxml_parse.c @@ -229,7 +229,7 @@ void STag_surfxml_storage(void) } void ETag_surfxml_storage(void) { - s_sg_platf_storage_cbarg_t storage; + s_sg_platf_storage_cbarg_t storage = SG_PLATF_STORAGE_INITIALIZER; memset(&storage,0,sizeof(storage)); storage.id = A_surfxml_storage_id; @@ -250,7 +250,7 @@ void STag_surfxml_storage___type(void) } void ETag_surfxml_storage___type(void) { - s_sg_platf_storage_type_cbarg_t storage_type; + s_sg_platf_storage_type_cbarg_t storage_type = SG_PLATF_STORAGE_TYPE_INITIALIZER; memset(&storage_type,0,sizeof(storage_type)); storage_type.content = A_surfxml_storage___type_content; @@ -270,7 +270,7 @@ void STag_surfxml_mstorage(void) } void ETag_surfxml_mstorage(void) { - s_sg_platf_mstorage_cbarg_t mstorage; + s_sg_platf_mstorage_cbarg_t mstorage = SG_PLATF_MSTORAGE_INITIALIZER; memset(&mstorage,0,sizeof(mstorage)); mstorage.name = A_surfxml_mstorage_name; @@ -283,7 +283,7 @@ void STag_surfxml_mount(void) } void ETag_surfxml_mount(void) { - s_sg_platf_mount_cbarg_t mount; + s_sg_platf_mount_cbarg_t mount = SG_PLATF_MOUNT_INITIALIZER; memset(&mount,0,sizeof(mount)); mount.name = A_surfxml_mount_name; @@ -430,7 +430,7 @@ void STag_surfxml_prop(void) } void ETag_surfxml_host(void) { - s_sg_platf_host_cbarg_t host; + s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; char* buf; memset(&host,0,sizeof(host)); @@ -484,7 +484,7 @@ void ETag_surfxml_host(void) { void STag_surfxml_host___link(void){ XBT_DEBUG("Create a Host_link for %s",A_surfxml_host___link_id); - s_sg_platf_host_link_cbarg_t host_link; + s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER; memset(&host_link,0,sizeof(host_link)); host_link.id = A_surfxml_host___link_id; @@ -494,7 +494,7 @@ void STag_surfxml_host___link(void){ } void STag_surfxml_router(void){ - s_sg_platf_router_cbarg_t router; + s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER; memset(&router, 0, sizeof(router)); router.id = A_surfxml_router_id; @@ -504,7 +504,7 @@ void STag_surfxml_router(void){ } void ETag_surfxml_cluster(void){ - s_sg_platf_cluster_cbarg_t cluster; + s_sg_platf_cluster_cbarg_t cluster = SG_PLATF_CLUSTER_INITIALIZER; memset(&cluster,0,sizeof(cluster)); cluster.properties = as_current_property_set; @@ -587,7 +587,7 @@ void STag_surfxml_cluster(void){ void STag_surfxml_cabinet(void){ parse_after_config(); - s_sg_platf_cabinet_cbarg_t cabinet; + s_sg_platf_cabinet_cbarg_t cabinet = SG_PLATF_CABINET_INITIALIZER; memset(&cabinet,0,sizeof(cabinet)); cabinet.id = A_surfxml_cabinet_id; cabinet.prefix = A_surfxml_cabinet_prefix; @@ -602,7 +602,7 @@ void STag_surfxml_cabinet(void){ void STag_surfxml_peer(void){ parse_after_config(); - s_sg_platf_peer_cbarg_t peer; + s_sg_platf_peer_cbarg_t peer = SG_PLATF_PEER_INITIALIZER; memset(&peer,0,sizeof(peer)); peer.id = A_surfxml_peer_id; peer.power = surf_parse_get_power(A_surfxml_peer_power); @@ -622,7 +622,7 @@ void STag_surfxml_link(void){ } void ETag_surfxml_link(void){ - s_sg_platf_link_cbarg_t link; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; memset(&link,0,sizeof(link)); link.properties = current_property_set; @@ -690,7 +690,7 @@ void STag_surfxml_link___ctn(void){ } void ETag_surfxml_backbone(void){ - s_sg_platf_link_cbarg_t link; + s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER; memset(&link,0,sizeof(link)); link.properties = NULL; @@ -743,7 +743,7 @@ void STag_surfxml_bypassASroute(void){ } void ETag_surfxml_route(void){ - s_sg_platf_route_cbarg_t route; + s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER; memset(&route,0,sizeof(route)); route.src = A_surfxml_route_src; @@ -767,7 +767,7 @@ void ETag_surfxml_route(void){ } void ETag_surfxml_ASroute(void){ - s_sg_platf_route_cbarg_t ASroute; + s_sg_platf_route_cbarg_t ASroute = SG_PLATF_ROUTE_INITIALIZER; memset(&ASroute,0,sizeof(ASroute)); ASroute.src = A_surfxml_ASroute_src; @@ -800,7 +800,7 @@ void ETag_surfxml_ASroute(void){ } void ETag_surfxml_bypassRoute(void){ - s_sg_platf_route_cbarg_t route; + s_sg_platf_route_cbarg_t route = SG_PLATF_ROUTE_INITIALIZER; memset(&route,0,sizeof(route)); route.src = A_surfxml_bypassRoute_src; @@ -815,7 +815,7 @@ void ETag_surfxml_bypassRoute(void){ } void ETag_surfxml_bypassASroute(void){ - s_sg_platf_route_cbarg_t ASroute; + s_sg_platf_route_cbarg_t ASroute = SG_PLATF_ROUTE_INITIALIZER; memset(&ASroute,0,sizeof(ASroute)); ASroute.src = A_surfxml_bypassASroute_src; @@ -831,7 +831,7 @@ void ETag_surfxml_bypassASroute(void){ } void ETag_surfxml_trace(void){ - s_sg_platf_trace_cbarg_t trace; + s_sg_platf_trace_cbarg_t trace = SG_PLATF_TRACE_INITIALIZER; memset(&trace,0,sizeof(trace)); trace.id = A_surfxml_trace_id; @@ -844,7 +844,7 @@ void ETag_surfxml_trace(void){ void STag_surfxml_trace___connect(void){ parse_after_config(); - s_sg_platf_trace_connect_cbarg_t trace_connect; + s_sg_platf_trace_connect_cbarg_t trace_connect = SG_PLATF_TRACE_CONNECT_INITIALIZER; memset(&trace_connect,0,sizeof(trace_connect)); trace_connect.element = A_surfxml_trace___connect_element; @@ -936,7 +936,7 @@ void STag_surfxml_process(void){ } void ETag_surfxml_process(void){ - s_sg_platf_process_cbarg_t process; + s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER; memset(&process,0,sizeof(process)); process.argc = argc; @@ -982,7 +982,7 @@ void STag_surfxml_gpu(void) } void ETag_surfxml_gpu(void) { - s_sg_platf_gpu_cbarg_t gpu; + s_sg_platf_gpu_cbarg_t gpu = SG_PLATF_GPU_INITIALIZER; memset(&gpu,0,sizeof(gpu)); gpu.name = A_surfxml_gpu_name;