diff --git a/headers/private/kernel/Notifications.h b/headers/private/kernel/Notifications.h index 6ab3c4475f..0d0fbc86db 100644 --- a/headers/private/kernel/Notifications.h +++ b/headers/private/kernel/Notifications.h @@ -108,11 +108,11 @@ public: NotificationListener& listener) = 0; virtual const char* Name() = 0; - HashTableLink& + NotificationService*& Link() { return fLink; } private: - HashTableLink fLink; + NotificationService* fLink; }; struct default_listener : public DoublyLinkedListLinkImpl { @@ -226,11 +226,11 @@ private: { return hash_hash_string(service->Name()); } bool Compare(const char* key, NotificationService* service) const { return !strcmp(key, service->Name()); } - HashTableLink* GetLink( + NotificationService*& GetLink( NotificationService* service) const - { return &service->Link(); } + { return service->Link(); } }; - typedef OpenHashTable ServiceHash; + typedef BOpenHashTable ServiceHash; static NotificationManager sManager; diff --git a/headers/private/kernel/condition_variable.h b/headers/private/kernel/condition_variable.h index 0a602e05d6..5f1a83f1e8 100644 --- a/headers/private/kernel/condition_variable.h +++ b/headers/private/kernel/condition_variable.h @@ -46,7 +46,7 @@ private: }; -struct ConditionVariable : protected HashTableLink { +struct ConditionVariable { public: void Init(const void* object, const char* objectType); @@ -81,6 +81,7 @@ protected: const void* fObject; const char* fObjectType; EntryList fEntries; + ConditionVariable* fNext; friend struct ConditionVariableEntry; friend struct ConditionVariableHashDefinition; diff --git a/headers/private/kernel/kimage.h b/headers/private/kernel/kimage.h index 619e7e3707..4cead2c245 100644 --- a/headers/private/kernel/kimage.h +++ b/headers/private/kernel/kimage.h @@ -18,7 +18,7 @@ struct team; struct image { struct image* next; struct image* prev; - HashTableLink hash_link; + struct image* hash_link; image_info info; team_id team; }; diff --git a/headers/private/kernel/util/MultiHashTable.h b/headers/private/kernel/util/MultiHashTable.h index 51a5b17fab..2313d6c4b1 100644 --- a/headers/private/kernel/util/MultiHashTable.h +++ b/headers/private/kernel/util/MultiHashTable.h @@ -21,10 +21,10 @@ template -class MultiHashTable : private OpenHashTable { public: - typedef OpenHashTable HashTable; + typedef BOpenHashTable HashTable; typedef MultiHashTable MultiTable; typedef typename HashTable::Iterator Iterator; @@ -116,7 +116,7 @@ public: while (slot) { if (HashTable::fDefinition.Compare(key, slot)) break; - slot = HashTable::_Link(slot)->fNext; + slot = HashTable::_Link(slot); } if (slot == NULL) @@ -140,18 +140,18 @@ private: // group values with the same key for (previous = table[index]; previous && !HashTable::fDefinition.CompareValues(previous, value); - previous = HashTable::_Link(previous)->fNext); + previous = HashTable::_Link(previous)); if (previous) { - _Link(value)->fNext = _Link(previous)->fNext; - _Link(previous)->fNext = value; + _Link(value) = _Link(previous); + _Link(previous) = value; } else { - _Link(value)->fNext = table[index]; + _Link(value) = table[index]; table[index] = value; } } - // TODO use OpenHashTable's _Resize + // TODO use BOpenHashTable's _Resize bool _Resize(size_t newSize) { ValueType **newTable = new ValueType *[newSize]; @@ -165,7 +165,7 @@ private: for (size_t i = 0; i < HashTable::fTableSize; i++) { ValueType *bucket = HashTable::fTable[i]; while (bucket) { - ValueType *next = _Link(bucket)->fNext; + ValueType *next = _Link(bucket); _Insert(newTable, newSize, bucket); bucket = next; } diff --git a/headers/private/kernel/util/OpenHashTable.h b/headers/private/kernel/util/OpenHashTable.h index b76b06c205..6d43d8bef2 100644 --- a/headers/private/kernel/util/OpenHashTable.h +++ b/headers/private/kernel/util/OpenHashTable.h @@ -21,10 +21,10 @@ `Compare' and `GetLink;. It must also define several types as shown in the following example: - struct Foo : HashTableLink { + struct Foo { int bar; - HashTableLink otherLink; + Foo* fNext; }; struct HashTableDefinition { @@ -34,22 +34,18 @@ HashTableDefinition(const HashTableDefinition&) {} size_t HashKey(int key) const { return key >> 1; } - size_t Hash(Foo *value) const { return HashKey(value->bar); } - bool Compare(int key, Foo *value) const { return value->bar == key; } - HashTableLink *GetLink(Foo *value) const { return value; } + size_t Hash(Foo* value) const { return HashKey(value->bar); } + bool Compare(int key, Foo* value) const { return value->bar == key; } + Foo*& GetLink(Foo* value) const { return value->fNext; } }; */ -template -struct HashTableLink { - Type *fNext; -}; template -class OpenHashTable { +class BOpenHashTable { public: - typedef OpenHashTable HashTable; + typedef BOpenHashTable HashTable; typedef typename Definition::KeyType KeyType; typedef typename Definition::ValueType ValueType; @@ -62,7 +58,7 @@ public: // regrowth factor: 200 / 256 = 78.125% // 50 / 256 = 19.53125% - OpenHashTable() + BOpenHashTable() : fTableSize(0), fItemCount(0), @@ -70,7 +66,7 @@ public: { } - OpenHashTable(const Definition& definition) + BOpenHashTable(const Definition& definition) : fDefinition(definition), fTableSize(0), @@ -79,7 +75,7 @@ public: { } - ~OpenHashTable() + ~BOpenHashTable() { free(fTable); } @@ -101,24 +97,24 @@ public: return fItemCount; } - ValueType *Lookup(const KeyType &key) const + ValueType* Lookup(const KeyType& key) const { if (fTableSize == 0) return NULL; size_t index = fDefinition.HashKey(key) & (fTableSize - 1); - ValueType *slot = fTable[index]; + ValueType* slot = fTable[index]; while (slot) { if (fDefinition.Compare(key, slot)) break; - slot = _Link(slot)->fNext; + slot = _Link(slot); } return slot; } - status_t Insert(ValueType *value) + status_t Insert(ValueType* value) { if (fTableSize == 0) { if (!_Resize(kMinimumSize)) @@ -130,7 +126,7 @@ public: return B_OK; } - void InsertUnchecked(ValueType *value) + void InsertUnchecked(ValueType* value) { if (CheckDuplicates && _ExhaustiveSearch(value)) { #ifdef _KERNEL_MODE @@ -146,7 +142,7 @@ public: // TODO: a ValueType* Remove(const KeyType& key) method is missing - bool Remove(ValueType *value) + bool Remove(ValueType* value) { if (!RemoveUnchecked(value)) return false; @@ -158,17 +154,18 @@ public: return true; } - bool RemoveUnchecked(ValueType *value) + bool RemoveUnchecked(ValueType* value) { size_t index = fDefinition.Hash(value) & (fTableSize - 1); - ValueType *previous = NULL, *slot = fTable[index]; + ValueType* previous = NULL; + ValueType* slot = fTable[index]; while (slot) { - ValueType *next = _Link(slot)->fNext; + ValueType* next = _Link(slot); if (value == slot) { if (previous) - _Link(previous)->fNext = next; + _Link(previous) = next; else fTable[index] = next; break; @@ -217,7 +214,7 @@ public: // update nextPointer to point to the fNext of the last // element in the bucket while (element != NULL) { - nextPointer = &_Link(element)->fNext; + nextPointer = &_Link(element); element = *nextPointer; } } @@ -274,20 +271,20 @@ public: class Iterator { public: - Iterator(const HashTable *table) + Iterator(const HashTable* table) : fTable(table) { Rewind(); } - Iterator(const HashTable *table, size_t index, ValueType *value) + Iterator(const HashTable* table, size_t index, ValueType* value) : fTable(table), fIndex(index), fNext(value) {} bool HasNext() const { return fNext != NULL; } - ValueType *Next() + ValueType* Next() { - ValueType *current = fNext; + ValueType* current = fNext; _GetNext(); return current; } @@ -306,15 +303,15 @@ public: void _GetNext() { if (fNext) - fNext = fTable->_Link(fNext)->fNext; + fNext = fTable->_Link(fNext); while (fNext == NULL && fIndex < fTable->fTableSize) fNext = fTable->fTable[fIndex++]; } - const HashTable *fTable; + const HashTable* fTable; size_t fIndex; - ValueType *fNext; + ValueType* fNext; }; Iterator GetIterator() const { return Iterator(this); } @@ -323,11 +320,11 @@ protected: // for g++ 2.95 friend class Iterator; - void _Insert(ValueType **table, size_t tableSize, ValueType *value) + void _Insert(ValueType** table, size_t tableSize, ValueType* value) { size_t index = fDefinition.Hash(value) & (tableSize - 1); - _Link(value)->fNext = table[index]; + _Link(value) = table[index]; table[index] = value; } @@ -349,9 +346,9 @@ protected: if (fTable) { for (size_t i = 0; i < fTableSize; i++) { - ValueType *bucket = fTable[i]; + ValueType* bucket = fTable[i]; while (bucket) { - ValueType *next = _Link(bucket)->fNext; + ValueType* next = _Link(bucket); _Insert(newTable, newSize, bucket); bucket = next; } @@ -364,28 +361,29 @@ protected: fTable = newTable; } - HashTableLink *_Link(ValueType *bucket) const + ValueType*& _Link(ValueType* bucket) const { return fDefinition.GetLink(bucket); } - bool _ExhaustiveSearch(ValueType *value) const + bool _ExhaustiveSearch(ValueType* value) const { for (size_t i = 0; i < fTableSize; i++) { - ValueType *bucket = fTable[i]; + ValueType* bucket = fTable[i]; while (bucket) { if (bucket == value) return true; - bucket = _Link(bucket)->fNext; + bucket = _Link(bucket); } } return false; } - Definition fDefinition; - size_t fTableSize, fItemCount; - ValueType **fTable; + Definition fDefinition; + size_t fTableSize; + size_t fItemCount; + ValueType** fTable; }; #endif // _KERNEL_UTIL_OPEN_HASH_TABLE_H diff --git a/headers/private/userlandfs/shared/HashMap.h b/headers/private/userlandfs/shared/HashMap.h index ad63811ed1..eac031d4e7 100644 --- a/headers/private/userlandfs/shared/HashMap.h +++ b/headers/private/userlandfs/shared/HashMap.h @@ -15,7 +15,7 @@ // HashMapElement template -class HashMapElement : public HashTableLink > { +class HashMapElement { private: typedef HashMapElement Element; @@ -34,8 +34,9 @@ public: { } - Key fKey; - Value fValue; + Key fKey; + Value fValue; + HashMapElement* fNext; }; @@ -51,8 +52,8 @@ struct HashMapTableDefinition { { return HashKey(value->fKey); } bool Compare(const KeyType& key, const ValueType* value) const { return value->fKey == key; } - HashTableLink* GetLink(ValueType* value) const - { return value; } + ValueType*& GetLink(ValueType* value) const + { return value->fNext; } }; @@ -128,7 +129,8 @@ public: private: friend class HashMap; - typedef OpenHashTable > ElementTable; + typedef BOpenHashTable > + ElementTable; HashMap* fMap; typename ElementTable::Iterator fIterator; @@ -152,7 +154,7 @@ public: Iterator GetIterator(); protected: - typedef OpenHashTable > ElementTable; + typedef BOpenHashTable > ElementTable; typedef HashMapElement Element; friend class Iterator; diff --git a/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp b/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp index a78b5c6606..c556c7f246 100644 --- a/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp +++ b/src/add-ons/kernel/bus_managers/agp_gart/agp_gart.cpp @@ -74,8 +74,9 @@ #define BIND_APERTURE 0x20000000 #define APERTURE_PUBLIC_FLAGS_MASK 0x0000ffff -struct aperture_memory : HashTableLink { +struct aperture_memory { aperture_memory *next; + aperture_memory *hash_link; addr_t base; size_t size; uint32 flags; @@ -104,21 +105,21 @@ public: { return (memory->base - fInfo.base) / B_PAGE_SIZE; } bool Compare(const KeyType &base, aperture_memory *memory) const { return base == memory->base; } - HashTableLink *GetLink(aperture_memory *memory) const - { return memory; } + aperture_memory *&GetLink(aperture_memory *memory) const + { return memory->hash_link; } private: aperture_info &fInfo; }; -typedef OpenHashTable MemoryHashTable; +typedef BOpenHashTable MemoryHashTable; struct agp_device_info { uint8 address; /* location of AGP interface in PCI capabilities */ agp_info info; }; -class Aperture : public HashTableLink { +class Aperture { public: Aperture(agp_gart_bus_module_info *module, void *aperture); ~Aperture(); @@ -156,6 +157,9 @@ private: MemoryHashTable fHashTable; aperture_memory *fFirstMemory; void *fPrivateAperture; + +public: + Aperture *fNext; }; class ApertureHashDefinition { @@ -169,11 +173,11 @@ public: { return aperture->ID(); } bool Compare(const KeyType &id, Aperture *aperture) const { return id == aperture->ID(); } - HashTableLink *GetLink(Aperture *aperture) const - { return aperture; } + Aperture *&GetLink(Aperture *aperture) const + { return aperture->fNext; } }; -typedef OpenHashTable ApertureHashTable; +typedef BOpenHashTable ApertureHashTable; static agp_device_info sDeviceInfos[MAX_DEVICES]; diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp index 72cf2cd82b..ac8fb615cf 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.cpp @@ -76,7 +76,7 @@ FileSystem::~FileSystem() int32 count = 0; while (ops != NULL) { count++; - VNodeOps* next = ops->fNext; + VNodeOps* next = ops->hash_link; free(ops); ops = next; } diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.h b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.h index 78260a4f8f..7527208119 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.h +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/FileSystem.h @@ -25,10 +25,11 @@ class Settings; class Volume; -struct VNodeOps : HashTableLink { +struct VNodeOps { int32 refCount; FSVNodeCapabilities capabilities; fs_vnode_ops* ops; + VNodeOps* hash_link; VNodeOps(const FSVNodeCapabilities& capabilities, fs_vnode_ops* ops) : @@ -55,8 +56,8 @@ struct VNodeOpsHashDefinition { { return HashKey(value->capabilities); } bool Compare(const FSVNodeCapabilities& key, const VNodeOps* value) const { return value->capabilities == key; } - HashTableLink* GetLink(VNodeOps* value) const - { return value; } + VNodeOps*& GetLink(VNodeOps* value) const + { return value->hash_link; } }; @@ -109,7 +110,7 @@ private: friend class KernelDebug; struct SelectSyncEntry; struct SelectSyncMap; - typedef OpenHashTable VNodeOpsMap; + typedef BOpenHashTable VNodeOpsMap; Vector fVolumes; mutex fVolumeLock; diff --git a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp index 944df6a8f0..7dbe15b0e3 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/kernel_add_on/Volume.cpp @@ -47,7 +47,7 @@ static const bigtime_t kUserlandServerlandPortTimeout = 10000000; // 10s // VNode -struct Volume::VNode : HashTableLink { +struct Volume::VNode { ino_t id; void* clientNode; void* fileCache; @@ -55,6 +55,7 @@ struct Volume::VNode : HashTableLink { int32 useCount; bool valid; bool published; + VNode* hash_link; VNode(ino_t id, void* clientNode, VNodeOps* ops) : @@ -98,14 +99,14 @@ struct Volume::VNodeHashDefinition { { return HashKey(value->id); } bool Compare(ino_t key, const VNode* value) const { return value->id == key; } - HashTableLink* GetLink(VNode* value) const - { return value; } + VNode*& GetLink(VNode* value) const + { return value->hash_link; } }; // VNodeMap struct Volume::VNodeMap - : public OpenHashTable { + : public BOpenHashTable { }; @@ -114,8 +115,8 @@ struct Volume::IORequestInfo { io_request* request; int32 id; - HashTableLink idLink; - HashTableLink structLink; + IORequestInfo* idLink; + IORequestInfo* structLink; IORequestInfo(io_request* request, int32 id) : @@ -137,8 +138,8 @@ struct Volume::IORequestIDHashDefinition { { return HashKey(value->id); } bool Compare(int32 key, const IORequestInfo* value) const { return value->id == key; } - HashTableLink* GetLink(IORequestInfo* value) const - { return &value->idLink; } + IORequestInfo*& GetLink(IORequestInfo* value) const + { return value->idLink; } }; @@ -153,20 +154,20 @@ struct Volume::IORequestStructHashDefinition { { return HashKey(value->request); } bool Compare(io_request* key, const IORequestInfo* value) const { return value->request == key; } - HashTableLink* GetLink(IORequestInfo* value) const - { return &value->structLink; } + IORequestInfo*& GetLink(IORequestInfo* value) const + { return value->structLink; } }; // IORequestIDMap struct Volume::IORequestIDMap - : public OpenHashTable { + : public BOpenHashTable { }; // IORequestStructMap struct Volume::IORequestStructMap - : public OpenHashTable { + : public BOpenHashTable { }; @@ -802,7 +803,7 @@ Volume::Unmount() if (fVNodes != NULL) { VNode* node = fVNodes->Clear(true); while (node != NULL) { - VNode* nextNode = node->fNext; + VNode* nextNode = node->hash_link; node->Delete(this); node = nextNode; } @@ -820,7 +821,7 @@ Volume::Unmount() if (fIORequestInfosByStruct != NULL) { IORequestInfo* info = fIORequestInfosByStruct->Clear(true); while (info != NULL) { - IORequestInfo* nextInfo = info->structLink.fNext; + IORequestInfo* nextInfo = info->structLink; delete info; info = nextInfo; } diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEEntry.h b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEEntry.h index 60874c83b6..8c7213ae71 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEEntry.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/fuse/FUSEEntry.h @@ -35,11 +35,11 @@ struct FUSEEntryRef { }; -struct FUSEEntry : public HashTableLink, - DoublyLinkedListLinkImpl { +struct FUSEEntry : DoublyLinkedListLinkImpl { FUSENode* parent; char* name; FUSENode* node; + FUSEEntry* hashLink; FUSEEntry() : @@ -77,12 +77,13 @@ struct FUSEEntry : public HashTableLink, typedef DoublyLinkedList FUSEEntryList; -struct FUSENode : RWLockable, HashTableLink { +struct FUSENode : RWLockable { ino_t id; FUSEEntryList entries; int type; int32 refCount; bool dirty; + FUSENode* hashLink; FUSENode(ino_t id, int type) : @@ -113,8 +114,8 @@ struct FUSEEntryHashDefinition { bool Compare(const FUSEEntryRef& key, const FUSEEntry* value) const { return value->parent->id == key.parentID && strcmp(value->name, key.name) == 0; } - HashTableLink* GetLink(FUSEEntry* value) const - { return value; } + FUSEEntry*& GetLink(FUSEEntry* value) const + { return value->hashLink; } }; @@ -128,13 +129,13 @@ struct FUSENodeHashDefinition { { return HashKey(value->id); } bool Compare(ino_t key, const FUSENode* value) const { return value->id == key; } - HashTableLink* GetLink(FUSENode* value) const - { return value; } + FUSENode*& GetLink(FUSENode* value) const + { return value->hashLink; } }; -typedef OpenHashTable FUSEEntryTable; -typedef OpenHashTable FUSENodeTable; +typedef BOpenHashTable FUSEEntryTable; +typedef BOpenHashTable FUSENodeTable; } // namespace UserlandFS diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelFileSystem.cpp b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelFileSystem.cpp index ff0dd92d6f..bd98892ee2 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelFileSystem.cpp +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelFileSystem.cpp @@ -32,15 +32,14 @@ struct HaikuKernelFileSystem::IORequestHashDefinition { { return value->id; } bool Compare(int32 key, const HaikuKernelIORequest* value) const { return value->id == key; } - HashTableLink* - GetLink(HaikuKernelIORequest* value) const - { return value; } + HaikuKernelIORequest*& GetLink(HaikuKernelIORequest* value) const + { return value->hashLink; } }; // IORequestTable struct HaikuKernelFileSystem::IORequestTable - : public OpenHashTable { + : public BOpenHashTable { typedef int32 KeyType; typedef HaikuKernelIORequest ValueType; @@ -50,9 +49,8 @@ struct HaikuKernelFileSystem::IORequestTable { return value->id; } bool Compare(int32 key, const HaikuKernelIORequest* value) const { return value->id == key; } - HashTableLink* - GetLink(HaikuKernelIORequest* value) const - { return value; } + HaikuKernelIORequest*& GetLink(HaikuKernelIORequest* value) const + { return value->hashLink; } }; @@ -67,14 +65,14 @@ struct HaikuKernelFileSystem::NodeCapabilitiesHashDefinition { { return HashKey(value->ops); } bool Compare(fs_vnode_ops* key, const ValueType* value) const { return value->ops == key; } - HashTableLink* GetLink(ValueType* value) const - { return value; } + ValueType*& GetLink(ValueType* value) const + { return value->hashLink; } }; // NodeCapabilitiesTable struct HaikuKernelFileSystem::NodeCapabilitiesTable - : public OpenHashTable { + : public BOpenHashTable { }; diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelIORequest.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelIORequest.h index ac2bc375d2..32a6d70852 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelIORequest.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelIORequest.h @@ -16,11 +16,11 @@ namespace UserlandFS { class HaikuKernelVolume; -struct HaikuKernelIORequest : HashTableLink, - IORequestInfo { +struct HaikuKernelIORequest : IORequestInfo { - HaikuKernelVolume* volume; - int32 refCount; + HaikuKernelVolume* volume; + int32 refCount; + HaikuKernelIORequest* hashLink; HaikuKernelIORequest(HaikuKernelVolume* volume, const IORequestInfo& info) : diff --git a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelNode.h b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelNode.h index 1ec0b081be..7d9681eb69 100644 --- a/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelNode.h +++ b/src/add-ons/kernel/file_systems/userlandfs/server/haiku/HaikuKernelNode.h @@ -41,10 +41,11 @@ public: }; -struct HaikuKernelNode::Capabilities : HashTableLink { +struct HaikuKernelNode::Capabilities { int32 refCount; fs_vnode_ops* ops; FSVNodeCapabilities capabilities; + Capabilities* hashLink; Capabilities(fs_vnode_ops* ops, FSVNodeCapabilities capabilities) : diff --git a/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp b/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp index 28ebd0b58c..d60110f2fb 100644 --- a/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp +++ b/src/add-ons/kernel/network/protocols/ipv4/ipv4.cpp @@ -150,7 +150,7 @@ struct MulticastStateHash { bool CompareValues(ValueType* value1, ValueType* value2) const { return value1->Interface()->index == value2->Interface()->index && value1->Address().s_addr == value2->Address().s_addr; } - HashTableLink* GetLink(ValueType* value) const { return value; } + ValueType*& GetLink(ValueType* value) const { return value->HashLink(); } }; diff --git a/src/add-ons/kernel/network/protocols/ipv4/multicast.h b/src/add-ons/kernel/network/protocols/ipv4/multicast.h index 5a6129b7e2..2cdf15fb1f 100644 --- a/src/add-ons/kernel/network/protocols/ipv4/multicast.h +++ b/src/add-ons/kernel/network/protocols/ipv4/multicast.h @@ -126,11 +126,9 @@ private: template -class MulticastGroupInterface - : public HashTableLink< MulticastGroupInterface > { +class MulticastGroupInterface { public: typedef MulticastGroupInterface ThisType; - typedef HashTableLink HashLink; typedef typename Addressing::AddressType AddressType; typedef MulticastFilter Filter; typedef ::AddressSet AddressSet; @@ -176,9 +174,12 @@ public: bool Compare(const KeyType &key, ValueType *value) const { return value->Interface()->index == key.second && value->Address().s_addr == key.first->s_addr; } - HashLink *GetLink(ValueType *value) const { return &value->fLink; } + MulticastGroupInterface*& GetLink(ValueType *value) const + { return value->HashLink(); } }; + MulticastGroupInterface*& HashLink() { return fLink; } + private: // for g++ 2.95 friend class HashDefinition; @@ -188,7 +189,7 @@ private: net_interface *fInterface; FilterMode fFilterMode; AddressSet fAddresses; - HashLink fLink; + MulticastGroupInterface* fLink; }; template @@ -209,7 +210,7 @@ public: private: typedef typename GroupInterface::HashDefinition HashDefinition; - typedef OpenHashTable States; + typedef BOpenHashTable States; void _ReturnState(GroupInterface *state); diff --git a/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp b/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp index 8420e334fe..b4af19c78e 100644 --- a/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp +++ b/src/add-ons/kernel/network/protocols/tcp/EndpointManager.cpp @@ -165,10 +165,10 @@ ConnectionHashDefinition::Compare(const KeyType& key, } -HashTableLink* +TCPEndpoint*& ConnectionHashDefinition::GetLink(TCPEndpoint* endpoint) const { - return &endpoint->fConnectionHashLink; + return endpoint->fConnectionHashLink; } @@ -204,10 +204,10 @@ EndpointHashDefinition::CompareValues(TCPEndpoint* first, } -HashTableLink* +TCPEndpoint*& EndpointHashDefinition::GetLink(TCPEndpoint* endpoint) const { - return &endpoint->fEndpointHashLink; + return endpoint->fEndpointHashLink; } diff --git a/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h b/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h index 40545c3f53..ebe2aea77a 100644 --- a/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h +++ b/src/add-ons/kernel/network/protocols/tcp/EndpointManager.h @@ -45,7 +45,7 @@ public: size_t Hash(TCPEndpoint* endpoint) const; bool Compare(const KeyType& key, TCPEndpoint* endpoint) const; - HashTableLink* GetLink(TCPEndpoint* endpoint) const; + TCPEndpoint*& GetLink(TCPEndpoint* endpoint) const; private: EndpointManager* fManager; @@ -62,7 +62,7 @@ public: bool Compare(uint16 port, TCPEndpoint* endpoint) const; bool CompareValues(TCPEndpoint* first, TCPEndpoint* second) const; - HashTableLink* GetLink(TCPEndpoint* endpoint) const; + TCPEndpoint*& GetLink(TCPEndpoint* endpoint) const; }; @@ -104,7 +104,7 @@ private: status_t _BindToEphemeral(TCPEndpoint* endpoint, const sockaddr* address); - typedef OpenHashTable ConnectionTable; + typedef BOpenHashTable ConnectionTable; typedef MultiHashTable EndpointTable; rw_lock fLock; diff --git a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h index 9d459201bc..2ebf2905bc 100644 --- a/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h +++ b/src/add-ons/kernel/network/protocols/tcp/TCPEndpoint.h @@ -133,8 +133,8 @@ private: void* _endpoint); private: - HashTableLink fConnectionHashLink; - HashTableLink fEndpointHashLink; + TCPEndpoint* fConnectionHashLink; + TCPEndpoint* fEndpointHashLink; friend class EndpointManager; friend class ConnectionHashDefinition; friend class EndpointHashDefinition; diff --git a/src/add-ons/kernel/network/protocols/udp/udp.cpp b/src/add-ons/kernel/network/protocols/udp/udp.cpp index a232748439..bc28440c8a 100644 --- a/src/add-ons/kernel/network/protocols/udp/udp.cpp +++ b/src/add-ons/kernel/network/protocols/udp/udp.cpp @@ -96,15 +96,15 @@ public: bool IsActive() const { return fActive; } void SetActive(bool newValue) { fActive = newValue; } - ::HashTableLink *HashTableLink() { return &fLink; } + UdpEndpoint *&HashTableLink() { return fLink; } private: UdpDomainSupport *fManager; bool fActive; - // an active UdpEndpoint is part of the endpoint + // an active UdpEndpoint is part of the endpoint // hash (and it is bound and optionally connected) - ::HashTableLink fLink; + UdpEndpoint *fLink; }; @@ -143,7 +143,7 @@ struct UdpHashDefinition { && endpoint->PeerAddress().EqualTo(key.second, true); } - ::HashTableLink *GetLink(UdpEndpoint *endpoint) const + UdpEndpoint *&GetLink(UdpEndpoint *endpoint) const { return endpoint->HashTableLink(); } @@ -189,7 +189,7 @@ private: net_address_module_info *AddressModule() const { return fDomain->address_module; } - typedef OpenHashTable EndpointTable; + typedef BOpenHashTable EndpointTable; mutex fLock; net_domain *fDomain; diff --git a/src/add-ons/kernel/network/protocols/unix/UnixAddressManager.h b/src/add-ons/kernel/network/protocols/unix/UnixAddressManager.h index 8f28faa746..1359b8a3d2 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixAddressManager.h +++ b/src/add-ons/kernel/network/protocols/unix/UnixAddressManager.h @@ -31,7 +31,7 @@ struct UnixAddressHashDefinition { return key == endpoint->Address(); } - HashTableLink* GetLink(UnixEndpoint* endpoint) const + UnixEndpoint*& GetLink(UnixEndpoint* endpoint) const { return endpoint->HashTableLink(); } @@ -100,7 +100,7 @@ public: } private: - typedef OpenHashTable EndpointTable; + typedef BOpenHashTable EndpointTable; mutex fLock; EndpointTable fBoundEndpoints; diff --git a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h index 07c7e11f0f..fb1bc96d86 100644 --- a/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h +++ b/src/add-ons/kernel/network/protocols/unix/UnixEndpoint.h @@ -90,9 +90,9 @@ public: return fAddress; } - ::HashTableLink* HashTableLink() + UnixEndpoint*& HashTableLink() { - return &fAddressHashLink; + return fAddressHashLink; } private: @@ -112,7 +112,7 @@ private: private: mutex fLock; UnixAddress fAddress; - ::HashTableLink fAddressHashLink; + UnixEndpoint* fAddressHashLink; UnixEndpoint* fPeerEndpoint; UnixFifo* fReceiveFifo; unix_endpoint_state fState; diff --git a/src/apps/debuganalyzer/gui/SubWindow.h b/src/apps/debuganalyzer/gui/SubWindow.h index 50ed229890..45f405137c 100644 --- a/src/apps/debuganalyzer/gui/SubWindow.h +++ b/src/apps/debuganalyzer/gui/SubWindow.h @@ -34,7 +34,7 @@ private: }; -class SubWindow : public BWindow, public HashTableLink { +class SubWindow : public BWindow { public: SubWindow(SubWindowManager* manager, BRect frame, const char* title, @@ -50,6 +50,9 @@ public: protected: SubWindowManager* fSubWindowManager; SubWindowKey* fSubWindowKey; + +public: + SubWindow* fNext; }; diff --git a/src/apps/debuganalyzer/gui/SubWindowManager.h b/src/apps/debuganalyzer/gui/SubWindowManager.h index 39b26437ce..37252c6c7f 100644 --- a/src/apps/debuganalyzer/gui/SubWindowManager.h +++ b/src/apps/debuganalyzer/gui/SubWindowManager.h @@ -49,13 +49,13 @@ private: return key.Equals(value->GetSubWindowKey()); } - HashTableLink* GetLink(SubWindow* value) const + SubWindow*& GetLink(SubWindow* value) const { - return value; + return value->fNext; } }; - typedef OpenHashTable SubWindowTable; + typedef BOpenHashTable SubWindowTable; private: BLooper* fParent; diff --git a/src/apps/debuganalyzer/model_loader/ModelLoader.cpp b/src/apps/debuganalyzer/model_loader/ModelLoader.cpp index d0a5f874bb..de7e316f9f 100644 --- a/src/apps/debuganalyzer/model_loader/ModelLoader.cpp +++ b/src/apps/debuganalyzer/model_loader/ModelLoader.cpp @@ -130,7 +130,7 @@ ModelLoader::FinishLoading(bool success) { ThreadInfo* threadInfo = fThreads.Clear(true); while (threadInfo != NULL) { - ThreadInfo* nextInfo = threadInfo->fNext; + ThreadInfo* nextInfo = threadInfo->next; delete threadInfo; threadInfo = nextInfo; } diff --git a/src/apps/debuganalyzer/model_loader/ModelLoader.h b/src/apps/debuganalyzer/model_loader/ModelLoader.h index b4fe2f78ad..7342cdffbc 100644 --- a/src/apps/debuganalyzer/model_loader/ModelLoader.h +++ b/src/apps/debuganalyzer/model_loader/ModelLoader.h @@ -44,11 +44,12 @@ private: UNKNOWN }; - struct ThreadInfo : HashTableLink { + struct ThreadInfo { Model::Thread* thread; ScheduleState state; bigtime_t lastTime; Model::ThreadWaitObject* waitObject; + ThreadInfo* next; ThreadInfo(Model::Thread* thread); @@ -68,11 +69,11 @@ private: bool Compare(thread_id key, const ThreadInfo* value) const { return key == value->ID(); } - HashTableLink* GetLink(ThreadInfo* value) const - { return value; } + ThreadInfo*& GetLink(ThreadInfo* value) const + { return value->next; } }; - typedef OpenHashTable ThreadTable; + typedef BOpenHashTable ThreadTable; // shorthands for the longish structure names typedef system_profiler_thread_enqueued_in_run_queue diff --git a/src/apps/debugger/TeamDebugger.cpp b/src/apps/debugger/TeamDebugger.cpp index fcd7ffb4a1..b94e72445e 100644 --- a/src/apps/debugger/TeamDebugger.cpp +++ b/src/apps/debugger/TeamDebugger.cpp @@ -44,7 +44,7 @@ struct TeamDebugger::ImageHandler : public Referenceable, - public HashTableLink, private LocatableFile::Listener { + private LocatableFile::Listener { public: ImageHandler(TeamDebugger* teamDebugger, Image* image) : @@ -85,6 +85,9 @@ private: private: TeamDebugger* fTeamDebugger; Image* fImage; + +public: + ImageHandler* fNext; }; @@ -110,9 +113,9 @@ struct TeamDebugger::ImageHandlerHashDefinition { return value->ImageID() == key; } - HashTableLink* GetLink(ImageHandler* value) const + ImageHandler*& GetLink(ImageHandler* value) const { - return value; + return value->fNext; } }; diff --git a/src/apps/debugger/TeamDebugger.h b/src/apps/debugger/TeamDebugger.h index df9e39d1e1..09302e12c7 100644 --- a/src/apps/debugger/TeamDebugger.h +++ b/src/apps/debugger/TeamDebugger.h @@ -74,7 +74,7 @@ private: private: struct ImageHandler; struct ImageHandlerHashDefinition; - typedef OpenHashTable ImageHandlerTable; + typedef BOpenHashTable ImageHandlerTable; private: static status_t _DebugEventListenerEntry(void* data); diff --git a/src/apps/debugger/ThreadHandler.h b/src/apps/debugger/ThreadHandler.h index 6265ac37ab..fe8ad48dcc 100644 --- a/src/apps/debugger/ThreadHandler.h +++ b/src/apps/debugger/ThreadHandler.h @@ -22,8 +22,7 @@ class Statement; class Worker; -class ThreadHandler : public Referenceable, - public HashTableLink, private ImageDebugInfoProvider, +class ThreadHandler : public Referenceable, private ImageDebugInfoProvider, private BreakpointClient { public: ThreadHandler(Thread* thread, Worker* worker, @@ -98,6 +97,9 @@ private: target_addr_t fBreakpointAddress; target_addr_t fPreviousInstructionPointer; bool fSingleStepping; + +public: + ThreadHandler* fNext; }; @@ -120,13 +122,13 @@ struct ThreadHandlerHashDefinition { return value->ThreadID() == key; } - HashTableLink* GetLink(ThreadHandler* value) const + ThreadHandler*& GetLink(ThreadHandler* value) const { - return value; + return value->fNext; } }; -typedef OpenHashTable ThreadHandlerTable; +typedef BOpenHashTable ThreadHandlerTable; #endif // THREAD_HANDLER_H diff --git a/src/apps/debugger/Worker.cpp b/src/apps/debugger/Worker.cpp index 2d35f255b9..5616e934e9 100644 --- a/src/apps/debugger/Worker.cpp +++ b/src/apps/debugger/Worker.cpp @@ -241,7 +241,7 @@ Worker::ShutDown() // abort all jobs Job* job = fJobs.Clear(true); while (job != NULL) { - Job* nextJob = static_cast*>(job)->fNext; + Job* nextJob = job->fNext; _AbortJob(job, false); job = nextJob; diff --git a/src/apps/debugger/Worker.h b/src/apps/debugger/Worker.h index bef87421be..758153bd6d 100644 --- a/src/apps/debugger/Worker.h +++ b/src/apps/debugger/Worker.h @@ -75,8 +75,7 @@ public: typedef DoublyLinkedList JobList; -class Job : public Referenceable, public DoublyLinkedListLinkImpl, - public HashTableLink { +class Job : public Referenceable, public DoublyLinkedListLinkImpl { public: Job(); virtual ~Job(); @@ -119,6 +118,9 @@ private: JobList fDependentJobs; job_wait_status fWaitStatus; ListenerList fListeners; + +public: + Job* fNext; }; @@ -161,18 +163,18 @@ private: return HashKey(value->Key()); } - bool Compare(const JobKey& key, Job *value) const + bool Compare(const JobKey& key, Job* value) const { return value->Key() == key; } - HashTableLink* GetLink(Job* value) const + Job*& GetLink(Job* value) const { - return value; + return value->fNext; } }; - typedef OpenHashTable JobTable; + typedef BOpenHashTable JobTable; private: job_wait_status WaitForJob(Job* waitingJob, const JobKey& key); diff --git a/src/apps/debugger/debug_info/DwarfInterfaceFactory.cpp b/src/apps/debugger/debug_info/DwarfInterfaceFactory.cpp index 4918a5e24e..0957232e03 100644 --- a/src/apps/debugger/debug_info/DwarfInterfaceFactory.cpp +++ b/src/apps/debugger/debug_info/DwarfInterfaceFactory.cpp @@ -115,8 +115,7 @@ private: // #pragma mark - DwarfType -struct DwarfInterfaceFactory::DwarfType : virtual Type, - HashTableLink { +struct DwarfInterfaceFactory::DwarfType : virtual Type { public: DwarfType(const BString& name) : @@ -143,8 +142,11 @@ public: virtual DIEType* GetDIEType() const = 0; private: - BString fName; - uint64 fByteSize; + BString fName; + uint64 fByteSize; + +public: + DwarfType* fNext; }; @@ -487,9 +489,9 @@ struct DwarfInterfaceFactory::DwarfTypeHashDefinition { return key == value->GetDIEType(); } - HashTableLink* GetLink(DwarfType* value) const + DwarfType*& GetLink(DwarfType* value) const { - return value; + return value->fNext; } }; diff --git a/src/apps/debugger/debug_info/DwarfInterfaceFactory.h b/src/apps/debugger/debug_info/DwarfInterfaceFactory.h index 6e788a266b..82e7bfd8fe 100644 --- a/src/apps/debugger/debug_info/DwarfInterfaceFactory.h +++ b/src/apps/debugger/debug_info/DwarfInterfaceFactory.h @@ -72,7 +72,7 @@ private: struct DwarfArrayType; struct DwarfTypeHashDefinition; - typedef OpenHashTable TypeTable; + typedef BOpenHashTable TypeTable; private: status_t _CreateType(DIEType* typeEntry, diff --git a/src/apps/debugger/debug_info/Function.h b/src/apps/debugger/debug_info/Function.h index 252fa664d7..bfaee71026 100644 --- a/src/apps/debugger/debug_info/Function.h +++ b/src/apps/debugger/debug_info/Function.h @@ -14,7 +14,7 @@ class FileSourceCode; -class Function : public Referenceable, public HashTableLink { +class Function : public Referenceable { public: class Listener; @@ -69,6 +69,10 @@ private: function_source_state fSourceCodeState; ListenerList fListeners; int32 fNotificationsDisabled; + +public: + // BOpenHashTable support + Function* fNext; }; diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.cpp b/src/apps/debugger/debug_info/TeamDebugInfo.cpp index caaab88f6f..2342e08cf3 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.cpp +++ b/src/apps/debugger/debug_info/TeamDebugInfo.cpp @@ -72,9 +72,9 @@ struct TeamDebugInfo::FunctionHashDefinition { && key->Name() == value->Name(); } - HashTableLink* GetLink(Function* value) const + Function*& GetLink(Function* value) const { - return value; + return value->fNext; } }; @@ -82,7 +82,7 @@ struct TeamDebugInfo::FunctionHashDefinition { // #pragma mark - SourceFileEntry -struct TeamDebugInfo::SourceFileEntry : public HashTableLink { +struct TeamDebugInfo::SourceFileEntry { SourceFileEntry(LocatableFile* sourceFile) : fSourceFile(sourceFile), @@ -207,9 +207,12 @@ private: } private: - LocatableFile* fSourceFile; - FileSourceCode* fSourceCode; - FunctionList fFunctions; + LocatableFile* fSourceFile; + FileSourceCode* fSourceCode; + FunctionList fFunctions; + +public: + SourceFileEntry* fNext; }; @@ -235,9 +238,9 @@ struct TeamDebugInfo::SourceFileHashDefinition { return key == value->SourceFile(); } - HashTableLink* GetLink(SourceFileEntry* value) const + SourceFileEntry*& GetLink(SourceFileEntry* value) const { - return value; + return value->fNext; } }; diff --git a/src/apps/debugger/debug_info/TeamDebugInfo.h b/src/apps/debugger/debug_info/TeamDebugInfo.h index c1bf87c402..ea3ab63958 100644 --- a/src/apps/debugger/debug_info/TeamDebugInfo.h +++ b/src/apps/debugger/debug_info/TeamDebugInfo.h @@ -71,8 +71,8 @@ private: typedef BObjectList SpecificInfoList; typedef BObjectList ImageList; - typedef OpenHashTable FunctionTable; - typedef OpenHashTable SourceFileTable; + typedef BOpenHashTable FunctionTable; + typedef BOpenHashTable SourceFileTable; private: status_t _AddFunction(Function* function); diff --git a/src/apps/debugger/dwarf/AbbreviationTable.h b/src/apps/debugger/dwarf/AbbreviationTable.h index b3a2e9e171..8d27432751 100644 --- a/src/apps/debugger/dwarf/AbbreviationTable.h +++ b/src/apps/debugger/dwarf/AbbreviationTable.h @@ -12,10 +12,11 @@ #include "Dwarf.h" -struct AbbreviationTableEntry : HashTableLink { - uint32 code; - off_t offset; - off_t size; +struct AbbreviationTableEntry { + uint32 code; + off_t offset; + off_t size; + AbbreviationTableEntry* next; AbbreviationTableEntry(uint32 code, off_t offset, off_t size) : @@ -88,10 +89,9 @@ struct AbbreviationTableHashDefinition { return value->code == key; } - HashTableLink* GetLink( - AbbreviationTableEntry* value) const + AbbreviationTableEntry*& GetLink(AbbreviationTableEntry* value) const { - return value; + return value->next; } }; @@ -109,7 +109,7 @@ public: AbbreviationEntry& entry); private: - typedef OpenHashTable EntryTable; + typedef BOpenHashTable EntryTable; private: status_t _ParseAbbreviationEntry( diff --git a/src/apps/debugger/files/FileManager.cpp b/src/apps/debugger/files/FileManager.cpp index 5d7e5acb44..047b809848 100644 --- a/src/apps/debugger/files/FileManager.cpp +++ b/src/apps/debugger/files/FileManager.cpp @@ -92,9 +92,9 @@ struct FileManager::EntryHashDefinition { return EntryPath(value) == key; } - HashTableLink* GetLink(LocatableEntry* value) const + LocatableEntry*& GetLink(LocatableEntry* value) const { - return value; + return value->fNext; } }; @@ -459,12 +459,12 @@ private: // #pragma mark - SourceFileEntry -struct FileManager::SourceFileEntry : public SourceFileOwner, - public HashTableLink { +struct FileManager::SourceFileEntry : public SourceFileOwner { - FileManager* manager; - BString path; - SourceFile* file; + FileManager* manager; + BString path; + SourceFile* file; + SourceFileEntry* next; SourceFileEntry(FileManager* manager, const BString& path) : @@ -509,9 +509,9 @@ struct FileManager::SourceFileHashDefinition { return value->path == key; } - HashTableLink* GetLink(SourceFileEntry* value) const + SourceFileEntry*& GetLink(SourceFileEntry* value) const { - return value; + return value->next; } }; diff --git a/src/apps/debugger/files/FileManager.h b/src/apps/debugger/files/FileManager.h index 6ff7edf7ac..656ac98ecf 100644 --- a/src/apps/debugger/files/FileManager.h +++ b/src/apps/debugger/files/FileManager.h @@ -52,8 +52,8 @@ private: struct SourceFileEntry; struct SourceFileHashDefinition; - typedef OpenHashTable LocatableEntryTable; - typedef OpenHashTable SourceFileTable; + typedef BOpenHashTable LocatableEntryTable; + typedef BOpenHashTable SourceFileTable; friend struct SourceFileEntry; // for gcc 2 diff --git a/src/apps/debugger/files/LocatableEntry.h b/src/apps/debugger/files/LocatableEntry.h index a1f6f5fc71..c0a63423f2 100644 --- a/src/apps/debugger/files/LocatableEntry.h +++ b/src/apps/debugger/files/LocatableEntry.h @@ -35,8 +35,7 @@ public: class LocatableEntry : public Referenceable, - public DoublyLinkedListLinkImpl, - public HashTableLink { + public DoublyLinkedListLinkImpl { public: LocatableEntry(LocatableEntryOwner* owner, LocatableDirectory* parent); @@ -58,6 +57,9 @@ protected: LocatableEntryOwner* fOwner; LocatableDirectory* fParent; locatable_entry_state fState; + +public: + LocatableEntry* fNext; }; diff --git a/src/apps/debugger/model/StackFrameValues.cpp b/src/apps/debugger/model/StackFrameValues.cpp index 752f4cb2c2..113d4c8e41 100644 --- a/src/apps/debugger/model/StackFrameValues.cpp +++ b/src/apps/debugger/model/StackFrameValues.cpp @@ -35,8 +35,9 @@ struct StackFrameValues::Key { }; -struct StackFrameValues::ValueEntry : Key, HashTableLink { +struct StackFrameValues::ValueEntry : Key { BVariant value; + ValueEntry* next; ValueEntry(ObjectID* variable, TypeComponentPath* path) : @@ -73,9 +74,9 @@ struct StackFrameValues::ValueEntryHashDefinition { return key == *value; } - HashTableLink* GetLink(ValueEntry* value) const + ValueEntry*& GetLink(ValueEntry* value) const { - return value; + return value->next; } }; @@ -172,7 +173,7 @@ StackFrameValues::_Cleanup() ValueEntry* entry = fValues->Clear(true); while (entry != NULL) { - ValueEntry* next = entry->fNext; + ValueEntry* next = entry->next; delete entry; entry = next; } diff --git a/src/apps/debugger/model/StackFrameValues.h b/src/apps/debugger/model/StackFrameValues.h index e8de005c33..63edcb7f43 100644 --- a/src/apps/debugger/model/StackFrameValues.h +++ b/src/apps/debugger/model/StackFrameValues.h @@ -43,7 +43,7 @@ private: struct ValueEntry; struct ValueEntryHashDefinition; - typedef OpenHashTable ValueTable; + typedef BOpenHashTable ValueTable; private: StackFrameValues& operator=(const StackFrameValues& other); diff --git a/src/servers/app/FontCacheEntry.cpp b/src/servers/app/FontCacheEntry.cpp index 4bbe53f10e..d24fe2b3e5 100644 --- a/src/servers/app/FontCacheEntry.cpp +++ b/src/servers/app/FontCacheEntry.cpp @@ -32,6 +32,8 @@ #include +#include + #include #include "utf8_functions.h" @@ -52,7 +54,7 @@ public: { GlyphCache* glyph = fGlyphTable.Clear(true); while (glyph != NULL) { - GlyphCache* next = glyph->fNext; + GlyphCache* next = glyph->hash_link; delete glyph; glyph = next; } @@ -111,13 +113,13 @@ private: return value->glyph_index == key; } - HashTableLink* GetLink(GlyphCache* value) const + GlyphCache*& GetLink(GlyphCache* value) const { - return value; + return value->hash_link; } }; - typedef OpenHashTable GlyphTable; + typedef BOpenHashTable GlyphTable; GlyphTable fGlyphTable; }; diff --git a/src/servers/app/FontCacheEntry.h b/src/servers/app/FontCacheEntry.h index f2e8bddba6..73f4c26ecf 100644 --- a/src/servers/app/FontCacheEntry.h +++ b/src/servers/app/FontCacheEntry.h @@ -33,8 +33,6 @@ #include #include -#include - #include "ServerFont.h" #include "FontEngine.h" #include "MultiLocker.h" @@ -42,7 +40,7 @@ #include "Transformable.h" -struct GlyphCache : public HashTableLink { +struct GlyphCache { GlyphCache(uint32 glyphIndex, uint32 dataSize, glyph_data_type dataType, const agg::rect_i& bounds, float advanceX, float advanceY, float insetLeft, float insetRight) @@ -73,6 +71,8 @@ struct GlyphCache : public HashTableLink { float advance_y; float inset_left; float inset_right; + + GlyphCache* hash_link; }; class FontCache; diff --git a/src/system/kernel/condition_variable.cpp b/src/system/kernel/condition_variable.cpp index 1975ea6150..4777ad2edd 100644 --- a/src/system/kernel/condition_variable.cpp +++ b/src/system/kernel/condition_variable.cpp @@ -36,11 +36,11 @@ struct ConditionVariableHashDefinition { { return (size_t)variable->fObject; } bool Compare(const void* key, ConditionVariable* variable) const { return key == variable->fObject; } - HashTableLink* GetLink(ConditionVariable* variable) const - { return variable; } + ConditionVariable*& GetLink(ConditionVariable* variable) const + { return variable->fNext; } }; -typedef OpenHashTable ConditionVariableHash; +typedef BOpenHashTable ConditionVariableHash; static ConditionVariableHash sConditionVariableHash; static spinlock sConditionVariablesLock; diff --git a/src/system/kernel/debug/system_profiler.cpp b/src/system/kernel/debug/system_profiler.cpp index ca5ba13e24..5fae6eff8a 100644 --- a/src/system/kernel/debug/system_profiler.cpp +++ b/src/system/kernel/debug/system_profiler.cpp @@ -126,7 +126,8 @@ private: }; struct WaitObject : DoublyLinkedListLinkImpl, - HashTableLink, WaitObjectKey { + WaitObjectKey { + struct WaitObject* hash_link; }; struct WaitObjectTableDefinition { @@ -150,14 +151,14 @@ private: && value->object == key.object; } - HashTableLink* GetLink(WaitObject* value) const + WaitObject*& GetLink(WaitObject* value) const { - return value; + return value->hash_link; } }; typedef DoublyLinkedList WaitObjectList; - typedef OpenHashTable WaitObjectTable; + typedef BOpenHashTable WaitObjectTable; private: spinlock fLock; diff --git a/src/system/kernel/device_manager/IOScheduler.cpp b/src/system/kernel/device_manager/IOScheduler.cpp index 045b12654a..f961c21745 100644 --- a/src/system/kernel/device_manager/IOScheduler.cpp +++ b/src/system/kernel/device_manager/IOScheduler.cpp @@ -87,12 +87,12 @@ struct IOScheduler::RequestOwnerHashDefinition { size_t Hash(const IORequestOwner* value) const { return value->thread; } bool Compare(thread_id key, const IORequestOwner* value) const { return value->thread == key; } - HashTableLink* GetLink(IORequestOwner* value) const - { return value; } + IORequestOwner*& GetLink(IORequestOwner* value) const + { return value->hash_link; } }; struct IOScheduler::RequestOwnerHashTable - : OpenHashTable { + : BOpenHashTable { }; diff --git a/src/system/kernel/device_manager/IOScheduler.h b/src/system/kernel/device_manager/IOScheduler.h index 96bc9eac58..09ad2e1b7e 100644 --- a/src/system/kernel/device_manager/IOScheduler.h +++ b/src/system/kernel/device_manager/IOScheduler.h @@ -27,14 +27,14 @@ public: typedef status_t (*io_callback)(void* data, io_operation* operation); -struct IORequestOwner : DoublyLinkedListLinkImpl, - HashTableLink { +struct IORequestOwner : DoublyLinkedListLinkImpl { team_id team; thread_id thread; int32 priority; IORequestList requests; IORequestList completed_requests; IOOperationList operations; + IORequestOwner* hash_link; bool IsActive() const { return !requests.IsEmpty() diff --git a/src/system/kernel/device_manager/legacy_drivers.cpp b/src/system/kernel/device_manager/legacy_drivers.cpp index c1e6769d80..3ffd1f6cbd 100644 --- a/src/system/kernel/device_manager/legacy_drivers.cpp +++ b/src/system/kernel/device_manager/legacy_drivers.cpp @@ -120,8 +120,8 @@ struct driver_entry : public DoublyLinkedListLinkImpl { typedef DoublyLinkedList DriverEntryList; struct directory_node_entry { - HashTableLink link; - ino_t node; + directory_node_entry* hash_link; + ino_t node; }; struct DirectoryNodeHashDefinition { @@ -134,15 +134,15 @@ struct DirectoryNodeHashDefinition { { return _Hash(entry->node); } bool Compare(ino_t* key, directory_node_entry* entry) const { return *key == entry->node; } - HashTableLink* + directory_node_entry*& GetLink(directory_node_entry* entry) const - { return &entry->link; } + { return entry->hash_link; } uint32 _Hash(ino_t node) const { return (uint32)(node >> 32) + (uint32)node; } }; -typedef OpenHashTable DirectoryNodeHash; +typedef BOpenHashTable DirectoryNodeHash; class DirectoryIterator { public: diff --git a/src/system/kernel/fs/node_monitor.cpp b/src/system/kernel/fs/node_monitor.cpp index b570af82ad..23d74aa07e 100644 --- a/src/system/kernel/fs/node_monitor.cpp +++ b/src/system/kernel/fs/node_monitor.cpp @@ -54,7 +54,7 @@ typedef DoublyLinkedList > MonitorListenerList; struct node_monitor { - HashTableLink link; + node_monitor* hash_link; dev_t device; ino_t node; MonitorListenerList listeners; @@ -164,9 +164,8 @@ class NodeMonitorService : public NotificationService { && key->node == monitor->node; } - HashTableLink* GetLink( - node_monitor* monitor) const - { return &monitor->link; } + node_monitor*& GetLink(node_monitor* monitor) const + { return monitor->hash_link; } uint32 _Hash(dev_t device, ino_t node) const { @@ -174,7 +173,7 @@ class NodeMonitorService : public NotificationService { } }; - typedef OpenHashTable MonitorHash; + typedef BOpenHashTable MonitorHash; MonitorHash fMonitors; recursive_lock fRecursiveLock; }; diff --git a/src/system/kernel/fs/vfs.cpp b/src/system/kernel/fs/vfs.cpp index 5c5b20cbcd..852d302129 100644 --- a/src/system/kernel/fs/vfs.cpp +++ b/src/system/kernel/fs/vfs.cpp @@ -123,11 +123,11 @@ struct EntryCacheKey { }; -struct EntryCacheEntry : HashTableLink, - DoublyLinkedListLinkImpl { - ino_t node_id; - ino_t dir_id; - char name[1]; +struct EntryCacheEntry : DoublyLinkedListLinkImpl { + EntryCacheEntry* hash_link; + ino_t node_id; + ino_t dir_id; + char name[1]; }; @@ -153,9 +153,9 @@ struct EntryCacheHashDefinition { && strcmp(value->name, key.name) == 0; } - HashTableLink* GetLink(EntryCacheEntry* value) const + EntryCacheEntry*& GetLink(EntryCacheEntry* value) const { - return value; + return value->hash_link; } }; @@ -251,7 +251,7 @@ public: } private: - typedef OpenHashTable EntryTable; + typedef BOpenHashTable EntryTable; typedef DoublyLinkedList EntryList; mutex fLock; diff --git a/src/system/kernel/image.cpp b/src/system/kernel/image.cpp index a6208ab504..ebf2398b2b 100644 --- a/src/system/kernel/image.cpp +++ b/src/system/kernel/image.cpp @@ -41,11 +41,11 @@ struct ImageTableDefinition { size_t Hash(struct image* value) const { return value->info.id; } bool Compare(image_id key, struct image* value) const { return value->info.id == key; } - HashTableLink* GetLink(struct image* value) const - { return &value->hash_link; } + struct image*& GetLink(struct image* value) const + { return value->hash_link; } }; -typedef OpenHashTable ImageTable; +typedef BOpenHashTable ImageTable; class ImageNotificationService : public DefaultNotificationService { diff --git a/src/system/kernel/module.cpp b/src/system/kernel/module.cpp index c0f9223b9a..8b321b7b6c 100644 --- a/src/system/kernel/module.cpp +++ b/src/system/kernel/module.cpp @@ -154,7 +154,7 @@ struct hash_entry : entry { free((char*)path); } - HashTableLink link; + hash_entry* hash_link; const char* path; }; @@ -164,8 +164,8 @@ struct NodeHashDefinition { size_t Hash(ValueType* entry) const { return HashKey(entry); } - HashTableLink* GetLink(ValueType* entry) const - { return &entry->link; } + ValueType*& GetLink(ValueType* entry) const + { return entry->hash_link; } size_t HashKey(KeyType key) const { @@ -179,7 +179,7 @@ struct NodeHashDefinition { } }; -typedef OpenHashTable NodeHash; +typedef BOpenHashTable NodeHash; struct module_listener : DoublyLinkedListLinkImpl { ~module_listener() diff --git a/src/system/kernel/posix/realtime_sem.cpp b/src/system/kernel/posix/realtime_sem.cpp index 0eb3a1edac..ec16dda467 100644 --- a/src/system/kernel/posix/realtime_sem.cpp +++ b/src/system/kernel/posix/realtime_sem.cpp @@ -134,19 +134,19 @@ public: ReleaseReference(); } - HashTableLink* HashLink() + NamedSem*& HashLink() { - return &fHashLink; + return fHashLink; } private: - char* fName; - vint32 fRefCount; - uid_t fUID; - gid_t fGID; - mode_t fPermissions; + char* fName; + vint32 fRefCount; + uid_t fUID; + gid_t fGID; + mode_t fPermissions; - ::HashTableLink fHashLink; + NamedSem* fHashLink; }; @@ -238,13 +238,13 @@ public: delete this; } - HashTableLink* HashLink() + UnnamedSharedSem*& HashLink() { - return &fHashLink; + return fHashLink; } private: - ::HashTableLink fHashLink; + UnnamedSharedSem* fHashLink; }; @@ -267,7 +267,7 @@ struct NamedSemHashDefinition { return strcmp(key, semaphore->Name()) == 0; } - HashTableLink* GetLink(NamedSem* semaphore) const + NamedSem*& GetLink(NamedSem* semaphore) const { return semaphore->HashLink(); } @@ -293,7 +293,7 @@ struct UnnamedSemHashDefinition { return key == semaphore->SemaphoreID(); } - HashTableLink* GetLink(UnnamedSharedSem* semaphore) const + UnnamedSharedSem*& GetLink(UnnamedSharedSem* semaphore) const { return semaphore->HashLink(); } @@ -442,8 +442,8 @@ public: } private: - typedef OpenHashTable NamedSemTable; - typedef OpenHashTable UnnamedSemTable; + typedef BOpenHashTable NamedSemTable; + typedef BOpenHashTable UnnamedSemTable; mutex fLock; NamedSemTable fNamedSemaphores; @@ -502,17 +502,17 @@ public: return clone; } - HashTableLink* HashLink() + TeamSemInfo*& HashLink() { - return &fHashLink; + return fHashLink; } private: - SemInfo* fSemaphore; - sem_t* fUserSemaphore; - int32 fOpenCount; + SemInfo* fSemaphore; + sem_t* fUserSemaphore; + int32 fOpenCount; - ::HashTableLink fHashLink; + TeamSemInfo* fHashLink; }; @@ -535,7 +535,7 @@ struct TeamSemHashDefinition { return key == semaphore->ID(); } - HashTableLink* GetLink(TeamSemInfo* semaphore) const + TeamSemInfo*& GetLink(TeamSemInfo* semaphore) const { return semaphore->HashLink(); } @@ -799,7 +799,7 @@ private: } private: - typedef OpenHashTable SemTable; + typedef BOpenHashTable SemTable; mutex fLock; SemTable fSemaphores; diff --git a/src/system/kernel/posix/xsi_message_queue.cpp b/src/system/kernel/posix/xsi_message_queue.cpp index baabfb3148..a20b9407f2 100644 --- a/src/system/kernel/posix/xsi_message_queue.cpp +++ b/src/system/kernel/posix/xsi_message_queue.cpp @@ -266,9 +266,9 @@ public: } } - HashTableLink* Link() + XsiMessageQueue*& Link() { - return &fLink; + return fLink; } private: @@ -284,7 +284,7 @@ private: ThreadQueue fWaitingToReceive; ThreadQueue fWaitingToSend; - ::HashTableLink fLink; + XsiMessageQueue* fLink; }; @@ -308,7 +308,7 @@ struct MessageQueueHashTableDefinition { return (int)key == (int)variable->ID(); } - HashTableLink* GetLink(XsiMessageQueue *variable) const + XsiMessageQueue*& GetLink(XsiMessageQueue *variable) const { return variable->Link(); } @@ -339,15 +339,15 @@ public: fMessageQueueId = messageQueue->ID(); } - HashTableLink* Link() + Ipc*& Link() { - return &fLink; + return fLink; } private: key_t fKey; int fMessageQueueId; - HashTableLink fLink; + Ipc* fLink; }; @@ -370,7 +370,7 @@ struct IpcHashTableDefinition { return (key_t)key == (key_t)variable->Key(); } - HashTableLink* GetLink(Ipc *variable) const + Ipc*& GetLink(Ipc *variable) const { return variable->Link(); } @@ -379,8 +379,8 @@ struct IpcHashTableDefinition { // Arbitrary limits #define MAX_XSI_MESSAGE 4096 #define MAX_XSI_MESSAGE_QUEUE 1024 -static OpenHashTable sIpcHashTable; -static OpenHashTable sMessageQueueHashTable; +static BOpenHashTable sIpcHashTable; +static BOpenHashTable sMessageQueueHashTable; static mutex sIpcLock; static mutex sXsiMessageQueueLock; diff --git a/src/system/kernel/posix/xsi_semaphore.cpp b/src/system/kernel/posix/xsi_semaphore.cpp index 4a840f3599..860efc8d8c 100644 --- a/src/system/kernel/posix/xsi_semaphore.cpp +++ b/src/system/kernel/posix/xsi_semaphore.cpp @@ -515,9 +515,9 @@ public: return fUndoList; } - HashTableLink* Link() + XsiSemaphoreSet*& Link() { - return &fLink; + return fLink; } private: @@ -532,7 +532,7 @@ private: uint32 fSequenceNumber; // used as a second id UndoList fUndoList; // undo list requests - ::HashTableLink fLink; + XsiSemaphoreSet* fLink; }; // Xsi semaphore set hash table @@ -555,7 +555,7 @@ struct SemaphoreHashTableDefinition { return (int)key == (int)variable->ID(); } - HashTableLink* GetLink(XsiSemaphoreSet *variable) const + XsiSemaphoreSet*& GetLink(XsiSemaphoreSet *variable) const { return variable->Link(); } @@ -586,15 +586,15 @@ public: fSemaphoreSetId = semaphoreSet->ID(); } - HashTableLink* Link() + Ipc*& Link() { - return &fLink; + return fLink; } private: key_t fKey; int fSemaphoreSetId; - HashTableLink fLink; + Ipc* fLink; }; @@ -617,7 +617,7 @@ struct IpcHashTableDefinition { return (key_t)key == (key_t)variable->Key(); } - HashTableLink* GetLink(Ipc *variable) const + Ipc*& GetLink(Ipc *variable) const { return variable->Link(); } @@ -626,8 +626,8 @@ struct IpcHashTableDefinition { // Arbitrary limit #define MAX_XSI_SEMAPHORE 4096 #define MAX_XSI_SEMAPHORE_SET 2048 -static OpenHashTable sIpcHashTable; -static OpenHashTable sSemaphoreHashTable; +static BOpenHashTable sIpcHashTable; +static BOpenHashTable sSemaphoreHashTable; static mutex sIpcLock; static mutex sXsiSemaphoreSetLock; diff --git a/src/system/kernel/slab/Slab.cpp b/src/system/kernel/slab/Slab.cpp index 7ce3d78c23..be4e810481 100644 --- a/src/system/kernel/slab/Slab.cpp +++ b/src/system/kernel/slab/Slab.cpp @@ -122,9 +122,10 @@ struct SmallObjectCache : object_cache { struct HashedObjectCache : object_cache { - struct Link : HashTableLink { - const void *buffer; - slab *parent; + struct Link { + const void* buffer; + slab* parent; + Link* next; }; struct Definition { @@ -144,12 +145,12 @@ struct HashedObjectCache : object_cache { size_t Hash(Link *value) const { return HashKey(value->buffer); } bool Compare(const void *key, Link *value) const { return value->buffer == key; } - HashTableLink *GetLink(Link *value) const { return value; } + Link*& GetLink(Link *value) const { return value->next; } HashedObjectCache *parent; }; - typedef OpenHashTable HashTable; + typedef BOpenHashTable HashTable; HashedObjectCache() : hash_table(this) {} diff --git a/src/system/kernel/vm/VMAnonymousCache.cpp b/src/system/kernel/vm/VMAnonymousCache.cpp index d40c11cd85..0db6e475cd 100644 --- a/src/system/kernel/vm/VMAnonymousCache.cpp +++ b/src/system/kernel/vm/VMAnonymousCache.cpp @@ -80,7 +80,8 @@ struct swap_hash_key { // Each swap block contains swap address information for // SWAP_BLOCK_PAGES continuous pages from the same cache -struct swap_block : HashTableLink { +struct swap_block { + swap_block* hash_link; swap_hash_key key; uint32 used; swap_addr_t swap_slots[SWAP_BLOCK_PAGES]; @@ -111,13 +112,13 @@ struct SwapHashTableDefinition { && key.cache == value->key.cache; } - HashTableLink *GetLink(swap_block *value) const + swap_block*& GetLink(swap_block *value) const { - return value; + return value->hash_link; } }; -typedef OpenHashTable SwapHashTable; +typedef BOpenHashTable SwapHashTable; typedef DoublyLinkedList SwapFileList; static SwapHashTable sSwapHashTable; diff --git a/src/tests/add-ons/kernel/kernelland_emu/condition_variable.cpp b/src/tests/add-ons/kernel/kernelland_emu/condition_variable.cpp index 7d14cb17e0..a724b97453 100644 --- a/src/tests/add-ons/kernel/kernelland_emu/condition_variable.cpp +++ b/src/tests/add-ons/kernel/kernelland_emu/condition_variable.cpp @@ -41,11 +41,11 @@ struct ConditionVariableHashDefinition { { return (size_t)variable->fObject; } bool Compare(const void* key, ConditionVariable* variable) const { return key == variable->fObject; } - HashTableLink* GetLink(ConditionVariable* variable) const - { return variable; } + ConditionVariable*& GetLink(ConditionVariable* variable) const + { return variable->fNext; } }; -typedef OpenHashTable ConditionVariableHash; +typedef BOpenHashTable ConditionVariableHash; static ConditionVariableHash sConditionVariableHash; static mutex sConditionVariablesLock = MUTEX_INITIALIZER("condition variables");