Fix the fifo-size limitation in tcp_echo
[vpp.git] / src / vlib / init.h
index 4fa5b30..f163ee2 100644 (file)
@@ -79,6 +79,27 @@ typedef struct vlib_config_function_runtime_t
   char name[32];
 } vlib_config_function_runtime_t;
 
+#define VLIB_REMOVE_FROM_LINKED_LIST(first,p,next)              \
+{                                                               \
+  ASSERT (first);                                               \
+  if (first == p)                                               \
+      first = (p)->next;                                        \
+  else                                                          \
+    {                                                           \
+      __typeof__ (p) current = first;                           \
+      while (current->next)                                     \
+       {                                                       \
+         if (current->next == p)                               \
+           {                                                   \
+             current->next = current->next->next;              \
+             break;                                            \
+           }                                                   \
+         current = current->next;                              \
+       }                                                       \
+      ASSERT (current);                                         \
+    }                                                           \
+}
+
 #define _VLIB_INIT_FUNCTION_SYMBOL(x, type)    \
   _vlib_##type##_function_##x
 
@@ -106,9 +127,34 @@ static void __vlib_add_##tag##_function_##x (void)              \
     = vm->tag##_function_registrations;                         \
   vm->tag##_function_registrations = &_vlib_init_function;      \
  _vlib_init_function.f = &x;                                    \
+}                                                               \
+static void __vlib_rm_##tag##_function_##x (void)               \
+    __attribute__((__destructor__)) ;                           \
+static void __vlib_rm_##tag##_function_##x (void)               \
+{                                                               \
+  vlib_main_t * vm = vlib_get_main();                           \
+  _vlib_init_function_list_elt_t *next;                         \
+  if (vm->tag##_function_registrations->f == &x)                \
+    {                                                           \
+      vm->tag##_function_registrations =                        \
+        vm->tag##_function_registrations->next_init_function;   \
+      return;                                                   \
+    }                                                           \
+  next = vm->tag##_function_registrations;                      \
+  while (next->next_init_function)                              \
+    {                                                           \
+      if (next->next_init_function->f == &x)                    \
+        {                                                       \
+          next->next_init_function =                            \
+            next->next_init_function->next_init_function;       \
+          return;                                               \
+        }                                                       \
+      next = next->next_init_function;                          \
+    }                                                           \
 }
 
 #define VLIB_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,init)
+#define VLIB_WORKER_INIT_FUNCTION(x) VLIB_DECLARE_INIT_FUNCTION(x,worker_init)
 
 #define VLIB_MAIN_LOOP_ENTER_FUNCTION(x) \
   VLIB_DECLARE_INIT_FUNCTION(x,main_loop_enter)
@@ -127,6 +173,16 @@ static void __vlib_add_config_function_##x (void)               \
        = vm->config_function_registrations;                     \
     vm->config_function_registrations                           \
        = &VLIB_CONFIG_FUNCTION_SYMBOL(x);                       \
+}                                                               \
+static void __vlib_rm_config_function_##x (void)                \
+    __attribute__((__destructor__)) ;                           \
+static void __vlib_rm_config_function_##x (void)                \
+{                                                               \
+    vlib_main_t * vm = vlib_get_main();                         \
+    vlib_config_function_runtime_t *p =                         \
+       & VLIB_CONFIG_FUNCTION_SYMBOL (x);                       \
+    VLIB_REMOVE_FROM_LINKED_LIST                                \
+      (vm->config_function_registrations, p, next_registration);\
 }                                                               \
   vlib_config_function_runtime_t                                \
     VLIB_CONFIG_FUNCTION_SYMBOL (x)                             \
@@ -148,6 +204,16 @@ static void __vlib_add_config_function_##x (void)               \
        = vm->config_function_registrations;                     \
     vm->config_function_registrations                           \
        = &VLIB_CONFIG_FUNCTION_SYMBOL(x);                       \
+}                                                               \
+static void __vlib_rm_config_function_##x (void)                \
+    __attribute__((__destructor__)) ;                           \
+static void __vlib_rm_config_function_##x (void)                \
+{                                                               \
+    vlib_main_t * vm = vlib_get_main();                         \
+    vlib_config_function_runtime_t *p =                         \
+       & VLIB_CONFIG_FUNCTION_SYMBOL (x);                       \
+    VLIB_REMOVE_FROM_LINKED_LIST                                \
+      (vm->config_function_registrations, p, next_registration);\
 }                                                               \
   vlib_config_function_runtime_t                                \
     VLIB_CONFIG_FUNCTION_SYMBOL (x)                             \