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

sys/util.h: Add IS_ALIGNED macro #67243

Merged
merged 1 commit into from
Feb 26, 2024
Merged

Conversation

yonsch
Copy link
Contributor

@yonsch yonsch commented Jan 5, 2024

Add an IS_ALIGNED macro, to test if a value x is aligned to an alignment align. This has been independently defined in multiple areas throughout the tree and modules. This PR fixes only those instances where the macro name collides with the sys/util macro.

@zephyrbot
Copy link
Collaborator

zephyrbot commented Jan 5, 2024

The following west manifest projects have been modified in this Pull Request:

Name Old Revision New Revision Diff

Note: This message is automatically posted and updated by the Manifest GitHub Action.

@zephyrbot zephyrbot added manifest manifest-sof DNM This PR should not be merged (Do Not Merge) labels Jan 5, 2024
peter-mitsis
peter-mitsis previously approved these changes Jan 5, 2024
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Macro itself looks great. Cross-repo change management strategy seems wrong though.

@@ -34,7 +34,7 @@ manifest:
groups:
- optional
- name: sof
revision: e7cb489d430dc2181e4a5f7f953ed1eaeec6668d
revision: pull/35/head
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the right way to do this. The fix needs to merge first, otherwise these YAML files become constant games of ping-pong chasing upstream patches.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just to have the fix tested with Zephyr's CI before it's merged in the external module.

Copy link
Collaborator

@marc-hb marc-hb Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The SOF macro IS_ALIGN() is used in only 4 places! Just rename it to SOF_ALIGN() as requested by https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions and make your forward, backward and backflip manifest life much easier.

EDIT: rejected in thesofproject/sof#8755

andyross
andyross previously approved these changes Jan 11, 2024
Copy link
Contributor

@andyross andyross left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like SOF upstream is aware and aligned, no reason not to approve. Though it still needs a real commit ID in the west.yaml and not a pull ref.

ceolin
ceolin previously approved these changes Jan 15, 2024
@@ -277,6 +277,13 @@ extern "C" {
*/
#define CONCAT(x, y) _DO_CONCAT(x, y)

#ifndef IS_ALIGNED
Copy link
Collaborator

@marc-hb marc-hb Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't do "opportunistic" macro definitions like this because debugging macros is the worst nightmare ever.

From https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions

Macros with commonly used names such as MIN, MAX, ARRAY_SIZE, must NOT be modified or protected to avoid name collisions with other implementations. In particular, they must not be prefixed to place them in a Zephyr-specific namespace, re-defined using #undef, or conditionally excluded from compilation using #ifndef.

marc-hb added a commit to marc-hb/sof that referenced this pull request Jan 17, 2024
This is the simplest, cheapest and safest to avoid the collision with
the incoming Zephyr macro IS_ALIGN() submitted in
zephyrproject-rtos/zephyr#67243

As SOF depends on Zephyr, most SOF symbols should be prefixed SOF_ or
something specific.

This is compliant with:
https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions

Signed-off-by: Marc Herbert <[email protected]>
@yonsch yonsch dismissed stale reviews from ceolin, andyross, and peter-mitsis via b6e3d3d January 28, 2024 20:49
@zephyrbot zephyrbot removed manifest manifest-sof DNM This PR should not be merged (Do Not Merge) labels Jan 28, 2024
@yonsch yonsch requested a review from ceolin January 28, 2024 21:48
@yonsch yonsch requested review from andyross and marc-hb January 28, 2024 21:48
marc-hb
marc-hb previously approved these changes Jan 28, 2024
@marc-hb marc-hb dismissed their stale review January 28, 2024 23:10

wait...

@marc-hb
Copy link
Collaborator

marc-hb commented Jan 28, 2024

Wait: does the intermediate state with only one commit compiles? Without warning?

I'm all for smaller commits and smaller PRs but isn't this one step too far? Could hinder git bisect etc.

Added IS_ALIGNED macro to check if a pointer is aligned to
a given alignment. Additionally, removed a macro with a
conflicting name in drivers/crypto_intel.

Signed-off-by: Yonatan Schachter <[email protected]>
@aescolar aescolar added this to the v3.7.0 milestone Feb 6, 2024
@aescolar
Copy link
Member

aescolar commented Feb 6, 2024

Setting the milestone as 3.7 as we are past rc1 in 3.6. If you disagree with this please correct the milestone.

@aescolar aescolar merged commit 4ef0e12 into zephyrproject-rtos:main Feb 26, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Base OS Base OS Library (lib/os) area: Crypto / RNG
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants