Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933889AbcDFI6T (ORCPT ); Wed, 6 Apr 2016 04:58:19 -0400 Received: from m50-132.163.com ([123.125.50.132]:56254 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933275AbcDFI6R (ORCPT ); Wed, 6 Apr 2016 04:58:17 -0400 From: zengzhaoxiu@163.com To: tony.luck@intel.com, fenghua.yu@intel.com Cc: linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, Zhaoxiu Zeng Subject: [PATCH v2 05/30] Add ia64-specific parity functions Date: Wed, 6 Apr 2016 16:57:37 +0800 Message-Id: <1459933057-6682-1-git-send-email-zengzhaoxiu@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <57031D9D.801@gmail.com> References: <57031D9D.801@gmail.com> X-CM-TRANSID: DNGowABHjv2CzwRXCryIAQ--.17301S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zr15Gw47ZrW5ZrW3Zw4xJFb_yoW8Gw15pF 1vkwn5trW8ta42kFy3CF1YqF4Sqrs7C3WxXrW3KrykJ3W7JF15Jr93u345Zr1jkrWv9ay3 ArW3JryDWan3AaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jAGYJUUUUU= X-Originating-IP: [112.95.225.98] X-CM-SenderInfo: p2hqw6xkdr5xrx6rljoofrz/xtbByghDgFO+iq4vWQAAs+ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1354 Lines: 52 From: Zhaoxiu Zeng Signed-off-by: Zhaoxiu Zeng --- arch/ia64/include/asm/bitops.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/ia64/include/asm/bitops.h b/arch/ia64/include/asm/bitops.h index 71e8145..041d1d6 100644 --- a/arch/ia64/include/asm/bitops.h +++ b/arch/ia64/include/asm/bitops.h @@ -439,6 +439,37 @@ 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; +} + +static __inline__ unsigned int __arch_parity32(unsigned int x) +{ + return __arch_parity64((unsigned long)x << 32); +} + +static __inline__ unsigned int __arch_parity16(unsigned int x) +{ + return __arch_parity64((unsigned long)x << 48); +} + +static __inline__ unsigned int __arch_parity8(unsigned int x) +{ + return __arch_parity64((unsigned long)x << 56); +} + +static __inline__ unsigned int __arch_parity4(unsigned int x) +{ + return __arch_parity64((unsigned long)x << 60); +} + +#include + #endif /* __KERNEL__ */ #include -- 2.5.0