mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] include: move STACK_ALIGN_ARRAY to linux/align.h
Date: Sat, 24 Aug 2024 22:02:14 +0200	[thread overview]
Message-ID: <20240824200214.2159827-1-a.fatoum@pengutronix.de> (raw)

As part of the measures to factor out stuff from common.h into dedicated
headers, move out STACK_ALIGN_ARRAY. This macro doesn't exit in Linux,
but the file is fitting.

We don't need to explicitly include it, because it's being included by
<linux/kernel.h>.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 include/common.h      | 12 ------------
 include/linux/align.h | 11 +++++++++++
 2 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/include/common.h b/include/common.h
index fb8931c51eb9..571f46fd0bc1 100644
--- a/include/common.h
+++ b/include/common.h
@@ -95,18 +95,6 @@ enum autoboot_state do_autoboot_countdown(void);
 
 void __noreturn start_barebox(void);
 void shutdown_barebox(void);
-
-/*
- * The STACK_ALIGN_ARRAY macro is used to allocate a buffer on the stack that
- * meets a minimum alignment requirement.
- *
- * Note that the size parameter is the number of array elements to allocate,
- * not the number of bytes.
- */
-#define STACK_ALIGN_ARRAY(type, name, size, align)		\
-	char __##name[sizeof(type) * (size) + (align) - 1];	\
-	type *name = (type *)ALIGN((uintptr_t)__##name, align)
-
 int mem_parse_options(int argc, char *argv[], char *optstr, int *mode,
 		char **sourcefile, char **destfile, int *swab);
 int memcpy_parse_options(int argc, char *argv[], int *sourcefd,
diff --git a/include/linux/align.h b/include/linux/align.h
index 8df1b3dcd749..4b373bf73d5b 100644
--- a/include/linux/align.h
+++ b/include/linux/align.h
@@ -10,4 +10,15 @@
 #define PTR_IS_ALIGNED(x, a)	IS_ALIGNED((unsigned long)(x), (a))
 #define IS_ALIGNED(x, a)		(((x) & ((typeof(x))(a) - 1)) == 0)
 
+/*
+ * The STACK_ALIGN_ARRAY macro is used to allocate a buffer on the stack that
+ * meets a minimum alignment requirement.
+ *
+ * Note that the size parameter is the number of array elements to allocate,
+ * not the number of bytes.
+ */
+#define STACK_ALIGN_ARRAY(type, name, size, align)		\
+	char __##name[sizeof(type) * (size) + (align) - 1];	\
+	type *name = (type *)ALIGN((unsigned long)__##name, align)
+
 #endif
-- 
2.39.2




             reply	other threads:[~2024-08-24 20:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-24 20:02 Ahmad Fatoum [this message]
2024-08-26 11:07 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240824200214.2159827-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox