[tor-dev] circuitmux_ewma.c

Gisle Vanem gvanem at broadpark.no
Thu Nov 1 17:04:22 UTC 2012


These gcc extensions:

/*** EWMA circuitmux_policy_t method table ***/

circuitmux_policy_t ewma_policy = {  .alloc_cmux_data = ewma_alloc_cmux_data,
  .free_cmux_data = ewma_free_cmux_data,

Doesn't work well with MSVC. Here is a patch:

--- ..\..\Git-latest\src\or\circuitmux_ewma.c   2012-11-01 15:53:23.125000000 +0100
+++ circuitmux_ewma.c   2012-11-01 17:52:55.371093500 +0100
@@ -200,15 +200,22 @@

 /*** EWMA circuitmux_policy_t method table ***/

-circuitmux_policy_t ewma_policy = {  .alloc_cmux_data = ewma_alloc_cmux_data,
-  .free_cmux_data = ewma_free_cmux_data,
-  .alloc_circ_data = ewma_alloc_circ_data,
-  .free_circ_data = ewma_free_circ_data,
-  .notify_circ_active = ewma_notify_circ_active,
-  .notify_circ_inactive = ewma_notify_circ_inactive,
-  .notify_set_n_cells = NULL, /* EWMA doesn't need this */
-  .notify_xmit_cells = ewma_notify_xmit_cells,
-  .pick_active_circuit = ewma_pick_active_circuit
+#ifdef __GNUC__
+  #define STRUCT_INIT(member,val) member = val
+#else
+  #define STRUCT_INIT(member,val) val
+#endif
+
+circuitmux_policy_t ewma_policy = {
+  STRUCT_INIT (.alloc_cmux_data, ewma_alloc_cmux_data),
+  STRUCT_INIT (.free_cmux_data, ewma_free_cmux_data),
+  STRUCT_INIT (.alloc_circ_data, ewma_alloc_circ_data),
+  STRUCT_INIT (.free_circ_data, ewma_free_circ_data),
+  STRUCT_INIT (.notify_circ_active, ewma_notify_circ_active),
+  STRUCT_INIT (.notify_circ_inactive, ewma_notify_circ_inactive),
+  STRUCT_INIT (.notify_set_n_cells, NULL), /* EWMA doesn't need this */
+  STRUCT_INIT (.notify_xmit_cells, ewma_notify_xmit_cells),
+  STRUCT_INIT (.pick_active_circuit, ewma_pick_active_circuit)
 };

 /*** EWMA method implementations using the below EWMA helper functions ***/

--gv


More information about the tor-dev mailing list