summaryrefslogtreecommitdiffstats
path: root/src/vlib
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-11-18 08:43:06 -0500
committerFlorin Coras <florin.coras@gmail.com>2017-11-18 17:04:34 +0000
commitcabbee7d8caeafa3959f4559177ae335567aefb4 (patch)
treea2692a381007e78ffb87586cbd6c19521435ed36 /src/vlib
parent1d6d085d352c8a009cca3bf62fa8975b3b44d90a (diff)
Call a plugin init function by name
Use this macro to arrange init function ordering between friend plugins. Fails in the usual manner if the plugin doesn't exist, or if the init function symbol is AWOL. clib_error_t * thisplug_init (vlib_main_t *vm) { clib_error_t *error = 0; if ((error = vlib_plugin_init_function ("otherplug.so", otherplug_init))) return error; <etc> return error; } VLIB_INIT_FUNCTION(thisplug_init); Change-Id: Ideecaf46bc0b1546e85096e54be8ddef87946565 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/vlib')
-rw-r--r--src/vlib/unix/plugin.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vlib/unix/plugin.h b/src/vlib/unix/plugin.h
index d9801ec439a..52da7436e61 100644
--- a/src/vlib/unix/plugin.h
+++ b/src/vlib/unix/plugin.h
@@ -115,6 +115,32 @@ void *vlib_get_plugin_symbol (char *plugin_name, char *symbol_name);
vlib_plugin_registration_t vlib_plugin_registration \
__attribute__((__section__(".vlib_plugin_registration")))
+/* Call a plugin init function: used for init function dependencies. */
+#define vlib_call_plugin_init_function(vm,p,x) \
+({ \
+ clib_error_t *(*_f)(vlib_main_t *); \
+ uword *_fptr = 0; \
+ clib_error_t * _error = 0; \
+ _fptr= vlib_get_plugin_symbol \
+ (p, CLIB_STRING_MACRO(_vlib_init_function_##x)); \
+ if (_fptr == 0) \
+ { \
+ _error = clib_error_return \
+ (0, "Plugin %s and/or symbol %s not found.", \
+ p, CLIB_STRING_MACRO(_vlib_init_function_##x)); \
+ } \
+ else \
+ { \
+ _f = (void *)(_fptr[0]); \
+ } \
+ if (_fptr && ! hash_get (vm->init_functions_called, _f)) \
+ { \
+ hash_set1 (vm->init_functions_called, _f); \
+ _error = _f (vm); \
+ } \
+ _error; \
+ })
+
#endif /* __included_plugin_h__ */
/*
talic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Copyright (c) 2015 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

bin_PROGRAMS += svmtool svmdbtool

nobase_include_HEADERS += 		\
  svm/ssvm.h 					\
  svm/svm_common.h 				\
  svm/svmdb.h 					\
  svm/svm_fifo.h 				\
  svm/svm_fifo_segment.h		\
  svm/queue.h					\
  svm/message_queue.h			\
  svm/svm.h

lib_LTLIBRARIES += libsvm.la libsvmdb.la

libsvm_la_SOURCES =				\
  svm/svm.c 					\
  svm/ssvm.c 					\
  svm/svm_fifo.c 				\
  svm/svm_fifo_segment.c		\
  svm/queue.c					\
  svm/message_queue.c

libsvm_la_LIBADD = libvppinfra.la -lrt -lpthread
libsvm_la_DEPENDENCIES = libvppinfra.la

svmtool_SOURCES = svm/svmtool.c
svmtool_LDADD = libsvm.la libvppinfra.la -lpthread -lrt

libsvmdb_la_LIBADD = libvppinfra.la libsvm.la
libsvmdb_la_DEPENDENCIES = libvppinfra.la libsvm.la
libsvmdb_la_SOURCES = svm/svmdb.c

svmdbtool_SOURCES = svm/svmdbtool.c
svmdbtool_LDADD = libsvmdb.la libsvm.la libvppinfra.la -lpthread -lrt

noinst_PROGRAMS += 				\
  test_svm_fifo1				\
  test_svm_message_queue

test_svm_fifo1_SOURCES = svm/test_svm_fifo1.c
test_svm_fifo1_LDADD = libsvm.la libvppinfra.la -lpthread -lrt
test_svm_fifo1_LDFLAGS = -static

test_svm_message_queue_SOURCES = svm/test_svm_message_queue.c
test_svm_message_queue_LDADD = libsvm.la libvppinfra.la -lpthread -lrt
test_svm_message_queue_LDFLAGS = -static

# vi:syntax=automake