summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-06-14 09:18:21 -0400
committerFlorin Coras <florin.coras@gmail.com>2018-06-14 18:52:47 +0000
commit1f806587d8e1d94ee7630cee134fbaae2de2f31e (patch)
treefb46e53861b5eebbf1333f85ded79c0558802bf3
parentabcddcbcabb180595ec8041ac7cf07249d896dc4 (diff)
Use __attribute__((weak)) references where necessary
It should be possible to use vlib without the vlibmemory library, etc. Change-Id: Ic2316b93d7dbb728fb4ff42a3ca8b0d747c9425e Signed-off-by: Dave Barach <dave@barachs.net>
-rw-r--r--src/vlib/main.c21
-rw-r--r--src/vlibmemory/memory_api.c6
-rw-r--r--src/vpp/api/api.c5
-rw-r--r--src/vpp/conf/startup.conf4
-rw-r--r--src/vpp/stats/stat_segment.c6
5 files changed, 25 insertions, 17 deletions
diff --git a/src/vlib/main.c b/src/vlib/main.c
index e4c4438b5aa..f9b38b27061 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -1678,6 +1678,18 @@ dummy_queue_signal_callback (vlib_main_t * vm)
{
}
+#define foreach_weak_reference_stub \
+_(vlib_map_stat_segment_init) \
+_(vpe_api_init) \
+_(vlibmemory_init) \
+_(map_api_segment_init)
+
+#define _(name) \
+clib_error_t *name (vlib_main_t *vm) __attribute__((weak)); \
+clib_error_t *name (vlib_main_t *vm) { return 0; }
+foreach_weak_reference_stub;
+#undef _
+
/* Main function. */
int
vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
@@ -1717,7 +1729,7 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
goto done;
}
- if ((error = vlib_call_init_function (vm, map_stat_segment_init)))
+ if ((error = vlib_map_stat_segment_init (vm)))
{
clib_error_report (error);
goto done;
@@ -1742,19 +1754,20 @@ vlib_main (vlib_main_t * volatile vm, unformat_input_t * input)
goto done;
}
- if ((error = vlib_call_init_function (vm, vpe_api_init)))
+ /* Direct call / weak reference, for vlib standalone use-cases */
+ if ((error = vpe_api_init (vm)))
{
clib_error_report (error);
goto done;
}
- if ((error = vlib_call_init_function (vm, vlibmemory_init)))
+ if ((error = vlibmemory_init (vm)))
{
clib_error_report (error);
goto done;
}
- if ((error = vlib_call_init_function (vm, map_api_segment_init)))
+ if ((error = map_api_segment_init (vm)))
{
clib_error_report (error);
goto done;
diff --git a/src/vlibmemory/memory_api.c b/src/vlibmemory/memory_api.c
index 4d31b35f132..1da77c5b29b 100644
--- a/src/vlibmemory/memory_api.c
+++ b/src/vlibmemory/memory_api.c
@@ -459,7 +459,7 @@ vl_mem_api_init (const char *region_name)
return 0;
}
-static clib_error_t *
+clib_error_t *
map_api_segment_init (vlib_main_t * vm)
{
api_main_t *am = &api_main;
@@ -473,8 +473,6 @@ map_api_segment_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (map_api_segment_init);
-
static void
send_memclnt_keepalive (vl_api_registration_t * regp, f64 now)
{
@@ -916,8 +914,6 @@ vlibmemory_init (vlib_main_t * vm)
return error;
}
-VLIB_INIT_FUNCTION (vlibmemory_init);
-
void
vl_set_memory_region_name (const char *name)
{
diff --git a/src/vpp/api/api.c b/src/vpp/api/api.c
index 8e24493c0ce..6c06ab4cef3 100644
--- a/src/vpp/api/api.c
+++ b/src/vpp/api/api.c
@@ -474,7 +474,7 @@ vpe_api_hookup (vlib_main_t * vm)
VLIB_API_INIT_FUNCTION (vpe_api_hookup);
-static clib_error_t *
+clib_error_t *
vpe_api_init (vlib_main_t * vm)
{
vpe_api_main_t *am = &vpe_api_main;
@@ -492,9 +492,6 @@ vpe_api_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (vpe_api_init);
-
-
static clib_error_t *
api_segment_config (vlib_main_t * vm, unformat_input_t * input)
{
diff --git a/src/vpp/conf/startup.conf b/src/vpp/conf/startup.conf
index 7ed279840fa..c1ac1235861 100644
--- a/src/vpp/conf/startup.conf
+++ b/src/vpp/conf/startup.conf
@@ -28,6 +28,10 @@ api-segment {
gid vpp
}
+socksvr {
+ default
+}
+
cpu {
## In the VPP there is one main thread and optionally the user can create worker(s)
## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically
diff --git a/src/vpp/stats/stat_segment.c b/src/vpp/stats/stat_segment.c
index 6fb9c83a369..16a727dbf64 100644
--- a/src/vpp/stats/stat_segment.c
+++ b/src/vpp/stats/stat_segment.c
@@ -186,8 +186,8 @@ vlib_stats_pop_heap2 (u64 * counter_vector, u32 thread_index, void *oldheap)
ssvm_pop_heap (oldheap);
}
-static clib_error_t *
-map_stat_segment_init (vlib_main_t * vm)
+clib_error_t *
+vlib_map_stat_segment_init (void)
{
stats_main_t *sm = &stats_main;
ssvm_private_t *ssvmp = &sm->stat_segment;
@@ -269,8 +269,6 @@ map_stat_segment_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (map_stat_segment_init);
-
typedef struct
{
u8 *name;