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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/include/sof/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,14 @@
/* callers must check/use the return value */
#define __must_check __attribute__((warn_unused_result))

#ifdef __ZEPHYR__
#include <zephyr/sys/util.h>
#endif

/* 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

#define IS_ALIGNED(size, alignment) ((size) % (alignment) == 0)
#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.


/* Treat zero as a special case because it wraps around */
#define is_power_of_2(x) ((x) && !((x) & ((x) - 1)))
Expand Down