Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752519AbcDFKYK (ORCPT ); Wed, 6 Apr 2016 06:24:10 -0400 Received: from m50-132.163.com ([123.125.50.132]:41668 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751165AbcDFKYI (ORCPT ); Wed, 6 Apr 2016 06:24:08 -0400 From: zengzhaoxiu@163.com To: ralf@linux-mips.org, Leonid.Yegoshin@imgtec.com, macro@linux-mips.org Cc: linux-mips@linux-mips.org, linux-kernel@vger.kernel.org, Zhaoxiu Zeng Subject: [PATCH v2 06/30] Add mips-specific parity functions Date: Wed, 6 Apr 2016 18:23:24 +0800 Message-Id: <1459938204-8761-1-git-send-email-zengzhaoxiu@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459933169-6749-1-git-send-email-zengzhaoxiu@163.com> References: <1459933169-6749-1-git-send-email-zengzhaoxiu@163.com> X-CM-TRANSID: DNGowABnnv2s4wRXdD+MAQ--.18711S2 X-Coremail-Antispam: 1Uf129KBjvJXoW7AF4xCw4UZFyrKr15JF43KFg_yoW8urWxpa 1kCrn5JrWvg34xAFWakFn2vF4ftrs5Wr1YqrWa9ryvyFy3tF1UJrnagw1DAr18KF409F48 urZxGF1DWwsFvFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07jVUDAUUUUU= X-Originating-IP: [112.95.225.98] X-CM-SenderInfo: p2hqw6xkdr5xrx6rljoofrz/xtbBDRFDgFaDmOfV0wAAsz Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1976 Lines: 77 From: Zhaoxiu Zeng Lifted from arch_hweight.h Signed-off-by: Zhaoxiu Zeng --- arch/mips/include/asm/arch_parity.h | 43 +++++++++++++++++++++++++++++++++++++ arch/mips/include/asm/bitops.h | 3 +++ 2 files changed, 46 insertions(+) create mode 100644 arch/mips/include/asm/arch_parity.h diff --git a/arch/mips/include/asm/arch_parity.h b/arch/mips/include/asm/arch_parity.h new file mode 100644 index 0000000..23b3c23 --- /dev/null +++ b/arch/mips/include/asm/arch_parity.h @@ -0,0 +1,44 @@ +/* + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file "COPYING" in the main directory of this archive + * for more details. + * + */ +#ifndef _ASM_ARCH_PARITY_H +#define _ASM_ARCH_PARITY_H + +#ifdef ARCH_HAS_USABLE_BUILTIN_POPCOUNT + +#include + +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; +} + +#else +#include +#endif + +#endif /* _ASM_ARCH_PARITY_H */ diff --git a/arch/mips/include/asm/bitops.h b/arch/mips/include/asm/bitops.h index ce9666c..0b87734 100644 --- a/arch/mips/include/asm/bitops.h +++ b/arch/mips/include/asm/bitops.h @@ -626,6 +626,9 @@ static inline int ffs(int word) #include #include +#include +#include + #include #include -- 2.5.0