Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754464AbcC1FoU (ORCPT ); Mon, 28 Mar 2016 01:44:20 -0400 Received: from mail-ig0-f195.google.com ([209.85.213.195]:33151 "EHLO mail-ig0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752140AbcC1FoK (ORCPT ); Mon, 28 Mar 2016 01:44:10 -0400 Subject: Re: [PATCH 10/31] Add sparc-specific parity functions To: David Miller References: <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com> <56F780FE.7000600@gmail.com> <20160327.224308.220596078048860811.davem@davemloft.net> Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org From: Zeng Zhaoxiu Message-ID: <56F8C4A3.1070808@gmail.com> Date: Mon, 28 Mar 2016 13:44:03 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160327.224308.220596078048860811.davem@davemloft.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 740 Lines: 20 在 2016年03月28日 10:43, David Miller 写道: > From: "zhaoxiu.zeng" > Date: Sun, 27 Mar 2016 14:43:10 +0800 > >> + >> +/* >> + * parityN: returns the parity of a N-bit word, >> + * i.e. the number of 1-bits in x modulo 2. >> + */ >> + >> +#define __arch_parity4(w) (__arch_hweight8((w) & 0xf) & 1) >> +#define __arch_parity8(w) (__arch_hweight8(w) & 1) >> +#define __arch_parity16(w) (__arch_hweight16(w) & 1) >> +#define __arch_parity32(w) (__arch_hweight32(w) & 1) >> +#define __arch_parity64(w) ((unsigned int)__arch_hweight64(w) & 1) > This looks like asm-generic/ material to me. This is generic for the architectures which have popcount instruction, but more higher costs than asm-generic/ for others.