diff options
author | dillon <dillon@FreeBSD.org> | 2003-01-11 01:09:51 +0000 |
---|---|---|
committer | dillon <dillon@FreeBSD.org> | 2003-01-11 01:09:51 +0000 |
commit | 7060fb8de0e3d82d1352b6ba4c60da0059ec8837 (patch) | |
tree | fd283a2e3997739d34987d9cc91ee671ead65731 /sys | |
parent | 3155dbd99ce81dc4841ea2380c12068dfb497612 (diff) | |
download | FreeBSD-src-7060fb8de0e3d82d1352b6ba4c60da0059ec8837.zip FreeBSD-src-7060fb8de0e3d82d1352b6ba4c60da0059ec8837.tar.gz |
Remove all use of the LOG2() macro/inline, undoing some non-optimal cruft
that crept in recently. GCC will optimize the divides and multiplies for us.
Submitted by: David Schultz <dschultz@uclink.Berkeley.EDU>
MFC after: 1 day
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/subr_blist.c | 32 | ||||
-rw-r--r-- | sys/sys/blist.h | 16 |
2 files changed, 16 insertions, 32 deletions
diff --git a/sys/kern/subr_blist.c b/sys/kern/subr_blist.c index 1ae2ee2..a58e548 100644 --- a/sys/kern/subr_blist.c +++ b/sys/kern/subr_blist.c @@ -153,8 +153,8 @@ blist_create(daddr_t blocks) radix = BLIST_BMAP_RADIX; while (radix < blocks) { - radix <<= BLIST_META_RADIX_SHIFT; - skip = (skip + 1) << BLIST_META_RADIX_SHIFT; + radix *= BLIST_META_RADIX; + skip = (skip + 1) * BLIST_META_RADIX; } bl = malloc(sizeof(struct blist), M_SWAP, M_WAITOK | M_ZERO); @@ -401,7 +401,7 @@ blst_meta_alloc( int skip ) { int i; - int next_skip = (skip >> BLIST_META_RADIX_SHIFT); + int next_skip = ((u_int)skip / BLIST_META_RADIX); if (scan->u.bmu_avail == 0) { /* @@ -412,7 +412,7 @@ blst_meta_alloc( } if (scan->u.bmu_avail == radix) { - radix >>= BLIST_META_RADIX_SHIFT; + radix /= BLIST_META_RADIX; /* * ALL-FREE special case, initialize uninitialize @@ -430,7 +430,7 @@ blst_meta_alloc( } } } else { - radix >>= BLIST_META_RADIX_SHIFT; + radix /= BLIST_META_RADIX; } for (i = 1; i <= skip; i += next_skip) { @@ -532,7 +532,7 @@ blst_meta_free( daddr_t blk ) { int i; - int next_skip = (skip >> BLIST_META_RADIX_SHIFT); + int next_skip = ((u_int)skip / BLIST_META_RADIX); #if 0 printf("FREE (%llx,%lld) FROM (%llx,%lld)\n", @@ -582,7 +582,7 @@ blst_meta_free( * Break the free down into its components */ - radix >>= BLIST_META_RADIX_SHIFT; + radix /= BLIST_META_RADIX; i = (freeBlk - blk) / radix; blk += i * radix; @@ -672,8 +672,8 @@ static void blst_copy( } - radix >>= BLIST_META_RADIX_SHIFT; - next_skip = (skip >> BLIST_META_RADIX_SHIFT); + radix /= BLIST_META_RADIX; + next_skip = ((u_int)skip / BLIST_META_RADIX); for (i = 1; count && i <= skip; i += next_skip) { if (scan[i].bm_bighint == (daddr_t)-1) @@ -751,7 +751,7 @@ blst_meta_fill( daddr_t blk ) { int i; - int next_skip = (skip >> BLIST_META_RADIX_SHIFT); + int next_skip = ((u_int)skip / BLIST_META_RADIX); int nblks = 0; if (count == radix || scan->u.bmu_avail == 0) { @@ -765,7 +765,7 @@ blst_meta_fill( } if (scan->u.bmu_avail == radix) { - radix >>= BLIST_META_RADIX_SHIFT; + radix /= BLIST_META_RADIX; /* * ALL-FREE special case, initialize sublevel @@ -782,7 +782,7 @@ blst_meta_fill( } } } else { - radix >>= BLIST_META_RADIX_SHIFT; + radix /= BLIST_META_RADIX; } if (count > radix) @@ -856,8 +856,8 @@ blst_radix_init(blmeta_t *scan, daddr_t radix, int skip, daddr_t count) scan->u.bmu_avail = 0; } - radix >>= BLIST_META_RADIX_SHIFT; - next_skip = (skip >> BLIST_META_RADIX_SHIFT); + radix /= BLIST_META_RADIX; + next_skip = ((u_int)skip / BLIST_META_RADIX); for (i = 1; i <= skip; i += next_skip) { if (count >= radix) { @@ -944,8 +944,8 @@ blst_radix_print(blmeta_t *scan, daddr_t blk, daddr_t radix, int skip, int tab) (long long)scan->bm_bighint ); - radix >>= BLIST_META_RADIX_SHIFT; - next_skip = (skip >> BLIST_META_RADIX_SHIFT); + radix /= BLIST_META_RADIX; + next_skip = ((u_int)skip / BLIST_META_RADIX); tab += 4; for (i = 1; i <= skip; i += next_skip) { diff --git a/sys/sys/blist.h b/sys/sys/blist.h index d426e48..c81439c 100644 --- a/sys/sys/blist.h +++ b/sys/sys/blist.h @@ -33,20 +33,6 @@ typedef u_int32_t u_daddr_t; /* unsigned disk address */ -static __inline int -LOG2(u_daddr_t v) -{ - int i = -1; - - if (!v) - return(0); - while (v) { - i++; - v >>= 1; - } - return (i); -} - /* * blmeta and bl_bitmap_t MUST be a power of 2 in size. */ @@ -69,9 +55,7 @@ typedef struct blist { } *blist_t; #define BLIST_META_RADIX 16 -#define BLIST_META_RADIX_SHIFT LOG2(BLIST_META_RADIX) #define BLIST_BMAP_RADIX (sizeof(u_daddr_t)*8) -#define BLIST_BMAP_RADIX_SHIFT LOG2(BLIST_BMAP_RADIX) #define BLIST_MAX_ALLOC BLIST_BMAP_RADIX |