From patchwork Fri Oct 16 06:38:40 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: 7411121 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 44C1D9F302 for ; Fri, 16 Oct 2015 06:41:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 64D4B20692 for ; Fri, 16 Oct 2015 06:41:02 +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 45AAC20649 for ; Fri, 16 Oct 2015 06:41:01 +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 1Zmyfb-0000uY-82; Fri, 16 Oct 2015 06:39:15 +0000 Received: from mo6-p00-ob.smtp.rzone.de ([2a01:238:20a:202:5300::2]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZmyfY-0000bL-4F for linux-arm-kernel@lists.infradead.org; Fri, 16 Oct 2015 06:39:12 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1444977527; l=1960; s=domk; d=goldelico.com; h=Date:Subject:Cc:To:From; bh=ySpUTuyg+Br9PW8WoWuKe4fqjp6z+g4Utq6p7fEboJY=; b=rOzNMONTtazTueFtNo0k3E7O4QPhkjvdL5RPx96BHmuBEsGmiJNFQSGiSD5OcQDC02N A6uG1iDtoN4CQahDV9NV/ud0audTallLNUb8o/m5nj/lrYAPB+H1gomHUPNv4T5AKYE05 DE5p6G5wi419mZ+h9ggUD6QLoD9G+i8/Ugg= X-RZG-AUTH: :JGIXVUS7cutRB/49FwqZ7WcecEarQROEYabkiUo6mSAGQ+qKIDwwPBEJ2Mw= X-RZG-CLASS-ID: mo00 Received: from localhost.localdomain (p57AE1A69.dip0.t-ipconnect.de [87.174.26.105]) by smtp.strato.de (RZmta 37.14 DYNA|AUTH) with ESMTPA id 201d7fr9G6cfV1y; Fri, 16 Oct 2015 08:38:41 +0200 (CEST) From: "H. Nikolaus Schaller" To: Szabolcs Nagy , Russell King , Nathan Lynch , Will Deacon Subject: [PATCH v4] ARM: fix vdsomunge not to depend on glibc specific byteswap.h Date: Fri, 16 Oct 2015 08:38:40 +0200 Message-Id: <4436b0dbf72aa409613ec4c7407b017d085e40ac.1444977518.git.hns@goldelico.com> X-Mailer: git-send-email 2.5.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151015_233912_343412_E4EB26C7 X-CRM114-Status: GOOD ( 10.71 ) 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: "H. Nikolaus Schaller" , marek@goldelico.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 and kindly improved by Russell King) Tested to compile on Mac OS X 10.9.5 host. Signed-off-by: H. Nikolaus Schaller --- arch/arm/vdso/vdsomunge.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/arch/arm/vdso/vdsomunge.c b/arch/arm/vdso/vdsomunge.c index aedec81..0cebd98 100644 --- a/arch/arm/vdso/vdsomunge.c +++ b/arch/arm/vdso/vdsomunge.c @@ -45,7 +45,6 @@ * it does. */ -#include #include #include #include @@ -59,6 +58,16 @@ #include #include +#define swab16(x) \ + ((((x) & 0x00ff) << 8) | \ + (((x) & 0xff00) >> 8)) + +#define swab32(x) \ + ((((x) & 0x000000ff) << 24) | \ + (((x) & 0x0000ff00) << 8) | \ + (((x) & 0x00ff0000) >> 8) | \ + (((x) & 0xff000000) << 24)) + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ #define HOST_ORDER ELFDATA2LSB #elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ @@ -104,17 +113,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)