Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
/me also hates void* pointers
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 15:38:54 +0000 (16:38 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 21:43:40 +0000 (22:43 +0100)
src/surf/surf_private.h
src/surf/surf_routing_cluster.c
src/surf/surf_routing_dijkstra.c
src/surf/surf_routing_floyd.c
src/surf/surf_routing_full.c
src/surf/surf_routing_none.c
src/surf/surf_routing_private.h
src/surf/surf_routing_rulebased.c
src/surf/surf_routing_vivaldi.c

index 1c7b932..ad8bde9 100644 (file)
@@ -101,11 +101,12 @@ typedef struct s_onelink {
 /**
  * Routing logic
  */
 /**
  * Routing logic
  */
+typedef struct s_routing_component *routing_component_t;
 
 typedef struct s_model_type {
   const char *name;
   const char *desc;
 
 typedef struct s_model_type {
   const char *name;
   const char *desc;
-  void *(*create) ();
+  routing_component_t (*create) ();
   void (*load) ();
   void (*unload) ();
   void (*end) ();
   void (*load) ();
   void (*unload) ();
   void (*end) ();
index 5a8d22b..45f09cc 100644 (file)
@@ -48,12 +48,12 @@ static route_extended_t cluster_get_route(routing_component_t rc,
 }
 
 /* Creation routing model functions */
 }
 
 /* Creation routing model functions */
-void *model_cluster_create(void)
+routing_component_t model_cluster_create(void)
 {
 {
-  routing_component_cluster_t new_component = model_rulebased_create();
-  new_component->generic_routing.get_route = cluster_get_route;
+  routing_component_t new_component = model_rulebased_create();
+  new_component->get_route = cluster_get_route;
 
 
-  return new_component;
+  return (routing_component_t) new_component;
 }
 void model_cluster_unload(void) {
 //  xbt_dict_free(&cluster_host_link); //FIXME: do it once the module management is clean in routing
 }
 void model_cluster_unload(void) {
 //  xbt_dict_free(&cluster_host_link); //FIXME: do it once the module management is clean in routing
index 6a89c34..cced813 100644 (file)
@@ -447,7 +447,7 @@ static void dijkstra_finalize(routing_component_t rc)
 
 /* Creation routing model functions */
 
 
 /* Creation routing model functions */
 
-void *model_dijkstra_both_create(int cached)
+routing_component_t model_dijkstra_both_create(int cached)
 {
   routing_component_dijkstra_t new_component =
       xbt_new0(s_routing_component_dijkstra_t, 1);
 {
   routing_component_dijkstra_t new_component =
       xbt_new0(s_routing_component_dijkstra_t, 1);
@@ -469,15 +469,15 @@ void *model_dijkstra_both_create(int cached)
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->generic_routing.bypassRoutes = xbt_dict_new();
   new_component->generic_routing.get_network_element_type = get_network_element_type;
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->generic_routing.bypassRoutes = xbt_dict_new();
   new_component->generic_routing.get_network_element_type = get_network_element_type;
-  return new_component;
+  return (routing_component_t)new_component;
 }
 
 }
 
-void *model_dijkstra_create(void)
+routing_component_t model_dijkstra_create(void)
 {
   return model_dijkstra_both_create(0);
 }
 
 {
   return model_dijkstra_both_create(0);
 }
 
-void *model_dijkstracache_create(void)
+routing_component_t model_dijkstracache_create(void)
 {
   return model_dijkstra_both_create(1);
 }
 {
   return model_dijkstra_both_create(1);
 }
index e744b86..390a28e 100644 (file)
@@ -174,7 +174,7 @@ static void floyd_finalize(routing_component_t rc)
   }
 }
 
   }
 }
 
-void *model_floyd_create(void)
+routing_component_t model_floyd_create(void)
 {
   routing_component_floyd_t new_component =
       xbt_new0(s_routing_component_floyd_t, 1);
 {
   routing_component_floyd_t new_component =
       xbt_new0(s_routing_component_floyd_t, 1);
@@ -195,7 +195,7 @@ void *model_floyd_create(void)
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->generic_routing.bypassRoutes = xbt_dict_new();
   new_component->generic_routing.get_network_element_type = get_network_element_type;
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->generic_routing.bypassRoutes = xbt_dict_new();
   new_component->generic_routing.get_network_element_type = get_network_element_type;
-  return new_component;
+  return (routing_component_t)new_component;
 }
 
 void model_floyd_load(void)
 }
 
 void model_floyd_load(void)
index be6166c..1673f86 100644 (file)
@@ -17,7 +17,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
 
 /* Routing model structure */
 
 
 /* Routing model structure */
 
-typedef struct {
+typedef struct s_routing_component_full {
   s_routing_component_t generic_routing;
   route_extended_t *routing_table;
 } s_routing_component_full_t, *routing_component_full_t;
   s_routing_component_t generic_routing;
   route_extended_t *routing_table;
 } s_routing_component_full_t, *routing_component_full_t;
@@ -124,7 +124,7 @@ static void full_finalize(routing_component_t rc)
 
 /* Creation routing model functions */
 
 
 /* Creation routing model functions */
 
-void *model_full_create(void)
+routing_component_t model_full_create(void)
 {
   routing_component_full_t new_component =
       xbt_new0(s_routing_component_full_t, 1);
 {
   routing_component_full_t new_component =
       xbt_new0(s_routing_component_full_t, 1);
@@ -145,7 +145,7 @@ void *model_full_create(void)
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->generic_routing.bypassRoutes = xbt_dict_new();
   new_component->generic_routing.get_network_element_type = get_network_element_type;
   new_component->generic_routing.to_index = xbt_dict_new();
   new_component->generic_routing.bypassRoutes = xbt_dict_new();
   new_component->generic_routing.get_network_element_type = get_network_element_type;
-  return new_component;
+  return (routing_component_t) new_component;
 }
 
 void model_full_load(void)
 }
 
 void model_full_load(void)
index 43b347b..c26c777 100644 (file)
@@ -53,7 +53,7 @@ static void none_set_autonomous_system(routing_component_t rc,
 }
 
 /* Creation routing model functions */
 }
 
 /* Creation routing model functions */
-void *model_none_create(void)
+routing_component_t model_none_create(void)
 {
   routing_component_none_t new_component =
       xbt_new0(s_routing_component_none_t, 1);
 {
   routing_component_none_t new_component =
       xbt_new0(s_routing_component_none_t, 1);
@@ -69,7 +69,7 @@ void *model_none_create(void)
       none_get_onelink_routes;
   new_component->generic_routing.get_bypass_route = none_get_bypass_route;
   new_component->generic_routing.finalize = none_finalize;
       none_get_onelink_routes;
   new_component->generic_routing.get_bypass_route = none_get_bypass_route;
   new_component->generic_routing.finalize = none_finalize;
-  return new_component;
+  return (routing_component_t) new_component;
 }
 
 void model_none_load(void)
 }
 
 void model_none_load(void)
index 15a2090..a18de1e 100644 (file)
@@ -64,7 +64,7 @@ void generic_src_dst_check(routing_component_t rc, const char *src,
 
 /* ************************************************************************** */
 /* *************************** FLOYD ROUTING ******************************** */
 
 /* ************************************************************************** */
 /* *************************** FLOYD ROUTING ******************************** */
-void *model_floyd_create(void);  /* create structures for floyd routing model */
+routing_component_t model_floyd_create(void);  /* create structures for floyd routing model */
 void model_floyd_load(void);     /* load parse functions for floyd routing model */
 void model_floyd_unload(void);   /* unload parse functions for floyd routing model */
 void model_floyd_end(void);      /* finalize the creation of floyd routing model */
 void model_floyd_load(void);     /* load parse functions for floyd routing model */
 void model_floyd_unload(void);   /* unload parse functions for floyd routing model */
 void model_floyd_end(void);      /* finalize the creation of floyd routing model */
@@ -73,18 +73,18 @@ void model_floyd_set_route(routing_component_t rc, const char *src,
 
 /* ************************************************** */
 /* ************** RULE-BASED ROUTING **************** */
 
 /* ************************************************** */
 /* ************** RULE-BASED ROUTING **************** */
-void *model_rulebased_create(void);      /* create structures for rulebased routing model */
+routing_component_t model_rulebased_create(void);      /* create structures for rulebased routing model */
 
 /* ************************************************** */
 /* **************  Cluster ROUTING   **************** */
 
 /* ************************************************** */
 /* **************  Cluster ROUTING   **************** */
-void *model_cluster_create(void);      /* create structures for cluster routing model */
+routing_component_t model_cluster_create(void);      /* create structures for cluster routing model */
 void model_cluster_unload(void);          /* Finalize the routing model */
 
 void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info);
 
 /* ************************************************** */
 /* **************  Vivaldi ROUTING   **************** */
 void model_cluster_unload(void);          /* Finalize the routing model */
 
 void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info);
 
 /* ************************************************** */
 /* **************  Vivaldi ROUTING   **************** */
-void *model_vivaldi_create(void);      /* create structures for vivaldi routing model */
+routing_component_t model_vivaldi_create(void);      /* create structures for vivaldi routing model */
 #define HOST_PEER(peername) bprintf("peer_%s", peername)
 #define ROUTER_PEER(peername) bprintf("router_%s", peername)
 #define LINK_UP_PEER(peername) bprintf("link_%s_up", peername)
 #define HOST_PEER(peername) bprintf("peer_%s", peername)
 #define ROUTER_PEER(peername) bprintf("router_%s", peername)
 #define LINK_UP_PEER(peername) bprintf("link_%s_up", peername)
@@ -92,9 +92,9 @@ void *model_vivaldi_create(void);      /* create structures for vivaldi routing
 
 /* ************************************************************************** */
 /* ********** Dijkstra & Dijkstra Cached ROUTING **************************** */
 
 /* ************************************************************************** */
 /* ********** Dijkstra & Dijkstra Cached ROUTING **************************** */
-void *model_dijkstra_both_create(int cached);    /* create by calling dijkstra or dijkstracache */
-void *model_dijkstra_create(void);       /* create structures for dijkstra routing model */
-void *model_dijkstracache_create(void);  /* create structures for dijkstracache routing model */
+routing_component_t model_dijkstra_both_create(int cached);    /* create by calling dijkstra or dijkstracache */
+routing_component_t model_dijkstra_create(void);       /* create structures for dijkstra routing model */
+routing_component_t model_dijkstracache_create(void);  /* create structures for dijkstracache routing model */
 void model_dijkstra_both_load(void);     /* load parse functions for dijkstra routing model */
 void model_dijkstra_both_unload(void);   /* unload parse functions for dijkstra routing model */
 void model_dijkstra_both_end(void);      /* finalize the creation of dijkstra routing model */
 void model_dijkstra_both_load(void);     /* load parse functions for dijkstra routing model */
 void model_dijkstra_both_unload(void);   /* unload parse functions for dijkstra routing model */
 void model_dijkstra_both_end(void);      /* finalize the creation of dijkstra routing model */
@@ -103,7 +103,7 @@ void model_dijkstra_both_set_route (routing_component_t rc, const char *src,
 
 /* ************************************************************************** */
 /* *************************** FULL ROUTING ********************************* */
 
 /* ************************************************************************** */
 /* *************************** FULL ROUTING ********************************* */
-void *model_full_create(void);   /* create structures for full routing model */
+routing_component_t model_full_create(void);   /* create structures for full routing model */
 void model_full_load(void);      /* load parse functions for full routing model */
 void model_full_unload(void);    /* unload parse functions for full routing model */
 void model_full_end(void);       /* finalize the creation of full routing model */
 void model_full_load(void);      /* load parse functions for full routing model */
 void model_full_unload(void);    /* unload parse functions for full routing model */
 void model_full_end(void);       /* finalize the creation of full routing model */
@@ -112,7 +112,7 @@ void model_full_set_route(  /* Set the route and ASroute between src and dst */
 
 /* ************************************************************************** */
 /* ******************************* NO ROUTING ******************************* */
 
 /* ************************************************************************** */
 /* ******************************* NO ROUTING ******************************* */
-void *model_none_create(void);           /* none routing model */
+routing_component_t model_none_create(void);           /* none routing model */
 void model_none_load(void);              /* none routing model */
 void model_none_unload(void);            /* none routing model */
 void model_none_end(void);               /* none routing model */
 void model_none_load(void);              /* none routing model */
 void model_none_unload(void);            /* none routing model */
 void model_none_end(void);               /* none routing model */
index 03ae1a4..611ad3e 100644 (file)
@@ -394,7 +394,7 @@ static void rulebased_finalize(routing_component_t rc)
 }
 
 /* Creation routing model functions */
 }
 
 /* Creation routing model functions */
-void *model_rulebased_create(void)
+routing_component_t model_rulebased_create(void)
 {
   routing_component_rulebased_t new_component =
       xbt_new0(s_routing_component_rulebased_t, 1);
 {
   routing_component_rulebased_t new_component =
       xbt_new0(s_routing_component_rulebased_t, 1);
@@ -418,5 +418,5 @@ void *model_rulebased_create(void)
   new_component->list_ASroute =
       xbt_dynar_new(sizeof(rule_route_extended_t),
                     &rule_route_extended_free);
   new_component->list_ASroute =
       xbt_dynar_new(sizeof(rule_route_extended_t),
                     &rule_route_extended_free);
-  return new_component;
+  return (routing_component_t) new_component;
 }
 }
index d53c812..85b8fab 100644 (file)
@@ -7,20 +7,6 @@
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_vivaldi, surf, "Routing part of surf");
 
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_vivaldi, surf, "Routing part of surf");
 
-/* Routing model structure */
-
-typedef struct {
-  s_routing_component_t generic_routing;
-  xbt_dict_t dict_processing_units;
-  xbt_dict_t dict_autonomous_systems;
-} s_routing_component_vivaldi_t, *routing_component_vivaldi_t;
-
-/* Parse routing model functions */
-
-static route_extended_t vivaldi_get_route(routing_component_t rc,
-                                            const char *src,
-                                            const char *dst);
-
 /* Business methods */
 static route_extended_t vivaldi_get_route(routing_component_t rc,
                                             const char *src,
 /* Business methods */
 static route_extended_t vivaldi_get_route(routing_component_t rc,
                                             const char *src,
@@ -85,10 +71,10 @@ static double vivaldi_get_link_latency (routing_component_t rc,const char *src,
 }
 
 /* Creation routing model functions */
 }
 
 /* Creation routing model functions */
-void *model_vivaldi_create(void)
+routing_component_t model_vivaldi_create(void)
 {
 {
-         routing_component_vivaldi_t new_component = model_none_create();
-         new_component->generic_routing.get_route = vivaldi_get_route;
-         new_component->generic_routing.get_latency = vivaldi_get_link_latency;
+         routing_component_t new_component = model_none_create();
+         new_component->get_route = vivaldi_get_route;
+         new_component->get_latency = vivaldi_get_link_latency;
          return new_component;
 }
          return new_component;
 }