Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754587AbcC0GLV (ORCPT ); Sun, 27 Mar 2016 02:11:21 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:33316 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752280AbcC0GLO (ORCPT ); Sun, 27 Mar 2016 02:11:14 -0400 Subject: [PATCH 08/31] Add tile-specific parity functions To: Chris Metcalf References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org From: "zhaoxiu.zeng" Message-ID: <56F77959.1010609@gmail.com> Date: Sun, 27 Mar 2016 14:10:33 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.1 MIME-Version: 1.0 In-Reply-To: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Content-Type: text/plain; charset=gbk Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1380 Lines: 50 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- arch/tile/include/asm/bitops.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/tile/include/asm/bitops.h b/arch/tile/include/asm/bitops.h index 20caa34..370d007 100644 --- a/arch/tile/include/asm/bitops.h +++ b/arch/tile/include/asm/bitops.h @@ -81,10 +81,36 @@ static inline unsigned long __arch_hweight64(__u64 w) return __builtin_popcountll(w); } +static inline unsigned int __arch_parity32(unsigned int w) +{ + return __builtin_popcount(w) & 1; +} + +static inline unsigned int __arch_parity16(unsigned int w) +{ + return __arch_parity32(w & 0xffff); +} + +static inline unsigned int __arch_parity8(unsigned int w) +{ + return __arch_parity32(w & 0xff); +} + +static inline unsigned int __arch_parity4(unsigned int w) +{ + return __arch_parity32(w & 0xf); +} + +static inline unsigned int __arch_parity64(__u64 w) +{ + return (unsigned int)__builtin_popcountll(w) & 1; +} + #include #include #include #include +#include #include #include #include -- 2.5.5