From b8c0d6618e66115f951cd2e5191d067711422ebb Mon Sep 17 00:00:00 2001 From: Hugo Santos Date: Thu, 26 Apr 2007 06:32:25 +0000 Subject: [PATCH] gcc 4 compilation fixes. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20835 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/slab/Base.h | 5 +++++ headers/private/kernel/slab/HashStrategy.h | 11 +++++++---- headers/private/kernel/slab/MergedStrategy.h | 10 +++++++--- headers/private/kernel/slab/Slab.h | 9 ++------- headers/private/kernel/slab/Strategy.h | 2 ++ 5 files changed, 23 insertions(+), 14 deletions(-) diff --git a/headers/private/kernel/slab/Base.h b/headers/private/kernel/slab/Base.h index 3026d85009..1631a4035c 100644 --- a/headers/private/kernel/slab/Base.h +++ b/headers/private/kernel/slab/Base.h @@ -20,6 +20,11 @@ extern "C" { #endif +enum { + CACHE_DONT_SLEEP = 1 << 0, + CACHE_ALIGN_TO_TOTAL = 1 << 16, +}; + static const int kMinimumSlabItems = 32; typedef void (*base_cache_constructor)(void *cookie, void *object); diff --git a/headers/private/kernel/slab/HashStrategy.h b/headers/private/kernel/slab/HashStrategy.h index 7c44b00b8d..cdd665f8bc 100644 --- a/headers/private/kernel/slab/HashStrategy.h +++ b/headers/private/kernel/slab/HashStrategy.h @@ -98,6 +98,7 @@ protected: template struct HashCacheStrategy : BaseCacheStrategy, BaseHashCacheStrategy { + typedef typename BaseCacheStrategy::BaseSlab BaseSlab; typedef typename BaseCacheStrategy::Slab Slab; typedef HashCacheStrategy Strategy; @@ -119,14 +120,14 @@ struct HashCacheStrategy : BaseCacheStrategy, BaseHashCacheStrategy { return NULL; void *pages; - if (Backend::AllocatePages(fParent, &slab->id, &pages, byteCount, + if (Backend::AllocatePages(Parent(), &slab->id, &pages, byteCount, flags) < B_OK) { fSlabCache.Free(slab); return NULL; } if (_PrepareSlab(slab, pages, byteCount, flags) < B_OK) { - Backend::FreePages(fParent, slab->id); + Backend::FreePages(Parent(), slab->id); fSlabCache.Free(slab); return NULL; } @@ -150,12 +151,14 @@ private: return BaseCacheStrategy::SlabSize(0); } + base_cache *Parent() const { return BaseCacheStrategy::Parent(); } + status_t _PrepareSlab(Slab *slab, void *pages, size_t byteCount, uint32_t flags) { uint8_t *data = (uint8_t *)pages; for (uint8_t *it = data; - it < (data + byteCount); it += fParent->object_size) { + it < (data + byteCount); it += Parent()->object_size) { Link *link = fLinkCache.Alloc(flags); if (link == NULL) { @@ -178,7 +181,7 @@ private: void _ClearSlabRange(uint8_t *data, uint8_t *end) { - for (uint8_t *it = data; it < end; it += fParent->object_size) { + for (uint8_t *it = data; it < end; it += Parent()->object_size) { Link *link = _Linkage(it); fHashTable.Remove(link); fLinkCache.Free(link); diff --git a/headers/private/kernel/slab/MergedStrategy.h b/headers/private/kernel/slab/MergedStrategy.h index 339b29cb9e..33cd84c289 100644 --- a/headers/private/kernel/slab/MergedStrategy.h +++ b/headers/private/kernel/slab/MergedStrategy.h @@ -9,6 +9,7 @@ #ifndef _SLAB_MERGED_STRATEGY_H_ #define _SLAB_MERGED_STRATEGY_H_ +#include #include @@ -29,6 +30,7 @@ namespace Private { template class MergedLinkCacheStrategy : public BaseCacheStrategy { public: + typedef typename BaseCacheStrategy::BaseSlab BaseSlab; typedef typename BaseCacheStrategy::Slab Slab; typedef cache_object_link Link; @@ -42,7 +44,7 @@ public: void *Object(Link *link) const { - return ((uint8_t *)link) - (fParent->object_size - sizeof(Link)); + return ((uint8_t *)link) - (Parent()->object_size - sizeof(Link)); } CacheObjectInfo ObjectInformation(void *object) const @@ -60,7 +62,7 @@ public: // in order to save a pointer per object or a hash table to // map objects to slabs we required this set of pages to be // aligned in a (pageCount * PAGE_SIZE) boundary. - if (Backend::AllocatePages(fParent, &id, &pages, byteCount, + if (Backend::AllocatePages(Parent(), &id, &pages, byteCount, CACHE_ALIGN_TO_TOTAL | flags) < B_OK) return NULL; @@ -84,10 +86,12 @@ private: return byteCount; } + base_cache *Parent() const { return BaseCacheStrategy::Parent(); } + Link *_Linkage(void *object) const { return (Link *)(((uint8_t *)object) - + (fParent->object_size - sizeof(Link))); + + (Parent()->object_size - sizeof(Link))); } Slab *_SlabInPages(const void *pages) const diff --git a/headers/private/kernel/slab/Slab.h b/headers/private/kernel/slab/Slab.h index e5d52b8886..36b56540b6 100644 --- a/headers/private/kernel/slab/Slab.h +++ b/headers/private/kernel/slab/Slab.h @@ -9,11 +9,11 @@ #ifndef _SLAB_SLAB_H_ #define _SLAB_SLAB_H_ -#ifdef __cplusplus +#include +#ifdef __cplusplus #include #include -#include #include #include #include @@ -22,11 +22,6 @@ extern "C" { #endif -enum { - CACHE_DONT_SLEEP = 1 << 0, - CACHE_ALIGN_TO_TOTAL = 1 << 16, -}; - typedef void *object_cache_t; diff --git a/headers/private/kernel/slab/Strategy.h b/headers/private/kernel/slab/Strategy.h index b0e26262f1..ca01cb67ee 100644 --- a/headers/private/kernel/slab/Strategy.h +++ b/headers/private/kernel/slab/Strategy.h @@ -47,6 +47,8 @@ protected: Backend::FreePages(fParent, ((Slab *)slab)->id); } + base_cache *Parent() const { return fParent; } + base_cache *fParent; };