From: Sascha Hauer <s.hauer@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2 1/2] scripts: define le32_to_cpup and friends for host/target tools
Date: Tue, 25 Mar 2025 08:22:01 +0100 [thread overview]
Message-ID: <Z-JZmexeu-CvQXU6@pengutronix.de> (raw)
In-Reply-To: <20250320052114.1732651-1-a.fatoum@pengutronix.de>
On Thu, Mar 20, 2025 at 06:21:13AM +0100, Ahmad Fatoum wrote:
> We already define le32_to_cpu and friends, but were missing so far the
> p-suffixed variant, which accepts a pointer.
>
> This is easily implemented with a bit of macro boilerplate, so let's do
> that.
>
> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
> ---
> v1 -> v2:
> - new patch
> ---
> scripts/compiler.h | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
This breaks compilation on riscv:
scripts/compiler.h:182:1: note: in expansion of macro 'DEFINE_CONV_P'
182 | DEFINE_CONV_P(be, 64)
| ^~~~~~~~~~~~~
scripts/compiler.h:170:55: error: unknown type name __be64'
170 | static inline u##bits cpu_to_##endian##bits##p(const __##endian##bits *p) \
| ^~
scripts/compiler.h:182:1: note: in expansion of macro 'DEFINE_CONV_P'
182 | DEFINE_CONV_P(be, 64)
| ^~~~~~~~~~~~~
I added a
#include <linux/types.h>
to scripts/compiler.h
Sascha
>
> diff --git a/scripts/compiler.h b/scripts/compiler.h
> index d8d0e1b906df..d6807b027e03 100644
> --- a/scripts/compiler.h
> +++ b/scripts/compiler.h
> @@ -160,6 +160,27 @@ typedef uint32_t __u32;
> # define be64_to_cpu(x) (x)
> #endif
>
> +#define DEFINE_CONV_P(endian, bits) \
> + static inline __##endian##bits endian##bits##_to_cpup(const u##bits *p) \
> + { \
> + u##bits val; \
> + memmove(&val, p, sizeof(val)); \
> + return endian##bits##_to_cpu(val); \
> + } \
> + static inline u##bits cpu_to_##endian##bits##p(const __##endian##bits *p) \
> + { \
> + __##endian##bits val; \
> + memmove(&val, p, sizeof(val)); \
> + return cpu_to_##endian##bits(val); \
> + }
> +
> +DEFINE_CONV_P(le, 16)
> +DEFINE_CONV_P(le, 32)
> +DEFINE_CONV_P(le, 64)
> +DEFINE_CONV_P(be, 16)
> +DEFINE_CONV_P(be, 32)
> +DEFINE_CONV_P(be, 64)
> +
> #ifndef min
> #define min(x, y) ({ \
> typeof(x) _min1 = (x); \
> --
> 2.39.5
>
>
>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
prev parent reply other threads:[~2025-03-25 7:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 5:21 Ahmad Fatoum
2025-03-20 5:21 ` [PATCH v2 2/2] booti: sanity check image magic before parsing header Ahmad Fatoum
2025-03-24 8:30 ` [PATCH v2 1/2] scripts: define le32_to_cpup and friends for host/target tools Sascha Hauer
2025-03-25 7:22 ` Sascha Hauer [this message]
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=Z-JZmexeu-CvQXU6@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=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