Define ffs/fls for all architectures

UBIFS requires fls(), which is not defined for arm (and some other
architectures) and this patch adds it. The implementation is taken from
Linux and is generic. ffs() is also defined for those that miss it.

Signed-off-by: Simon Kagstrom <simon.kagstrom@netinsight.net>
This commit is contained in:
Simon Kagstrom
2009-08-24 09:10:12 +02:00
committed by Tom Rix
parent f83ab09566
commit c1d1bfa583
7 changed files with 53 additions and 0 deletions

View File

@@ -178,6 +178,7 @@ static __inline__ int fls(unsigned int x)
{
return __ilog2(x) + 1;
}
#define fls
/**
* fls64 - find last set bit in a 64-bit word
@@ -230,6 +231,7 @@ extern __inline__ int ffs(int x)
{
return __ilog2(x & -x) + 1;
}
#define ffs
/*
* hweightN: returns the hamming weight (i.e. the number