Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753617AbcC0GAg (ORCPT ); Sun, 27 Mar 2016 02:00:36 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35192 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbcC0GA1 (ORCPT ); Sun, 27 Mar 2016 02:00:27 -0400 Subject: [PATCH 06/31] Add ia64-specific parity functions To: Tony Luck , Fenghua Yu References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, linux-ia64@vger.kernel.org From: "zhaoxiu.zeng" Message-ID: <56F776E2.4090609@gmail.com> Date: Sun, 27 Mar 2016 14:00:02 +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: 1161 Lines: 36 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- arch/ia64/include/asm/bitops.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h index 71e8145..de13d89 100644 --- a/arch/ia64/include/asm/bitops.h +++ b/arch/ia64/include/asm/bitops.h @@ -439,6 +439,22 @@ static __inline__ unsigned long __arch_hweight64(unsigned long x) #include +/* + * parityN: returns the parity of a N-bit word, + * i.e. the number of 1-bits in x modulo 2. + */ +static __inline__ unsigned int __arch_parity64(unsigned long x) +{ + return (unsigned int)ia64_popcnt(x) & 1; +} + +#define __arch_parity32(x) ((unsigned int) __arch_parity64((x) & 0xfffffffful)) +#define __arch_parity16(x) ((unsigned int) __arch_parity64((x) & 0xfffful)) +#define __arch_parity8(x) ((unsigned int) __arch_parity64((x) & 0xfful)) +#define __arch_parity4(x) ((unsigned int) __arch_parity64((x) & 0xful)) + +#include + #endif /* __KERNEL__ */ #include -- 2.5.5