From: ericm Date: Fri, 13 Oct 2006 03:10:24 +0000 (+0000) Subject: branch: b_new_cmd X-Git-Tag: v1_8_0_110~486^2~569 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=8b128330c9b7fada874cb78f4f9216c10a157bd6;p=fs%2Flustre-release.git branch: b_new_cmd from tappro: a better version of size_roundup_power2(). --- diff --git a/lustre/include/liblustre.h b/lustre/include/liblustre.h index 290accd..17dbceb 100644 --- a/lustre/include/liblustre.h +++ b/lustre/include/liblustre.h @@ -760,36 +760,6 @@ int test_and_clear_bit(int nr, unsigned long *addr) return oldbit; } -static inline -int fls(int x) -{ - int r = 32; - - if (!x) - return 0; - if (!(x & 0xffff0000u)) { - x <<= 16; - r -= 16; - } - if (!(x & 0xff000000u)) { - x <<= 8; - r -= 8; - } - if (!(x & 0xf0000000u)) { - x <<= 4; - r -= 4; - } - if (!(x & 0xc0000000u)) { - x <<= 2; - r -= 2; - } - if (!(x & 0x80000000u)) { - x <<= 1; - r -= 1; - } - return r; -} - /* FIXME sys/capability will finally included linux/fs.h thus * cause numerous trouble on x86-64. as temporary solution for * build broken at Cray, we copy definition we need from capability.h diff --git a/lustre/include/lustre_sec.h b/lustre/include/lustre_sec.h index ced9bea..c99af98 100644 --- a/lustre/include/lustre_sec.h +++ b/lustre/include/lustre_sec.h @@ -416,14 +416,14 @@ extern struct proc_dir_entry *sptlrpc_proc_root; */ static inline int size_roundup_power2(int size) { - int rc; - - LASSERT(size > 0); - rc = 1 << (fls(size) - 1); - if ((rc - 1) & size) - rc <<= 1; - LASSERT(rc > 0); - return rc; + size--; + size |= size >> 1; + size |= size >> 2; + size |= size >> 4; + size |= size >> 8; + size |= size >> 16; + size++; + return size; } /*