Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754710AbcC0Gq0 (ORCPT ); Sun, 27 Mar 2016 02:46:26 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:36249 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752765AbcC0GqU (ORCPT ); Sun, 27 Mar 2016 02:46:20 -0400 Subject: [PATCH 11/31] Add x86-specific parity functions References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> Cc: linux-kernel@vger.kernel.org, x86@kernel.org To: Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Denys Vlasenko From: "zhaoxiu.zeng" Message-ID: <56F7819E.5020502@gmail.com> Date: Sun, 27 Mar 2016 14:45:50 +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: 1040 Lines: 32 From: Zeng Zhaoxiu Signed-off-by: Zeng Zhaoxiu --- arch/x86/include/asm/bitops.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index 7766d1c..d3210c0 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -501,6 +501,18 @@ static __always_inline int fls64(__u64 x) #include +#define __arch_parity32(x) (__arch_hweight32(x) & 1) +#define __arch_parity4(x) (__arch_parity32((x) & 0xf)) +#define __arch_parity8(x) (__arch_parity32((x) & 0xff)) +#define __arch_parity16(x) (__arch_parity32((x) & 0xffff)) +#ifdef CONFIG_X86_32 +#define __arch_parity64(x) (__arch_parity32((unsigned int)((x) >> 32) ^ (unsigned int)(x))) +#else +#define __arch_parity64(x) (__arch_hweight64(x) & 1) +#endif + +#include + #include #include -- 2.5.5