Page MenuHomeFreeBSD

D45170.id138447.diff
No OneTemporary

D45170.id138447.diff

Index: sys/dev/cxgbe/osdep.h
===================================================================
--- sys/dev/cxgbe/osdep.h
+++ sys/dev/cxgbe/osdep.h
@@ -130,14 +130,6 @@
#define PCI_EXP_LNKSTA_NLW PCIEM_LINK_STA_WIDTH
#define PCI_EXP_DEVCTL2 PCIER_DEVICE_CTL2
-static inline int
-ilog2(long x)
-{
- KASSERT(x > 0 && powerof2(x), ("%s: invalid arg %ld", __func__, x));
-
- return (flsl(x) - 1);
-}
-
static inline char *
strstrip(char *s)
{
Index: sys/dev/mana/gdma_util.h
===================================================================
--- sys/dev/mana/gdma_util.h
+++ sys/dev/mana/gdma_util.h
@@ -170,15 +170,6 @@
return (max);
}
-static inline unsigned long
-ilog2(unsigned long x)
-{
- unsigned long log = x;
- while (x >>= 1)
- log++;
- return (log);
-}
-
static inline unsigned long
roundup_pow_of_two(unsigned long x)
{
Index: sys/powerpc/booke/pmap_64.c
===================================================================
--- sys/powerpc/booke/pmap_64.c
+++ sys/powerpc/booke/pmap_64.c
@@ -125,7 +125,6 @@
#define VM_MAPDEV_PA_MAX 0x4000000000000000 /* Don't encroach on DMAP */
static void tid_flush(tlbtid_t tid);
-static unsigned long ilog2(unsigned long);
/**************************************************************************/
/* Page table management */
@@ -746,18 +745,6 @@
/* TID handling */
/**************************************************************************/
-/*
- * Return the largest uint value log such that 2^log <= num.
- */
-static unsigned long
-ilog2(unsigned long num)
-{
- long lz;
-
- __asm ("cntlzd %0, %1" : "=r" (lz) : "r" (num));
- return (63 - lz);
-}
-
/*
* Invalidate all TLB0 entries which match the given TID. Note this is
* dedicated for cases when invalidations should NOT be propagated to other
Index: sys/sys/libkern.h
===================================================================
--- sys/sys/libkern.h
+++ sys/sys/libkern.h
@@ -186,6 +186,31 @@
8 * sizeof(mask) - __builtin_clzll((unsigned long long)mask));
}
+static __inline __pure2 int
+ilog2(int mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 - __builtin_clz((u_int)mask));
+}
+
+static __inline __pure2 int
+ilog2l(long mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 - __builtin_clzl((u_long)mask));
+}
+
+static __inline __pure2 int
+ilog2ll(long long mask)
+{
+
+ MPASS(mask != 0);
+ return (8 * sizeof(mask) - 1 -
+ __builtin_clzll((unsigned long long)mask));
+}
+
#define bitcount64(x) __bitcount64((uint64_t)(x))
#define bitcount32(x) __bitcount32((uint32_t)(x))
#define bitcount16(x) __bitcount16((uint16_t)(x))

File Metadata

Mime Type
text/plain
Expires
Mon, Mar 23, 4:45 AM (20 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
30160520
Default Alt Text
D45170.id138447.diff (2 KB)

Event Timeline