lkml.org 
[lkml]   [2016]   [Mar]   [28]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH 07/31] Add mips-specific parity functions
From
Date


在 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>
>>
>>
>

\
 
 \ /
  Last update: 2016-03-29 04:41    [W:0.121 / U:0.180 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site