From patchwork Sat Jan 28 10:52:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Helge Deller X-Patchwork-Id: 9543183 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDCA160415 for ; Sat, 28 Jan 2017 11:23:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9D7926E54 for ; Sat, 28 Jan 2017 11:23:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB1AD281C3; Sat, 28 Jan 2017 11:23:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36A4326E54 for ; Sat, 28 Jan 2017 11:23:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750837AbdA1LXx (ORCPT ); Sat, 28 Jan 2017 06:23:53 -0500 Received: from mout.gmx.net ([212.227.15.18]:50025 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750828AbdA1LXx (ORCPT ); Sat, 28 Jan 2017 06:23:53 -0500 Received: from ls3530.fritz.box ([92.203.22.148]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0LngRb-1c0HBO3frz-00hyye; Sat, 28 Jan 2017 11:52:10 +0100 Date: Sat, 28 Jan 2017 11:52:02 +0100 From: Helge Deller To: linux-parisc@vger.kernel.org, James Bottomley , John David Anglin Cc: Richard Henderson Subject: [PATCH] parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header Message-ID: <20170128105202.GA8664@ls3530.fritz.box> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) X-Provags-ID: V03:K0:0SxYWe/aEk9/jzHa1/j8/shU8Ml0uGn1a5CfmjdBf2NYorid8Up j66DVZqzqeS3QrbbbJX/tTAFf+SoyuHZDhkPJZKUCIDK0dNKZxmXgGBqZVFygNfsPnQ7mUK NvCxdr77JvREcqMtY9WHNyaDGMr1YPFWgoMMhkmxvbSo7ZjK3WkXs+4pfYysHmPpUNXxixt 8r640AFqe/l7RpphFk8eg== X-UI-Out-Filterresults: notjunk:1; V01:K0:88tADg4fvNk=:oECL+IPPo/kopZbwbFQ3fo 2lT7GBxh5RWT3iSPm8qwIwSfc24wZR3/erWCs4LZb12rAorSh69WBjY8Pb2zoQ2lHZipvhObh Ls+QgaSY+JJpAxjeCsjcH2xpwkdeJ+aRHDd4psdj7B04OHOz1/gBdTBMgNNQdXm5tPBIU6/ry +sCpp49JSr75GWiA9V4FTDeqPNBGjY5ymXe0J6BwuAcPasugRdEcSK2D+5vh7RtH4gLyAe0+d duAySDzPFLdXtUCsNgtrdeYuJTIq5Q4xaZUfn6+JTxnnK/B4EAsFAxhRKUjxx9gFF4pt2xpan 0Jla8IQt14eAZLM6/B7kvjkC39wCnUPWoglysvlQ+8VkE1D5gUWmEidM9oMIPqPexiALDBTOB Nepmj3j6KuDwMFY2jBAOl6TiTLaF2s8ZOUKdJhnq/3DtujRMUf6QCmJsGAV7mwChcUQol/Mi1 jHMnd8rEgijpg528KHQHOkJ2urS5NltU1MIsZU9Yy4hGwTHpGZCxoQy6Cry6/DJyVsiy04bLi bsxtNFfWzTKwytuvVKloP1QAqNExBf4+n7krG5xjSm+PRWobM8IJufSwGozX7jw+L5DzM6rVZ LmS1uGwo8AznVA6Wbuh5X8vqO3AdrFbXUFBmA9z1bPB51/yyJ7rLYQD4K13RSRMJwsQCAzOtt n6fxvZ5AA183vRNbAKSVYULwwlLfaT/nXYmftxlRVo8UrcsuxBhRa8hB7qYX3rnfvkOMw09s0 Lb7SBFD/7yxGfq4RoxNxcIAzorA75ePL5/PREURdvYU6+6eavHUghi3JqEk= Sender: linux-parisc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-parisc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In swab.h the "#if BITS_PER_LONG > 32" breaks compiling userspace programs if BITS_PER_LONG is #defined by userspace with the sizeof() compiler builtin. Solve this problem by using __BITS_PER_LONG instead. Since we now #include asm/bitsperlong.h avoid further potential userspace pollution by moving the #define of SHIFT_PER_LONG to bitops.h which is not exported to userspace. This patch unbreaks compiling qemu on hppa/parisc. Signed-off-by: Helge Deller Cc: --- To unsubscribe from this list: send the line "unsubscribe linux-parisc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/parisc/include/asm/bitops.h b/arch/parisc/include/asm/bitops.h index 3f9406d..da87943 100644 --- a/arch/parisc/include/asm/bitops.h +++ b/arch/parisc/include/asm/bitops.h @@ -6,7 +6,7 @@ #endif #include -#include /* for BITS_PER_LONG/SHIFT_PER_LONG */ +#include #include #include #include @@ -17,6 +17,12 @@ * to include/asm-i386/bitops.h or kerneldoc */ +#if __BITS_PER_LONG == 64 +#define SHIFT_PER_LONG 6 +#else +#define SHIFT_PER_LONG 5 +#endif + #define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1)) diff --git a/arch/parisc/include/uapi/asm/bitsperlong.h b/arch/parisc/include/uapi/asm/bitsperlong.h index e0a23c7..07fa7e5 100644 --- a/arch/parisc/include/uapi/asm/bitsperlong.h +++ b/arch/parisc/include/uapi/asm/bitsperlong.h @@ -3,10 +3,8 @@ #if defined(__LP64__) #define __BITS_PER_LONG 64 -#define SHIFT_PER_LONG 6 #else #define __BITS_PER_LONG 32 -#define SHIFT_PER_LONG 5 #endif #include diff --git a/arch/parisc/include/uapi/asm/swab.h b/arch/parisc/include/uapi/asm/swab.h index e78403b..928e1bb 100644 --- a/arch/parisc/include/uapi/asm/swab.h +++ b/arch/parisc/include/uapi/asm/swab.h @@ -1,6 +1,7 @@ #ifndef _PARISC_SWAB_H #define _PARISC_SWAB_H +#include #include #include @@ -38,7 +39,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x) } #define __arch_swab32 __arch_swab32 -#if BITS_PER_LONG > 32 +#if __BITS_PER_LONG > 32 /* ** From "PA-RISC 2.0 Architecture", HP Professional Books. ** See Appendix I page 8 , "Endian Byte Swapping". @@ -61,6 +62,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x) return x; } #define __arch_swab64 __arch_swab64 -#endif /* BITS_PER_LONG > 32 */ +#endif /* __BITS_PER_LONG > 32 */ #endif /* _PARISC_SWAB_H */