From 552606651c20b8fb34c398d4174a4b6cc617886a Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Tue, 9 Nov 2021 23:27:05 -0800 Subject: [PATCH] [lib][console] include stdalign.h and use alignof/alignas Instead of manually calling out the alignment to a void *, use alignas to the real type. --- lib/console/include/lib/console/cmd.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/console/include/lib/console/cmd.h b/lib/console/include/lib/console/cmd.h index 20ae40d0..6489763f 100644 --- a/lib/console/include/lib/console/cmd.h +++ b/lib/console/include/lib/console/cmd.h @@ -9,14 +9,17 @@ #include #include +#include #include #include __BEGIN_CDECLS -/* included from top level lk/console_cmd.h when lib/console is built. +/* Included from top level lk/console_cmd.h when lib/console is built. * Provides definitions for how to register a command block to be picked up by * the lib/console machinery. + * + * Do not include directly. */ /* an individual command */ @@ -36,15 +39,15 @@ typedef struct _cmd_block { #define STATIC_COMMAND_START static const console_cmd _cmd_list[] = { -#define STATIC_COMMAND_END(name) }; const console_cmd_block _cmd_block_##name \ - __ALIGNED(sizeof(void *)) __SECTION("commands") = \ +#define STATIC_COMMAND_END(name) }; alignas(console_cmd_block) const console_cmd_block _cmd_block_##name \ + __SECTION("commands") = \ { #name, sizeof(_cmd_list) / sizeof(_cmd_list[0]), _cmd_list } /* same as above but with a suffixed name to make the list unique within the file */ #define STATIC_COMMAND_START_NAMED(name) static const console_cmd _cmd_list_##name[] = { -#define STATIC_COMMAND_END_NAMED(name) }; const console_cmd_block _cmd_block_##name \ - __ALIGNED(sizeof(void *)) __SECTION("commands") = \ +#define STATIC_COMMAND_END_NAMED(name) }; alignas(console_cmd_block) const console_cmd_block _cmd_block_##name \ + __SECTION("commands") = \ { #name, sizeof(_cmd_list_##name) / sizeof(_cmd_list_##name[0]), _cmd_list_##name } #define STATIC_COMMAND(command_str, help_str, func) \