mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] include: move STACK_ALIGN_ARRAY to linux/align.h
@ 2024-08-24 20:02 Ahmad Fatoum
  2024-08-26 11:07 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-08-24 20:02 UTC (permalink / raw)
  To: barebox; +Cc: Ahmad Fatoum

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




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] include: move STACK_ALIGN_ARRAY to linux/align.h
  2024-08-24 20:02 [PATCH] include: move STACK_ALIGN_ARRAY to linux/align.h Ahmad Fatoum
@ 2024-08-26 11:07 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2024-08-26 11:07 UTC (permalink / raw)
  To: barebox, Ahmad Fatoum


On Sat, 24 Aug 2024 22:02:14 +0200, Ahmad Fatoum wrote:
> 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>.
> 
> [...]

Applied, thanks!

[1/1] include: move STACK_ALIGN_ARRAY to linux/align.h
      https://git.pengutronix.de/cgit/barebox/commit/?id=74fe1ce29bcf (link may not be stable)

Best regards,
-- 
Sascha Hauer <s.hauer@pengutronix.de>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-26 11:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-24 20:02 [PATCH] include: move STACK_ALIGN_ARRAY to linux/align.h Ahmad Fatoum
2024-08-26 11:07 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox