[BACK]Return to bitops.h CVS log [TXT][DIR] Up to [Development] / linux-2.6-xfs / include / asm-cris / arch-v32

File: [Development] / linux-2.6-xfs / include / asm-cris / arch-v32 / bitops.h (download)

Revision 1.2, Mon Dec 5 21:19:08 2005 UTC (11 years, 10 months ago) by nathans.longdrop.melbourne.sgi.com
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +5 -5 lines

Merge up to 2.6.15-rc5.
Merge of 2.6.x-xfs-melb:linux:24672a by kenmcd.

#ifndef _ASM_CRIS_ARCH_BITOPS_H
#define _ASM_CRIS_ARCH_BITOPS_H

/*
 * Helper functions for the core of the ff[sz] functions. They compute the
 * number of leading zeroes of a bits-in-byte, byte-in-word and
 * word-in-dword-swapped number. They differ in that the first function also
 * inverts all bits in the input.
 */

static inline unsigned long
cris_swapnwbrlz(unsigned long w)
{
	unsigned long res;

	__asm__ __volatile__ ("swapnwbr %0\n\t"
			      "lz %0,%0"
			      : "=r" (res) : "0" (w));

	return res;
}

static inline unsigned long
cris_swapwbrlz(unsigned long w)
{
	unsigned long res;

	__asm__ __volatile__ ("swapwbr %0\n\t"
			      "lz %0,%0"
			      : "=r" (res) : "0" (w));

	return res;
}

/*
 * Find First Zero in word. Undefined if no zero exist, so the caller should
 * check against ~0 first.
 */
static inline unsigned long
ffz(unsigned long w)
{
	return cris_swapnwbrlz(w);
}

/*
 * Find First Set bit in word. Undefined if no 1 exist, so the caller
 * should check against 0 first.
 */
static inline unsigned long
__ffs(unsigned long w)
{
	return cris_swapnwbrlz(~w);
}

/*
 * Find First Bit that is set.
 */
static inline unsigned long
kernel_ffs(unsigned long w)
{
	return w ? cris_swapwbrlz (w) + 1 : 0;
}

#endif /* _ASM_CRIS_ARCH_BITOPS_H */