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

common.h: Guard definition of IS_ALIGNED for Zephyr builds #8708

Merged
merged 1 commit into from
Jan 16, 2024

Conversation

yonsch
Copy link
Contributor

@yonsch yonsch commented Jan 7, 2024

common.h defines the IS_ALIGNED macro, which conflicts with a Zephyr macro of the same name. Add guards to define it only if it is not already defined by Zephyr.

@sofci
Copy link
Collaborator

sofci commented Jan 7, 2024

Can one of the admins verify this patch?

reply test this please to run this test once

Copy link
Contributor

@btian1 btian1 left a comment

Choose a reason for hiding this comment

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

There is another place in Zephyr also defined this in zephyr code, could you change zephyr code as well?
https://github.com/zephyrproject-rtos/zephyr/blob/main/drivers/crypto/crypto_intel_sha_priv.h#L33

Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Thanks @yonsch !

#define IS_ALIGNED(size, alignment) ((size) % (alignment) == 0)
#else
#include <zephyr/sys/util.h>
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is referring to zephyrproject-rtos/zephyr#67243 which isn't merged yet, right? So if we merge this first this will break Zephyr builds? This cannot be merged like this. A simple solution would be to use #ifnder IS_ALIGNED as a guard.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@lyakh SOF CI agrees with you, most builds are failing. So yeah, this would need ifdef on IS_ALIGNED definition or a ifdef check on Zephyr version. @yonsch the SOF CI builds against both a fixed version of Zephyr and latest "main" of Zephyr upstream.

Copy link
Member

Choose a reason for hiding this comment

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

Long term we move this and other common Zephyr re-definitions to the xtos header directory for remaining xtos users and pull this directly from Zephyr.

common.h defines the IS_ALIGNED macro, which conflicts with
a Zephyr macro of the same name. Add guards to define it only
if it is not already defined by Zephyr.

Signed-off-by: Yonatan Schachter <[email protected]>
@yonsch yonsch force-pushed the zephyr_is_aligned branch from 1d46d59 to 514020f Compare January 11, 2024 18:10
@kv2019i kv2019i requested a review from lyakh January 12, 2024 07:54
Copy link
Collaborator

@kv2019i kv2019i left a comment

Choose a reason for hiding this comment

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

Refresh +1 , thanks @yonsch !

@lyakh can you check again?

@lgirdwood
Copy link
Member

Looks like some CI has timed out - restart CI.

@lgirdwood
Copy link
Member

SOFCI TEST

@kv2019i
Copy link
Collaborator

kv2019i commented Jan 15, 2024

@wszypelt This PR seems to have got stuck in quickbuild, can you check.
For other results, the one fail in https://sof-ci.01.org/sofpr/PR8708/build1825/devicetest/index.html can be ignored.

@kv2019i kv2019i merged commit 0a3b816 into thesofproject:main Jan 16, 2024
43 of 44 checks passed
/* Align the number to the nearest alignment value */
#ifndef IS_ALIGNED
Copy link
Collaborator

Choose a reason for hiding this comment

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

Except for "extreme" cases, #ifndef is always best avoided because it makes the usual, horrible macro experience even worse. Zephyr forbids it: https://docs.zephyrproject.org/latest/contribute/coding_guidelines/index.html#rule-a-3-macro-name-collisions

As requested in zephyrproject-rtos/zephyr#67243 (comment), please rename this SOF_ALIGN() and make everything simpler: backwards and forwards compatibility and trannsitions

Copy link
Collaborator

Choose a reason for hiding this comment

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

@marc-hb Can you do a follow-up on SOF side. This is sufficient for now to unblock the integration of Zephyr side IS_ALIGNED. SOF can move to other naming on its own pace.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you do a follow-up on SOF side.

Submitted in #8755

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.

7 participants