From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
To: David Daney <ddaney.cavm@gmail.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
Leonid Yegoshin <Leonid.Yegoshin@imgtec.com>,
"Maciej W. Rozycki" <macro@linux-mips.org>,
linux-kernel@vger.kernel.org, linux-mips@linux-mips.org
Subject: Re: [PATCH 07/31] Add mips-specific parity functions
Date: Tue, 29 Mar 2016 10:15:48 +0800 [thread overview]
Message-ID: <56F9E554.8090204@gmail.com> (raw)
In-Reply-To: <56F968EE.1000307@gmail.com>
在 2016年03月29日 01:25, David Daney 写道:
> On 03/26/2016 11:06 PM, zhaoxiu.zeng wrote:
>> From: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
>>
>
> There is nothing MIPS specific here. Why not put it in asm-generic or
> some similar place where it can be shared by all architectures?
>
> Also, are you sure __builtin_popcount() is available on all GCC
> versions that are supported for building the kernel?
>
> David Daney
>
Refrence to arch_hweight.h.
In the 68th line of
arch/mips/include/asm/mach-cavium-octeon/cpu-feature-overrides.h, we can
see:
#ifdef __OCTEON__
/*
* All gcc versions that have OCTEON support define __OCTEON__ and have the
* __builtin_popcount support.
*/
#define ARCH_HAS_USABLE_BUILTIN_POPCOUNT 1
#endif
/*
* All gcc versions that have OCTEON support define __OCTEON__ and have the
* __builtin_popcount support.
*/
>> Signed-off-by: Zeng Zhaoxiu <zhaoxiu.zeng@gmail.com>
>> ---
>> arch/mips/include/asm/arch_parity.h | 44
>> +++++++++++++++++++++++++++++++++++++
>> arch/mips/include/asm/bitops.h | 3 +++
>> 2 files changed, 47 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 <asm/types.h>
>> +
>> +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 <asm-generic/bitops/arch_hweight.h>
>> +#include <asm-generic/bitops/arch_parity.h>
>> +#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 <asm/arch_hweight.h>
>> #include <asm-generic/bitops/const_hweight.h>
>>
>> +#include <asm/arch_parity.h>
>> +#include <asm-generic/bitops/const_parity.h>
>> +
>> #include <asm-generic/bitops/le.h>
>> #include <asm-generic/bitops/ext2-atomic.h>
>>
>>
>
next prev parent reply other threads:[~2016-03-29 2:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1458788612-4367-1-git-send-email-zhaoxiu.zeng@gmail.com>
2016-03-27 6:06 ` [PATCH 07/31] Add mips-specific parity functions zhaoxiu.zeng
2016-03-28 17:25 ` David Daney
2016-03-29 2:15 ` Zeng Zhaoxiu [this message]
2016-03-27 6:55 ` [PATCH 13/31] mips: use parity functions in cerr-sb1.c zhaoxiu.zeng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56F9E554.8090204@gmail.com \
--to=zhaoxiu.zeng@gmail.com \
--cc=Leonid.Yegoshin@imgtec.com \
--cc=ddaney.cavm@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=macro@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox