aboutsummaryrefslogtreecommitdiffstats
path: root/src/vlib/buffer.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-03-08 19:08:56 -0500
committerOle Trøan <otroan@employees.org>2017-03-09 19:07:17 +0000
commit80f54e20270ed0628ee725e3e3c515731a0188f2 (patch)
treefa06d939942af6f5126ee645c38cb787814bfb6f /src/vlib/buffer.c
parentb3b2de71ceea0cc7ce18f89cc8180ed4a42e355d (diff)
vlib_mains == 0 special cases be gone
Clean up spurious binary API client link dependency on libvlib.so, which managed to hide behind vlib_mains == 0 checks reached by VLIB_xxx_FUNCTION macros. Change-Id: I5df1f8ab07dca1944250e643ccf06e60a8462325 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib/buffer.c')
-rw-r--r--src/vlib/buffer.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/vlib/buffer.c b/src/vlib/buffer.c
index 9f26bec7..6ba82584 100644
--- a/src/vlib/buffer.c
+++ b/src/vlib/buffer.c
@@ -261,7 +261,28 @@ done:
return result;
}
-vlib_main_t **vlib_mains;
+/*
+ * Hand-craft a static vector w/ length 1, so vec_len(vlib_mains) =1
+ * and vlib_mains[0] = &vlib_global_main from the beginning of time.
+ *
+ * The only place which should ever expand vlib_mains is start_workers()
+ * in threads.c. It knows about the bootstrap vector.
+ */
+/* *INDENT-OFF* */
+static struct
+{
+ vec_header_t h;
+ vlib_main_t *vm;
+} __attribute__ ((packed)) __bootstrap_vlib_main_vector
+ __attribute__ ((aligned (CLIB_CACHE_LINE_BYTES))) =
+{
+ .h.len = 1,
+ .vm = &vlib_global_main,
+};
+/* *INDENT-ON* */
+
+vlib_main_t **vlib_mains = &__bootstrap_vlib_main_vector.vm;
+
/* When dubugging validate that given buffers are either known allocated
or known free. */
@@ -280,7 +301,7 @@ vlib_buffer_validate_alloc_free (vlib_main_t * vm,
ASSERT (os_get_cpu_number () == 0);
/* smp disaster check */
- if (vlib_mains)
+ if (vec_len (vlib_mains) > 1)
ASSERT (vm == vlib_mains[0]);
is_free = expected_state == VLIB_BUFFER_KNOWN_ALLOCATED;
@@ -956,7 +977,7 @@ show_buffers (vlib_main_t * vm,
do
{
- curr_vm = vec_len (vlib_mains) ? vlib_mains[vm_index] : vm;
+ curr_vm = vlib_mains[vm_index];
bm = curr_vm->buffer_main;
/* *INDENT-OFF* */