[dpdk-dev] [PATCH v2 01/18] eal: introduce dtor macros

Neil Horman nhorman at tuxdriver.com
Thu Mar 22 12:35:55 CET 2018


On Wed, Mar 21, 2018 at 06:15:22PM +0100, Gaetan Rivet wrote:
> Signed-off-by: Gaetan Rivet <gaetan.rivet at 6wind.com>
> ---
>  lib/librte_eal/common/include/rte_common.h | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
> 
> diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
> index c7803e41c..500fc3adb 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -105,6 +105,29 @@ static void __attribute__((constructor, used)) func(void)
>  static void __attribute__((constructor(prio), used)) func(void)
>  
>  /**
> + * Run after main() with high priority.
> + *
> + * The destructor will be run *before* prioritized destructors.
> + *
> + * @param func
> + *   Destructor function name.
> + */
> +#define RTE_FINI(func) \
> +static void __attribute__((destructor, used)) func(void)
> +
> +/**
> + * Run after main() with low priority.
> + *
> + * @param func
> + *   Destructor function name.
> + * @param prio
> + *   Priority number must be above 100.
> + *   Lowest number is the last to run.
> + */
> +#define RTE_FINI_PRIO(func, prio) \
> +static void __attribute__((destructor(prio), used)) func(void)
> +
> +/**
If you need to require that priority be above 100, you probably want to create a
BUILD_BUG type macro to enforce that.

Neil

>   * Force a function to be inlined
>   */
>  #define __rte_always_inline inline __attribute__((always_inline))
> -- 
> 2.11.0
> 
> 


More information about the dev mailing list