From patchwork Sat Oct 3 20:46:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "H. Nikolaus Schaller" X-Patchwork-Id: 7322551 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 37088BEEA4 for ; Sat, 3 Oct 2015 20:49:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 30B3420711 for ; Sat, 3 Oct 2015 20:49:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 402E72070B for ; Sat, 3 Oct 2015 20:49:56 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZiTiO-00037Y-KL; Sat, 03 Oct 2015 20:47:32 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::6]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZiTiL-00033E-Px for linux-arm-kernel@lists.infradead.org; Sat, 03 Oct 2015 20:47:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1443905224; l=1977; s=domk; d=goldelico.com; h=To:References:Content-Transfer-Encoding:Cc:Date:In-Reply-To:From: Content-Type:Mime-Version:Subject; bh=VtDlKhIEJlhEnL0AvvjNt4U+5wE1WsXtxFalGQFYD1w=; b=rr3igwgGitnN1HWHLOMGnZtsQZWdKaz6qitVO9yclSO6ajaSOhbHd0nSbrpzm3K6bcB gKAjGzg8NvQPhee4nxrseMTBFm1T+v/OxNHxBBuiQVXYelgyiDjnI+T1kWomc1KNBxOYa gK1GI48XptvkvParb8Ba9kB1mIguZOVH9y8= X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcKdUCnXG6JabOfSXKWrat8m8zozo0= X-RZG-CLASS-ID: mo00 Received: from [192.168.2.104] (p57AE00A4.dip0.t-ipconnect.de [87.174.0.164]) by post.strato.de (RZmta 37.12 DYNA|AUTH) with ESMTPA id K039f1r93KksCIJ; Sat, 3 Oct 2015 22:46:54 +0200 (CEST) Subject: [PATCH v2] ARM: fix vdsomunge not to depend on glibc specific byteswap.h Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) From: "H. Nikolaus Schaller" In-Reply-To: <2039A9BE-ADA4-4D28-84F4-C8B9D76834AD@goldelico.com> Date: Sat, 3 Oct 2015 22:46:44 +0200 Message-Id: References: <2039A9BE-ADA4-4D28-84F4-C8B9D76834AD@goldelico.com> To: Szabolcs Nagy , Russell King , Nathan Lynch , Will Deacon X-Mailer: Apple Mail (2.1878.6) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151003_134730_189924_1FDD756E X-CRM114-Status: GOOD ( 11.58 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: marek@goldelico.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the host toolchain is not glibc based then the arm kernel build fails with HOSTCC arch/arm/vdso/vdsomunge arch/arm/vdso/vdsomunge.c:48:22: fatal error: byteswap.h: No such file or directory Observed: with omap2plus_defconfig and compile on Mac OS X with arm ELF cross-compiler. Reason: byteswap.h is a glibc only header. Solution: replace by private byte-swapping macros (taken from arch/mips/boot/elf2ecoff.c) Tested to compile on Mac OS X 10.9.5 host. Signed-off-by: H. Nikolaus Schaller --- arch/arm/vdso/vdsomunge.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/arm/vdso/vdsomunge.c b/arch/arm/vdso/vdsomunge.c index aedec81..27a9a0b 100644 --- a/arch/arm/vdso/vdsomunge.c +++ b/arch/arm/vdso/vdsomunge.c @@ -45,7 +45,18 @@ * it does. */ -#include +#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) )) + #include #include #include @@ -104,17 +115,17 @@ static void cleanup(void) static Elf32_Word read_elf_word(Elf32_Word word, bool swap) { - return swap ? bswap_32(word) : word; + return swap ? swab32(word) : word; } static Elf32_Half read_elf_half(Elf32_Half half, bool swap) { - return swap ? bswap_16(half) : half; + return swap ? swab16(half) : half; } static void write_elf_word(Elf32_Word val, Elf32_Word *dst, bool swap) { - *dst = swap ? bswap_32(val) : val; + *dst = swap ? swab32(val) : val; } int main(int argc, char **argv)