Author: bonefish Date: 2010-06-02 22:42:53 +0200 (Wed, 02 Jun 2010) New Revision: 36998 Changeset: http://dev.haiku-os.org/changeset/36998/haiku Modified: haiku/trunk/headers/private/kernel/util/RadixBitmap.h haiku/trunk/src/libs/compat/freebsd_network/Unit.cpp haiku/trunk/src/system/kernel/util/RadixBitmap.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h Log: Replaced the swap_addr_t and SWAP_SLOT_NONE in RadixBitmap.{h,cpp} by radix_slot_t and RADIX_SLOT_NONE. Modified: haiku/trunk/headers/private/kernel/util/RadixBitmap.h =================================================================== --- haiku/trunk/headers/private/kernel/util/RadixBitmap.h 2010-06-02 18:42:20 UTC (rev 36997) +++ haiku/trunk/headers/private/kernel/util/RadixBitmap.h 2010-06-02 20:42:53 UTC (rev 36998) @@ -37,7 +37,7 @@ #include <SupportDefs.h> -typedef uint32 swap_addr_t; +typedef uint32 radix_slot_t; typedef uint32 bitmap_t; typedef struct radix_node { @@ -48,26 +48,26 @@ int32 big_hint; // the biggest continuous slots under us } radix_node; -// Bitmap which uses radix tree for hinting. +// Bitmap which uses radix tree for hinting. // The radix tree is stored in an array. typedef struct radix_bitmap { - swap_addr_t free_slots; // # of free slots - swap_addr_t radix; // coverage radix - swap_addr_t skip; // starting skip - radix_node *root; // root of radix tree, actually it is an array - swap_addr_t root_size; // size of the array(# of nodes in the tree) + radix_slot_t free_slots; // # of free slots + radix_slot_t radix; // coverage radix + radix_slot_t skip; // starting skip + radix_node *root; // root of radix tree, actually it is an array + radix_slot_t root_size; // size of the array(# of nodes in the tree) } radix_bitmap; -#define BITMAP_RADIX (sizeof(swap_addr_t) * 8) -#define NODE_RADIX 16 +#define BITMAP_RADIX (sizeof(radix_slot_t) * 8) +#define NODE_RADIX 16 -#define SWAP_SLOT_NONE ((swap_addr_t)-1) +#define RADIX_SLOT_NONE ((radix_slot_t)-1) extern radix_bitmap *radix_bitmap_create(uint32 slots); -extern swap_addr_t radix_bitmap_alloc(radix_bitmap *bmp, uint32 count); -extern void radix_bitmap_dealloc(radix_bitmap *bmp, swap_addr_t slotIndex, +extern radix_slot_t radix_bitmap_alloc(radix_bitmap *bmp, uint32 count); +extern void radix_bitmap_dealloc(radix_bitmap *bmp, radix_slot_t slotIndex, uint32 count); extern void radix_bitmap_destroy(radix_bitmap *bmp); Modified: haiku/trunk/src/libs/compat/freebsd_network/Unit.cpp =================================================================== --- haiku/trunk/src/libs/compat/freebsd_network/Unit.cpp 2010-06-02 18:42:20 UTC (rev 36997) +++ haiku/trunk/src/libs/compat/freebsd_network/Unit.cpp 2010-06-02 20:42:53 UTC (rev 36998) @@ -39,13 +39,12 @@ int _alloc_unr_locked(struct unrhdr* idStore) { - swap_addr_t slotIndex; + radix_slot_t slotIndex; int id = ID_STORE_FULL; slotIndex = radix_bitmap_alloc(idStore->idBuffer, 1); - if (slotIndex != SWAP_SLOT_NONE) { + if (slotIndex != RADIX_SLOT_NONE) id = slotIndex + idStore->idBias; - } return id; } Modified: haiku/trunk/src/system/kernel/util/RadixBitmap.cpp =================================================================== --- haiku/trunk/src/system/kernel/util/RadixBitmap.cpp 2010-06-02 18:42:20 UTC (rev 36997) +++ haiku/trunk/src/system/kernel/util/RadixBitmap.cpp 2010-06-02 20:42:53 UTC (rev 36998) @@ -193,8 +193,8 @@ } -static swap_addr_t -radix_leaf_alloc(radix_node *leaf, swap_addr_t slotIndex, int32 count) +static radix_slot_t +radix_leaf_alloc(radix_node *leaf, radix_slot_t slotIndex, int32 count) { if (count <= (int32)BITMAP_RADIX) { bitmap_t bitmap = ~leaf->u.bitmap; @@ -212,12 +212,12 @@ // we could not allocate count here, update big_hint if (leaf->big_hint >= count) leaf->big_hint = count - 1; - return SWAP_SLOT_NONE; + return RADIX_SLOT_NONE; } -static swap_addr_t -radix_node_alloc(radix_node *node, swap_addr_t slotIndex, int32 count, +static radix_slot_t +radix_node_alloc(radix_node *node, radix_slot_t slotIndex, int32 count, uint32 radix, uint32 skip) { uint32 next_skip = skip / NODE_RADIX; @@ -228,13 +228,13 @@ break; if (count <= node[i].big_hint) { - swap_addr_t addr = SWAP_SLOT_NONE; + radix_slot_t addr = RADIX_SLOT_NONE; if (next_skip == 1) addr = radix_leaf_alloc(&node[i], slotIndex, count); else addr = radix_node_alloc(&node[i], slotIndex, count, radix, next_skip - 1); - if (addr != SWAP_SLOT_NONE) { + if (addr != RADIX_SLOT_NONE) { node->u.available -= count; if (node->big_hint > node->u.available) node->big_hint = node->u.available; @@ -248,21 +248,21 @@ // we could not allocate count in the subtree, update big_hint if (node->big_hint >= count) node->big_hint = count - 1; - return SWAP_SLOT_NONE; + return RADIX_SLOT_NONE; } -swap_addr_t +radix_slot_t radix_bitmap_alloc(radix_bitmap *bmp, uint32 count) { - swap_addr_t addr = SWAP_SLOT_NONE; + radix_slot_t addr = RADIX_SLOT_NONE; if (bmp->radix == BITMAP_RADIX) addr = radix_leaf_alloc(bmp->root, 0, count); else addr = radix_node_alloc(bmp->root, 0, count, bmp->radix, bmp->skip); - if (addr != SWAP_SLOT_NONE) + if (addr != RADIX_SLOT_NONE) bmp->free_slots -= count; return addr; @@ -270,7 +270,7 @@ static void -radix_leaf_dealloc(radix_node *leaf, swap_addr_t slotIndex, uint32 count) +radix_leaf_dealloc(radix_node *leaf, radix_slot_t slotIndex, uint32 count) { uint32 n = slotIndex & (BITMAP_RADIX - 1); bitmap_t mask = ((bitmap_t)-1 >> (BITMAP_RADIX - count - n)) @@ -282,8 +282,8 @@ static void -radix_node_dealloc(radix_node *node, swap_addr_t slotIndex, uint32 count, - uint32 radix, uint32 skip, swap_addr_t index) +radix_node_dealloc(radix_node *node, radix_slot_t slotIndex, uint32 count, + uint32 radix, uint32 skip, radix_slot_t index) { node->u.available += count; @@ -317,7 +317,7 @@ void -radix_bitmap_dealloc(radix_bitmap *bmp, swap_addr_t slotIndex, uint32 count) +radix_bitmap_dealloc(radix_bitmap *bmp, radix_slot_t slotIndex, uint32 count) { if (bmp->radix == BITMAP_RADIX) radix_leaf_dealloc(bmp->root, slotIndex, count); Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2010-06-02 18:42:20 UTC (rev 36997) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.cpp 2010-06-02 20:42:53 UTC (rev 36998) @@ -62,6 +62,8 @@ #define INITIAL_SWAP_HASH_SIZE 1024 +#define SWAP_SLOT_NONE RADIX_SLOT_NONE + #define SWAP_BLOCK_PAGES 32 #define SWAP_BLOCK_SHIFT 5 /* 1 << SWAP_BLOCK_SHIFT == SWAP_BLOCK_PAGES */ #define SWAP_BLOCK_MASK (SWAP_BLOCK_PAGES - 1) Modified: haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h =================================================================== --- haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h 2010-06-02 18:42:20 UTC (rev 36997) +++ haiku/trunk/src/system/kernel/vm/VMAnonymousCache.h 2010-06-02 20:42:53 UTC (rev 36998) @@ -15,7 +15,8 @@ #if ENABLE_SWAP_SUPPORT -typedef page_num_t swap_addr_t; +typedef uint32 swap_addr_t; + // TODO: Should be wider, but RadixBitmap supports only a 32 bit type ATM! struct swap_block; struct system_memory_info;