DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: Tyler Retzlaff <roretzla@linux.microsoft.com>
Cc: dev@dpdk.org, ferruh.yigit@intel.com, dmitry.kozliuk@gmail.com,
	david.marchand@redhat.com
Subject: Re: [dpdk-dev] [RFC] toolchain specific macro expansion
Date: Thu, 24 Jun 2021 08:54:49 +0200	[thread overview]
Message-ID: <3277479.bKIgzLV6lZ@thomas> (raw)
In-Reply-To: <20210623182657.GA24634@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net>

23/06/2021 20:26, Tyler Retzlaff:
> today rte_common.h defines common macros for use by dpdk and consuming
> applications. most expansions are specific to the gcc toolchain.
> 
> example
> // lib/eal/include/rte_common.h
> 
> /**
>  * Hint never returning function
>  */
> #define __rte_noreturn __attribute__((noreturn))
> 
> there is an anticipated need rte_common.h to expose alternate
> expansions for non-gcc toolchains in the future and would like
> comments on how to achieve this in an agreeable manner.
> 
> 
> option 1 add conditional compilation directly to rte_common.h
> 
> example
> // lib/eal/include/rte_common.h
> 
> /**
>  * Hint never returning function
>  */
> #ifdef RTE_TOOLCHAIN_GCC
> #define __rte_noreturn __attribute__((noreturn))
> #endif
> 
> #ifdef RTE_TOOLCHAIN_FOO
> #define __rte_noreturn __foo_expansion_for_noreturn
> #endif
> 
> represents the simplest approach technically but may be tedious to
> maintain due to the number of macros and number of conditional
> expansions per macro.

Macros are simple so the option 1 is not that bad.


> option 2 add toolchain specific files (follow existing platform/os
>          includes pattern)
> 
> example:
> // lib/eal/gcc/rte_toolchain_common.h
> #define __rte_noreturn __attribute__((noreturn))

We should keep a macro in rte_common.h which triggers an explicit error
if not overriden for the toolchain.
That way we can have a single doxygen comment in rte_common.h
like it is done in lib/eal/include/generic/

> // lib/eal/include/rte_common.h
> #include <rte_toolchain_common.h>

The include may be done in the reverse order:
the toolchain-specific .h in lib/eal/gcc/include/
includes generic/rte_common.h in lib/eal/include/generic/.
If both have the same name, we keep #include <rte_common.h>

> // meson.build (illustrative change)
> host_toolchain = cc.get_id() # e.g. gcc
> 
> global_inc = include_directories('.', 'config',
>     'lib/eal/include',
>     'lib/eal/@0@/include'.format(host_machine.system()),
>     'lib/eal/@0@/include'.format(arch_subdir),
>     'lib/eal/@0@/include'.format(host_toolchain),
> )
> 
> results in the introduction of more files that need to be
> published/installed for applications but separate files per
> implementation allow for easier maintainability.




  reply	other threads:[~2021-06-24  6:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 18:26 Tyler Retzlaff
2021-06-24  6:54 ` Thomas Monjalon [this message]
2021-06-24 16:02   ` Tyler Retzlaff
2021-06-24 16:29     ` Thomas Monjalon
2021-06-28 14:33       ` Tyler Retzlaff
2021-07-07 20:23       ` Tyler Retzlaff
2021-07-07 20:35         ` Thomas Monjalon
2021-07-07 20:56           ` Tyler Retzlaff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3277479.bKIgzLV6lZ@thomas \
    --to=thomas@monjalon.net \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=dmitry.kozliuk@gmail.com \
    --cc=ferruh.yigit@intel.com \
    --cc=roretzla@linux.microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).