I am traversing through linux kernel code. I found a macro defined as #define __async_inline __always_inline
. I searched for __always_inline
,I found the following statement #define __always_inline inline
. My question is why they need to do like this? They can directly use inline
instead of this macro's?
The code says this:
#ifdef CONFIG_HAS_DMA
#define __async_inline
#else
#define __async_inline __always_inline
#endif
It is self-explained. __async_inline
will be replaced by inline
if CONFIG_HAS_DMA
is not defined.
This is a common way to parameterize code, to move a decision of some sort (in this case, the use of inline
) to a single place, so that should that decision change (for whatever reason: different compilers, different configuration options, different architectures), there is only one single place to change.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With