Skip to content

Commit

Permalink
toolchain: Add assembly-side counterpart of __aligned
Browse files Browse the repository at this point in the history
Zephyr toolchain abstraction provides a macro __aligned(x) to add specified
alignment, in bytes, to a chosen symbol for C/C++ source files but there is
no portable counterpart available for symbols defined in assembly source
files. This change-set adds a new macro BALIGN(x) for this purpose.

Signed-off-by: Irfan Ahmad <[email protected]>
  • Loading branch information
hIAhmad committed Feb 13, 2025
1 parent 0c368e8 commit 1d5070c
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions include/zephyr/toolchain/common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2010-2014 Wind River Systems, Inc.
* Copyright (c) 2025 Siemens AG
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -106,6 +107,37 @@

#endif /* _ASMLANGUAGE */

/*
* General directive for assembly code, to align the following symbol, in bytes.
*
* Example:
*
* BALIGN(4)
* test_symbol:
*
* 'test_symbol' will get aligned to 4 bytes.
*/

#ifdef _ASMLANGUAGE

#if defined(CONFIG_X86) || defined(CONFIG_ARM) || defined(CONFIG_ARM64) || \
defined(CONFIG_NIOS2) || defined(CONFIG_RISCV) || \
defined(CONFIG_XTENSA) || defined(CONFIG_MIPS)

#define BALIGN(x) .balign x

#elif defined(CONFIG_ARC) || defined(CONFIG_SPARC)

#define BALIGN(x) .align x

#else

#error Architecture unsupported

#endif

#endif /* _ASMLANGUAGE */

/* force inlining a function */

#if !defined(_ASMLANGUAGE)
Expand Down

0 comments on commit 1d5070c

Please sign in to comment.