[v2] eal: change init macro as exec environment specific

Message ID 20190403192819.20243-1-jerinj@marvell.com (mailing list archive)
State Accepted, archived
Headers
Series [v2] eal: change init macro as exec environment specific |

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Jerin Jacob Kollanukkaran April 3, 2019, 7:28 p.m. UTC
  From: Jerin Jacob <jerinj@marvell.com>

baremetal execution environments may have a different
method to enable RTE_INIT instead of using compiler
constructor and/or OS specific linker scheme.
Allow an option to override RTE_INIT* macros using
rte_os.h or appropriate header file.

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---

v2:
- Leverage the rte_os.h created by Windows port to override RTE_INIT* macro if needed.
- Removed the exec environment specific librte_eal/<OS>/eal/include/exec-env/rte_exec-env.h
file creation
- Removed the duplication of RTE_INIT_* definition on each rte_exec-env.h file
as it is common for Linux,FreeBSD and Windows port

---
 lib/librte_eal/common/include/rte_common.h | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Thomas Monjalon April 3, 2019, 8:07 p.m. UTC | #1
03/04/2019 21:28, Jerin Jacob Kollanukkaran:
> From: Jerin Jacob <jerinj@marvell.com>
> 
> baremetal execution environments may have a different
> method to enable RTE_INIT instead of using compiler
> constructor and/or OS specific linker scheme.
> Allow an option to override RTE_INIT* macros using
> rte_os.h or appropriate header file.
> 
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
> 
> v2:
> - Leverage the rte_os.h created by Windows port to override RTE_INIT* macro if needed.
> - Removed the exec environment specific librte_eal/<OS>/eal/include/exec-env/rte_exec-env.h
> file creation
> - Removed the duplication of RTE_INIT_* definition on each rte_exec-env.h file
> as it is common for Linux,FreeBSD and Windows port
> 
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -106,8 +106,10 @@ typedef uint16_t unaligned_uint16_t;
>   *   Priority number must be above 100.
>   *   Lowest number is the first to run.
>   */
> +#ifndef RTE_INIT_PRIO /* Allow to override from eal */
>  #define RTE_INIT_PRIO(func, prio) \
>  static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)
> +#endif

I did not think about such #ifndef, it's a lot simpler :)

As a nit, I would just fix eal to uppercase EAL in the above comment.
I may do it on apply.

Acked-by: Thomas Monjalon <thomas@monjalon.net>
  
Thomas Monjalon April 3, 2019, 9:52 p.m. UTC | #2
03/04/2019 22:07, Thomas Monjalon:
> 03/04/2019 21:28, Jerin Jacob Kollanukkaran:
> > From: Jerin Jacob <jerinj@marvell.com>
> > 
> > baremetal execution environments may have a different
> > method to enable RTE_INIT instead of using compiler
> > constructor and/or OS specific linker scheme.
> > Allow an option to override RTE_INIT* macros using
> > rte_os.h or appropriate header file.
> > 
> > Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> 
> Acked-by: Thomas Monjalon <thomas@monjalon.net>

Applied, thanks
  

Patch

diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 1d3c33021..f2691b4e1 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -106,8 +106,10 @@  typedef uint16_t unaligned_uint16_t;
  *   Priority number must be above 100.
  *   Lowest number is the first to run.
  */
+#ifndef RTE_INIT_PRIO /* Allow to override from eal */
 #define RTE_INIT_PRIO(func, prio) \
 static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)
+#endif
 
 /**
  * Run function before main() with low priority.
@@ -129,8 +131,10 @@  static void __attribute__((constructor(RTE_PRIO(prio)), used)) func(void)
  *   Priority number must be above 100.
  *   Lowest number is the last to run.
  */
+#ifndef RTE_FINI_PRIO /* Allow to override from eal */
 #define RTE_FINI_PRIO(func, prio) \
 static void __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
+#endif
 
 /**
  * Run after main() with high priority.