Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754343AbcC1P3W (ORCPT ); Mon, 28 Mar 2016 11:29:22 -0400 Received: from shards.monkeyblade.net ([149.20.54.216]:44330 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752404AbcC1P3S (ORCPT ); Mon, 28 Mar 2016 11:29:18 -0400 Date: Mon, 28 Mar 2016 11:29:15 -0400 (EDT) Message-Id: <20160328.112915.1286498398436148099.davem@davemloft.net> To: zhaoxiu.zeng@gmail.com Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org Subject: Re: [PATCH 10/31] Add sparc-specific parity functions From: David Miller In-Reply-To: <56F8C4A3.1070808@gmail.com> References: <56F780FE.7000600@gmail.com> <20160327.224308.220596078048860811.davem@davemloft.net> <56F8C4A3.1070808@gmail.com> X-Mailer: Mew version 6.6 on Emacs 24.5 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 28 Mar 2016 08:29:17 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 971 Lines: 25 From: Zeng Zhaoxiu Date: Mon, 28 Mar 2016 13:44:03 +0800 > 在 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. Which is why said stanza's in the asm-generic header should be triggered by a CPP define or similar.