From: "H. Peter Anvin" <hpa@zytor.com>
To: Andy Lutomirski <luto@amacapital.net>,
Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Josh Boyer <jwboyer@fedoraproject.org>,
Ingo Molnar <mingo@kernel.org>,
LKML <linux-kernel@vger.kernel.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"linux-tip-commits@vger.kernel.org"
<linux-tip-commits@vger.kernel.org>,
"linux-next@vger.kernel.org" <linux-next@vger.kernel.org>
Subject: Re: [PATCH v2 2/2] x86,vdso: Fix cross-compilation from big-endian architectures
Date: Fri, 30 May 2014 13:02:55 -0700 [thread overview]
Message-ID: <5388E3EF.6030700@zytor.com> (raw)
In-Reply-To: <2cf258df123cb24bad63c274c8563c050547d99d.1401464755.git.luto@amacapital.net>
On 05/30/2014 08:48 AM, Andy Lutomirski wrote:
> This adds a macro GET(x) to convert x from big-endian to
> little-endian. Hopefully I put it everywhere it needs to go and got
> all the cases needed for everyone's linux/elf.h.
>
> Signed-off-by: Andy Lutomirski <luto@amacapital.net>
> ---
> arch/x86/vdso/vdso2c.c | 15 ++++++++++++
> arch/x86/vdso/vdso2c.h | 63 ++++++++++++++++++++++++++++----------------------
> 2 files changed, 50 insertions(+), 28 deletions(-)
A couple of observations:
1. We shouldn't use double-underscore in host C code.
2. It would be nice if we can take these sort of things (host-build
helper macros) and move them to some common file in the Linux kernel
eventually, so it would be a good thing to make the naming a little
less general.
3. Even though it isn't necessary, making it work on 8-bit values so
one doesn't have to worry about the type would seem like a good
thing.
I came up with the following, it seems like a reasonable simplification:
> #define _LE(x, bits, ifnot) \
> __builtin_choose_expr( \
> (sizeof(x) == bits/8), \
> (__typeof__(x))le##bits##toh(x), ifnot)
>
> extern void bad_le(uint64_t);
> #define _LAST_LE(x) \
> __builtin_choose_expr(sizeof(x) == 1, (x), bad_le(x))
>
> #define LE(x) \
> _LE(x, 64, _LE(x, 32, _LE(x, 16, _LAST_LE(x))))
What do you think?
-hpa
next prev parent reply other threads:[~2014-05-30 20:03 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2c4fcf45524162a34d87fdda1eb046b2a5cecee7.1399317206.git.luto@amacapital.net>
[not found] ` <tip-6f121e548f83674ab4920a4e60afb58d4f61b829@git.kernel.org>
2014-05-29 19:17 ` [tip:x86/vdso] x86, vdso: Reimplement vdso.so preparation in build-time C Paul Gortmaker
2014-05-29 19:32 ` Andy Lutomirski
2014-05-29 19:43 ` H. Peter Anvin
2014-05-29 19:46 ` Andy Lutomirski
2014-05-29 21:57 ` [PATCH 0/2] x86,vdso: vdso build fixes and improvements Andy Lutomirski
2014-05-29 21:57 ` [PATCH 1/2] x86,vdso: When vdso2c fails, unlink the output Andy Lutomirski
2014-05-29 21:57 ` [PATCH 2/2] x86,vdso: Fix cross-compilation from big-endian architectures Andy Lutomirski
2014-05-29 22:41 ` [PATCH 0/2] x86,vdso: vdso build fixes and improvements Paul Gortmaker
2014-05-29 22:49 ` Andy Lutomirski
2014-05-30 5:42 ` Stephen Rothwell
2014-05-30 15:40 ` Andy Lutomirski
2014-05-30 15:48 ` [PATCH v2 " Andy Lutomirski
2014-05-30 15:48 ` [PATCH v2 1/2] x86,vdso: When vdso2c fails, unlink the output Andy Lutomirski
2014-05-30 15:48 ` [PATCH v2 2/2] x86,vdso: Fix cross-compilation from big-endian architectures Andy Lutomirski
2014-05-30 20:02 ` H. Peter Anvin [this message]
2014-05-30 20:09 ` Andy Lutomirski
2014-05-30 20:21 ` H. Peter Anvin
2014-05-30 20:34 ` Andy Lutomirski
2014-05-31 0:14 ` H. Peter Anvin
2014-05-29 19:43 ` [tip:x86/vdso] x86, vdso: Reimplement vdso.so preparation in build-time C Josh Boyer
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=5388E3EF.6030700@zytor.com \
--to=hpa@zytor.com \
--cc=jwboyer@fedoraproject.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=paul.gortmaker@windriver.com \
--cc=tglx@linutronix.de \
/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;
as well as URLs for NNTP newsgroup(s).