Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb41838b authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'core-hweight-for-linus' of...

Merge branch 'core-hweight-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'core-hweight-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  x86, hweight: Use a 32-bit popcnt for __arch_hweight32()
  arch, hweight: Fix compilation errors
  x86: Add optimized popcnt variants
  bitops: Optimize hweight() by making use of compile-time evaluation
parents 98f01720 c59bd568
Loading
Loading
Loading
Loading
+10 −8
Original line number Diff line number Diff line
@@ -405,29 +405,31 @@ static inline int fls(int x)

#if defined(CONFIG_ALPHA_EV6) && defined(CONFIG_ALPHA_EV67)
/* Whee.  EV67 can calculate it directly.  */
static inline unsigned long hweight64(unsigned long w)
static inline unsigned long __arch_hweight64(unsigned long w)
{
	return __kernel_ctpop(w);
}

static inline unsigned int hweight32(unsigned int w)
static inline unsigned int __arch_weight32(unsigned int w)
{
	return hweight64(w);
	return __arch_hweight64(w);
}

static inline unsigned int hweight16(unsigned int w)
static inline unsigned int __arch_hweight16(unsigned int w)
{
	return hweight64(w & 0xffff);
	return __arch_hweight64(w & 0xffff);
}

static inline unsigned int hweight8(unsigned int w)
static inline unsigned int __arch_hweight8(unsigned int w)
{
	return hweight64(w & 0xff);
	return __arch_hweight64(w & 0xff);
}
#else
#include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/arch_hweight.h>
#endif

#include <asm-generic/bitops/const_hweight.h>

#endif /* __KERNEL__ */

#include <asm-generic/bitops/find.h>
+6 −5
Original line number Diff line number Diff line
@@ -437,17 +437,18 @@ __fls (unsigned long x)
 * hweightN: returns the hamming weight (i.e. the number
 * of bits set) of a N-bit word
 */
static __inline__ unsigned long
hweight64 (unsigned long x)
static __inline__ unsigned long __arch_hweight64(unsigned long x)
{
	unsigned long result;
	result = ia64_popcnt(x);
	return result;
}

#define hweight32(x)	(unsigned int) hweight64((x) & 0xfffffffful)
#define hweight16(x)	(unsigned int) hweight64((x) & 0xfffful)
#define hweight8(x)	(unsigned int) hweight64((x) & 0xfful)
#define __arch_hweight32(x) ((unsigned int) __arch_hweight64((x) & 0xfffffffful))
#define __arch_hweight16(x) ((unsigned int) __arch_hweight64((x) & 0xfffful))
#define __arch_hweight8(x)  ((unsigned int) __arch_hweight64((x) & 0xfful))

#include <asm-generic/bitops/const_hweight.h>

#endif /* __KERNEL__ */

+6 −5
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ extern void change_bit(unsigned long nr, volatile unsigned long *addr);

#ifdef ULTRA_HAS_POPULATION_COUNT

static inline unsigned int hweight64(unsigned long w)
static inline unsigned int __arch_hweight64(unsigned long w)
{
	unsigned int res;

@@ -52,7 +52,7 @@ static inline unsigned int hweight64(unsigned long w)
	return res;
}

static inline unsigned int hweight32(unsigned int w)
static inline unsigned int __arch_hweight32(unsigned int w)
{
	unsigned int res;

@@ -60,7 +60,7 @@ static inline unsigned int hweight32(unsigned int w)
	return res;
}

static inline unsigned int hweight16(unsigned int w)
static inline unsigned int __arch_hweight16(unsigned int w)
{
	unsigned int res;

@@ -68,7 +68,7 @@ static inline unsigned int hweight16(unsigned int w)
	return res;
}

static inline unsigned int hweight8(unsigned int w)
static inline unsigned int __arch_hweight8(unsigned int w)
{
	unsigned int res;

@@ -78,9 +78,10 @@ static inline unsigned int hweight8(unsigned int w)

#else

#include <asm-generic/bitops/hweight.h>
#include <asm-generic/bitops/arch_hweight.h>

#endif
#include <asm-generic/bitops/const_hweight.h>
#include <asm-generic/bitops/lock.h>
#endif /* __KERNEL__ */

+5 −0
Original line number Diff line number Diff line
@@ -237,6 +237,11 @@ config X86_32_LAZY_GS
	def_bool y
	depends on X86_32 && !CC_STACKPROTECTOR

config ARCH_HWEIGHT_CFLAGS
	string
	default "-fcall-saved-ecx -fcall-saved-edx" if X86_32
	default "-fcall-saved-rdi -fcall-saved-rsi -fcall-saved-rdx -fcall-saved-rcx -fcall-saved-r8 -fcall-saved-r9 -fcall-saved-r10 -fcall-saved-r11" if X86_64

config KTIME_SCALAR
	def_bool X86_32
source "init/Kconfig"
+6 −3
Original line number Diff line number Diff line
@@ -42,9 +42,6 @@
#define LOCK_PREFIX ""
#endif

/* This must be included *after* the definition of LOCK_PREFIX */
#include <asm/cpufeature.h>

struct alt_instr {
	u8 *instr;		/* original instruction */
	u8 *replacement;
@@ -98,6 +95,12 @@ static inline int alternatives_text_reserved(void *start, void *end)
      "663:\n\t" newinstr "\n664:\n"		/* replacement     */	\
      ".previous"

/*
 * This must be included *after* the definition of ALTERNATIVE due to
 * <asm/arch_hweight.h>
 */
#include <asm/cpufeature.h>

/*
 * Alternative instructions for different CPU types or capabilities.
 *
Loading