From: Andy Lutomirski <luto@amacapital.net>
To: "H. Peter Anvin" <hpa@zytor.com>
Cc: Paul Gortmaker <paul.gortmaker@windriver.com>,
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:09:25 -0700 [thread overview]
Message-ID: <CALCETrVvR3SaYX7jvoX_q7m=HSzt1xvrDurrOpm2XT5SG3JVqw@mail.gmail.com> (raw)
In-Reply-To: <5388E3EF.6030700@zytor.com>
On Fri, May 30, 2014 at 1:02 PM, H. Peter Anvin <hpa@zytor.com> wrote:
> 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)
This will do awful things if x is a floating-point type, and, for
integers, the cast is probably unnecessary. But it should be okay.
>>
>> extern void bad_le(uint64_t);
If this ever goes in a common header, then we should do the
__attribute__((error)) thing. I wonder if it would ever make sense to
have __LINUX_HOSTPROG__ and make some of the basic headers work. Hmm.
>> #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?
My only real real objection is that _LE sounds like converting *to*
little-endian to me. Admittedly, that's the same thing on any
remotely sane architecture, but still.
--Andy
next prev parent reply other threads:[~2014-05-30 20:09 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-05 19:19 [PATCH v5 0/7] Clean up and unify the vDSO Andy Lutomirski
2014-05-05 19:19 ` [PATCH v5 1/7] x86,mm: Ensure correct alignment of the fixmap Andy Lutomirski
2014-05-05 22:24 ` [tip:x86/vdso] x86, mm: " tip-bot for Andy Lutomirski
2014-05-05 19:19 ` [PATCH v5 2/7] x86: Clean up 32-bit vs 64-bit vdso params Andy Lutomirski
2014-05-05 22:24 ` [tip:x86/vdso] x86, vdso: " tip-bot for Andy Lutomirski
2014-05-05 19:19 ` [PATCH v5 3/7] x86: Move syscall and sysenter setup into kernel/cpu/common.c Andy Lutomirski
2014-05-05 22:24 ` [tip:x86/vdso] x86, vdso: " tip-bot for Andy Lutomirski
2014-05-05 19:19 ` [PATCH v5 4/7] x86: Reimplement vdso.so preparation in build-time C Andy Lutomirski
2014-05-05 22:25 ` [tip:x86/vdso] x86, vdso: " tip-bot for Andy Lutomirski
2014-05-29 19:17 ` 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-31 3:09 ` [tip:x86/vdso] x86/vdso, build: " tip-bot for 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
2014-05-30 20:09 ` Andy Lutomirski [this message]
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-31 3:09 ` [tip:x86/vdso] x86/vdso, build: " tip-bot for Andy Lutomirski
2014-05-31 3:10 ` [tip:x86/vdso] x86/vdso, build: Make LE access macros clearer, host-safe tip-bot for H. Peter Anvin
2014-05-31 10:40 ` tip-bot for H. Peter Anvin
2014-05-29 19:43 ` [tip:x86/vdso] x86, vdso: Reimplement vdso.so preparation in build-time C Josh Boyer
2014-05-05 19:19 ` [PATCH v5 5/7] x86: Move the 32-bit vdso special pages after the text Andy Lutomirski
2014-05-05 22:25 ` [tip:x86/vdso] x86, vdso: " tip-bot for Andy Lutomirski
2014-05-05 19:19 ` [PATCH v5 6/7] x86: Move the vvar and hpet mappings next to the 64-bit vDSO Andy Lutomirski
2014-05-05 22:25 ` [tip:x86/vdso] x86, vdso: " tip-bot for Andy Lutomirski
2014-05-05 19:19 ` [PATCH v5 7/7] x86: Remove vestiges of VDSO_PRELINK and some outdated comments Andy Lutomirski
2014-05-05 22:25 ` [tip:x86/vdso] x86, vdso: " tip-bot for Andy Lutomirski
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='CALCETrVvR3SaYX7jvoX_q7m=HSzt1xvrDurrOpm2XT5SG3JVqw@mail.gmail.com' \
--to=luto@amacapital.net \
--cc=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=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).