lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Wed, 6 Apr 2016 16:53:30 +0800 From: zengzhaoxiu@....com To: realmz6@...il.com Cc: adi-buildroot-devel@...ts.sourceforge.net, linux-kernel@...r.kernel.org, Zhaoxiu Zeng <zhaoxiu.zeng@...il.com> Subject: [PATCH v2 04/30] Add blackfin-specific parity functions From: Zhaoxiu Zeng <zhaoxiu.zeng@...il.com> Signed-off-by: Zhaoxiu Zeng <zhaoxiu.zeng@...il.com> --- arch/blackfin/include/asm/bitops.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/arch/blackfin/include/asm/bitops.h b/arch/blackfin/include/asm/bitops.h index b298b65..6609b7e 100644 --- a/arch/blackfin/include/asm/bitops.h +++ b/arch/blackfin/include/asm/bitops.h @@ -23,6 +23,7 @@ #include <asm-generic/bitops/sched.h> #include <asm-generic/bitops/ffs.h> #include <asm-generic/bitops/const_hweight.h> +#include <asm-generic/bitops/const_parity.h> #include <asm-generic/bitops/lock.h> #include <asm-generic/bitops/ext2-atomic.h> @@ -137,4 +138,34 @@ static inline unsigned int __arch_hweight8(unsigned int w) return __arch_hweight32(w & 0xff); } +/* + * parityN: returns the parity of a N-bit word, + * i.e. the number of 1-bits in w modulo 2. + */ + +static inline unsigned int __arch_parity32(unsigned int w) +{ + return __arch_hweight32(w) & 1; +} + +static inline unsigned int __arch_parity64(__u64 w) +{ + return __arch_parity32((unsigned int)(w >> 32) ^ (unsigned int)w); +} + +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); +} + #endif /* _BLACKFIN_BITOPS_H */ -- 2.5.0
Powered by blists - more mailing lists