baremetal execution environments may have a different method to enable RTE_INIT instead of using compiler constructor scheme. Move RTE_INIT* definition under exec-env to support different execution environments.
Signed-off-by: Jerin Jacob <jerin.ja...@caviumnetworks.com> --- app/test-eventdev/evt_test.h | 2 +- lib/librte_eal/bsdapp/eal/Makefile | 2 +- .../bsdapp/eal/include/exec-env/rte_eal.h | 51 ++++++++++++++++++++++ lib/librte_eal/common/eal_common_log.c | 2 + lib/librte_eal/common/include/rte_bus.h | 2 + lib/librte_eal/common/include/rte_eal.h | 6 --- lib/librte_eal/common/include/rte_tailq.h | 2 + lib/librte_eal/linuxapp/eal/Makefile | 2 +- .../linuxapp/eal/include/exec-env/rte_eal.h | 51 ++++++++++++++++++++++ 9 files changed, 111 insertions(+), 9 deletions(-) create mode 100644 lib/librte_eal/bsdapp/eal/include/exec-env/rte_eal.h create mode 100644 lib/librte_eal/linuxapp/eal/include/exec-env/rte_eal.h diff --git a/app/test-eventdev/evt_test.h b/app/test-eventdev/evt_test.h index 17bdd1650..f63f9a814 100644 --- a/app/test-eventdev/evt_test.h +++ b/app/test-eventdev/evt_test.h @@ -37,7 +37,7 @@ #include <stdbool.h> #include <sys/queue.h> -#include <rte_eal.h> +#include <exec-env/rte_eal.h> enum evt_test_result { EVT_TEST_SUCCESS, diff --git a/lib/librte_eal/bsdapp/eal/Makefile b/lib/librte_eal/bsdapp/eal/Makefile index 05517a2dc..2f5574f79 100644 --- a/lib/librte_eal/bsdapp/eal/Makefile +++ b/lib/librte_eal/bsdapp/eal/Makefile @@ -107,7 +107,7 @@ CFLAGS_eal_thread.o += -Wno-return-type CFLAGS_eal_hpet.o += -Wno-return-type endif -INC := rte_interrupts.h +INC := rte_interrupts.h rte_eal.h SYMLINK-$(CONFIG_RTE_EXEC_ENV_BSDAPP)-include/exec-env := \ $(addprefix include/exec-env/,$(INC)) diff --git a/lib/librte_eal/bsdapp/eal/include/exec-env/rte_eal.h b/lib/librte_eal/bsdapp/eal/include/exec-env/rte_eal.h new file mode 100644 index 000000000..1f3222f01 --- /dev/null +++ b/lib/librte_eal/bsdapp/eal/include/exec-env/rte_eal.h @@ -0,0 +1,51 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _BSDAPP_RTE_EAL_H_ +#define _BSDAPP_RTE_EAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTE_INIT(func) \ +static void __attribute__((constructor, used)) func(void) + +#define RTE_INIT_PRIO(func, prio) \ +static void __attribute__((constructor(prio), used)) func(void) + +#ifdef __cplusplus +} +#endif + +#endif /* _BSDAPP_RTE_EAL_H_ */ diff --git a/lib/librte_eal/common/eal_common_log.c b/lib/librte_eal/common/eal_common_log.c index 0e3b93209..236a662b0 100644 --- a/lib/librte_eal/common/eal_common_log.c +++ b/lib/librte_eal/common/eal_common_log.c @@ -43,6 +43,8 @@ #include <rte_log.h> #include <rte_per_lcore.h> +#include <exec-env/rte_eal.h> + #include "eal_private.h" /* global log structure */ diff --git a/lib/librte_eal/common/include/rte_bus.h b/lib/librte_eal/common/include/rte_bus.h index c79368d3c..52e13bd0d 100644 --- a/lib/librte_eal/common/include/rte_bus.h +++ b/lib/librte_eal/common/include/rte_bus.h @@ -52,6 +52,8 @@ extern "C" { #include <rte_log.h> #include <rte_dev.h> +#include <exec-env/rte_eal.h> + /** Double linked list of buses */ TAILQ_HEAD(rte_bus_list, rte_bus); diff --git a/lib/librte_eal/common/include/rte_eal.h b/lib/librte_eal/common/include/rte_eal.h index 0e7363d77..cce5160bd 100644 --- a/lib/librte_eal/common/include/rte_eal.h +++ b/lib/librte_eal/common/include/rte_eal.h @@ -287,12 +287,6 @@ static inline int rte_gettid(void) return RTE_PER_LCORE(_thread_id); } -#define RTE_INIT(func) \ -static void __attribute__((constructor, used)) func(void) - -#define RTE_INIT_PRIO(func, prio) \ -static void __attribute__((constructor(prio), used)) func(void) - #ifdef __cplusplus } #endif diff --git a/lib/librte_eal/common/include/rte_tailq.h b/lib/librte_eal/common/include/rte_tailq.h index 3aae098ae..6a5ca3731 100644 --- a/lib/librte_eal/common/include/rte_tailq.h +++ b/lib/librte_eal/common/include/rte_tailq.h @@ -48,6 +48,8 @@ extern "C" { #include <stdio.h> #include <rte_debug.h> +#include <exec-env/rte_eal.h> + /** dummy structure type used by the rte_tailq APIs */ struct rte_tailq_entry { TAILQ_ENTRY(rte_tailq_entry) next; /**< Pointer entries for a tailq list */ diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linuxapp/eal/Makefile index e6ab6c30f..ec8ffddf4 100644 --- a/lib/librte_eal/linuxapp/eal/Makefile +++ b/lib/librte_eal/linuxapp/eal/Makefile @@ -130,7 +130,7 @@ ifeq ($(CONFIG_RTE_TOOLCHAIN_GCC),y) CFLAGS_eal_thread.o += -Wno-return-type endif -INC := rte_interrupts.h rte_kni_common.h rte_dom0_common.h +INC := rte_interrupts.h rte_kni_common.h rte_dom0_common.h rte_eal.h SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUXAPP)-include/exec-env := \ $(addprefix include/exec-env/,$(INC)) diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_eal.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_eal.h new file mode 100644 index 000000000..bac4924a6 --- /dev/null +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_eal.h @@ -0,0 +1,51 @@ +/*- + * BSD LICENSE + * + * Copyright(c) 2010-2017 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUXAPP_RTE_EAL_H_ +#define _LINUXAPP_RTE_EAL_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RTE_INIT(func) \ +static void __attribute__((constructor, used)) func(void) + +#define RTE_INIT_PRIO(func, prio) \ +static void __attribute__((constructor(prio), used)) func(void) + +#ifdef __cplusplus +} +#endif + +#endif /* _LINUXAPP_RTE_EAL_H_ */ -- 2.14.0