Skip to content

Commit

Permalink
scripts: build: gen_handles: use Z_DECL_ALIGN
Browse files Browse the repository at this point in the history
Instead of hardcoding alignment size for pass 2 device handles, use
Z_DECL_ALIGN. This makes sure gen_handles.py is always in sync with the
type defined in device.h. The build assert in device.h can be removed as
a result, since we do not hardcode handles size anywhere else.

Signed-off-by: Gerard Marull-Paretas <[email protected]>
  • Loading branch information
gmarull authored and carlescufi committed Oct 11, 2022
1 parent a6a4400 commit 8821623
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
7 changes: 0 additions & 7 deletions include/zephyr/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@ extern "C" {
*/
typedef int16_t device_handle_t;

/*
* The build assert will fail if device_handle_t changes size, which
* means the alignment directives in the linker scripts and in
* `gen_handles.py` must be updated.
*/
BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts");

/** @brief Flag value used in lists of device handles to separate
* distinct groups.
*
Expand Down
2 changes: 1 addition & 1 deletion scripts/build/gen_handles.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def c_handle_array(dev, handles, extra_support_handles=0):
'DEVICE_HANDLE_ENDS',
]
return [
'const device_handle_t __aligned(2) __attribute__((__section__(".__device_handles_pass2")))',
'const Z_DECL_ALIGN(device_handle_t) __attribute__((__section__(".__device_handles_pass2")))',
'{:s}[] = {{ {:s} }};'.format(dev.ordinals.sym.name, ', '.join(handles)),
]

Expand Down

0 comments on commit 8821623

Please sign in to comment.