From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754008AbbJOQwi (ORCPT ); Thu, 15 Oct 2015 12:52:38 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.216]:47552 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753992AbbJOQwh convert rfc822-to-8bit (ORCPT ); Thu, 15 Oct 2015 12:52:37 -0400 X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcKdUCnXG6JabOfSXKWrat/m8zrzY0= X-RZG-CLASS-ID: mo00 Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) Subject: Re: [PATCH v2] ARM: fix vdsomunge not to depend on glibc specific byteswap.h From: "H. Nikolaus Schaller" In-Reply-To: <20151015163712.GD32532@n2100.arm.linux.org.uk> Date: Thu, 15 Oct 2015 18:52:29 +0200 Cc: Nathan Lynch , Szabolcs Nagy , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, marek@goldelico.com Content-Transfer-Encoding: 8BIT Message-Id: <2EC080E4-B31C-46F5-8239-FF96493DA861@goldelico.com> References: <2039A9BE-ADA4-4D28-84F4-C8B9D76834AD@goldelico.com> <5B19AAFC-976C-4B33-A83E-229693FA7858@goldelico.com> <561E63C9.3040702@mentor.com> <350DE2A3-622F-4624-8AFC-D0F37CCB29EA@goldelico.com> <20151015163712.GD32532@n2100.arm.linux.org.uk> To: Russell King - ARM Linux X-Mailer: Apple Mail (2.1878.6) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 15.10.2015 um 18:37 schrieb Russell King - ARM Linux : > On Thu, Oct 15, 2015 at 07:52:38AM +0200, H. Nikolaus Schaller wrote: >> ERROR: space prohibited before that close parenthesis ')' >> #46: FILE: arch/arm/vdso/vdsomunge.c:64: >> + (((unsigned short)(x) & (unsigned short)0xff00U) >> 8) )) > > I have a pet hatred of too many parens. I also have a hatred of idiotic > casts. What about changing the above to one of: > > (((x) & 0xff00) >> 8) > (((x) >> 8) & 0xff) > >> >> ERROR: space prohibited before that close parenthesis ')' >> #53: FILE: arch/arm/vdso/vdsomunge.c:71: >> + (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24) )) > > and one of: > > (((x) & 0xff000000) >> 24) > (((x) >> 24) & 0xff) > > ? Well, the semantics is sometimes the same but I think readability goes down because the macro becomes quite un-symmetric and for >> 8 you should better be sure that values are unsigned if combining with | operator. Of course it is questionable why the constants (with U and UL modifiers) are casted. The full macro (as copied verbatim from existing arch/mips/boot/elf2ecoff.c) is: +#define swab16(x) \ + ((unsigned short)( \ + (((unsigned short)(x) & (unsigned short)0x00ffU) << 8) | \ + (((unsigned short)(x) & (unsigned short)0xff00U) >> 8))) + +#define swab32(x) \ + ((unsigned int)( \ + (((unsigned int)(x) & (unsigned int)0x000000ffUL) << 24) | \ + (((unsigned int)(x) & (unsigned int)0x0000ff00UL) << 8) | \ + (((unsigned int)(x) & (unsigned int)0x00ff0000UL) >> 8) | \ + (((unsigned int)(x) & (unsigned int)0xff000000UL) >> 24))) + I have already submitted a V3 of this patch, so please comment that. A question is why this is not generally available for all HOSTCC based tools so that we could simply include some header. But since that is no kernel code but a tool, I think it is not really necessary to put significant efforts into this piece of code. This was probably the intention of the original code to simply include byteswap.h - then you don't even see how complex the macros are - but it is not a standard header. BR and thanks, Nikolaus Schaller