From mboxrd@z Thu Jan 1 00:00:00 1970 From: "H. Peter Anvin" Subject: Re: [PATCH v2 2/2] x86,vdso: Fix cross-compilation from big-endian architectures Date: Fri, 30 May 2014 13:21:14 -0700 Message-ID: <5388E83A.5000500@zytor.com> References: <2cf258df123cb24bad63c274c8563c050547d99d.1401464755.git.luto@amacapital.net> <5388E3EF.6030700@zytor.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: Received: from terminus.zytor.com ([198.137.202.10]:47666 "EHLO mail.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933360AbaE3UV1 (ORCPT ); Fri, 30 May 2014 16:21:27 -0400 In-Reply-To: Sender: linux-next-owner@vger.kernel.org List-ID: To: Andy Lutomirski Cc: Paul Gortmaker , Josh Boyer , Ingo Molnar , LKML , "tglx@linutronix.de" , "linux-tip-commits@vger.kernel.org" , "linux-next@vger.kernel.org" On 05/30/2014 01:09 PM, Andy Lutomirski wrote: >> >> 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. > I mostly wanted to preserve the signedness. Yes, if we care about floating-point it gets trickier. At some point hopefully there will be a native C feature to handle this crap. >>> 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. GET_LE() then? -hpa