Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DNM: PSA core lite additions #2637

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

frkv
Copy link
Contributor

@frkv frkv commented Mar 18, 2025

Work in progress

Macro additions for PSA core lite. Zephyr Needs update with tests before they can be merged

For PSA core lite, see PRs:

frkv added 6 commits March 27, 2025 14:43
…B for examples

-This avoids compliance-errors when using the term CONFIG_BAR e.g. in
 API documentation.
-This avoids compliance-errors when using the terms CONFIG_FLAG_A
 and CONFIG_FLAG_B in API documentation.

NOTE: CONFIG_BAR, CONFIG_FLAG_A, and CONFIG_FLAG_B are not real
configurations

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
(cherry picked from commit 7847bf210af5de3b09c0eb40f4cdf30c284ce79a7)
…tements

-Adding specialized matching for default label to allow macros being
 used in swich-statements.
 Before this commit, any code that makes use of a macro above default:
 in a switch-statement will cause issues complaining about spaces

 Example:
    switch (a) {
        SOME_MACRO(A)
        default:
             break;
    }

 ... would complain on the colon of the default case, regardless of
 the content of the macro

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
(cherry picked from commit ce50a78375d9241a074f72bbb42c27a476fc73e9)
-Added macro IS_ENABLED_ALL to check multiple macro definitions to see
 if ALL of them are define and set to 1. The result of calling this macro
 is compiler-visible expressions resolving to "1" if true, otherwise
 "0".
-Added macro IS_ENABLED_ANY to check multiple macro definitions to see
 if ANY of them are defined and set to 1. The result of calling this
 macro is compiler-visible expressions resolving to "1" if true,
 otherwise "0".
-Added unit tests for IS_ENABLED
-Added unit tests for IS_ENABLED_ALL and IS_ENABLED_ANY

Both macros utilize the same strategy as the IS_ENABLED macro, but
supports variable number of arguments

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
(cherry picked from commit a17af065ae9ae16fd8e38392e6efeff0d20692dd)
-Added macro IF_ENABLED_ALL to emit code if all flags are defined to 1,
 otherwise an empty token is emitted.
-Added macro IF_ENABLED_ANY to emit code if any flags are defined to 1,
 otherwise an empty token is emitted.
-Added unit tests for IF_ENABLED_ALL and IF_ENABLED_ANY

Both macros utilize the same strategy as the IF_ENABLED macro, but
supports a list of flags as a single argument. The flags to check must
be wrapped in parentheses.

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
(cherry picked from commit 7131122bca3100267fa1ec0edff6e7c98afccf31)
…ED_<ALL/ANY>

-Added macro CASE_IF_ENABLED to emit a case in a switch-statement
 if the given flag is define to 1.
-Added macro CASE_IF_ENABLED_ALL to emit code if all flags are defined
 to 1, otherwise an empty token is emitted.
-Added macro CASE_IF_ENABLED_ANY to emit a case code if any flags
 are defined to 1, otherwise an empty token is emitted.
-Added unit tests for CASE_IF_ENABLED, CASE_IF_ENABLED_ALL,
 CASE_IF_ENABLED_ANY

These macros utilize the same strategy as the IF_ENABLED macro

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
(cherry picked from commit 4ee6ef8708d0126afe9f990b505222e6529bc687)
-Add macro UTIL_CONCAT_AND which does a concatenation of a variable
 list of arguments with && between the arguments.
 This macro uses primitive concatenation and doesn't try to process
 them in the preprocessor
-Add macro UTIL_CONCAT_OR which does a concatenation of a variable
 list of arguments with && between the arguments.
 This macro uses primitive concatenation and doesn't try to process
 them in the preprocessor
-Added unit tests for UTIL_CONCAT_AND and UTIL_CONCAT_OR

Signed-off-by: Frank Audun Kvamtrø <frank.kvamtro@nordicsemi.no>
(cherry picked from commit f69266b8b529a9fe751e50767e745e696c216003)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant