DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] toolchain specific macro expansion
@ 2021-06-23 18:26 Tyler Retzlaff
  2021-06-24  6:54 ` Thomas Monjalon
  0 siblings, 1 reply; 8+ messages in thread
From: Tyler Retzlaff @ 2021-06-23 18:26 UTC (permalink / raw)
  To: dev; +Cc: thomas, ferruh.yigit, dmitry.kozliuk, david.marchand

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.


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))

// lib/eal/include/rte_common.h
#include <rte_toolchain_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.


we are interested in hearing about alternatives not listed here but in
the absence of other options we would propose to submit a patch
following option 2.

comments and alternatives welcome.

thanks


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-07-07 20:56 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-23 18:26 [dpdk-dev] [RFC] toolchain specific macro expansion Tyler Retzlaff
2021-06-24  6:54 ` Thomas Monjalon
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

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).