gcc 4 compilation fixes.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@20835 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Hugo Santos
2007-04-26 06:32:25 +00:00
parent 457b03ecb4
commit b8c0d6618e
5 changed files with 23 additions and 14 deletions
+5
View File
@@ -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);
+7 -4
View File
@@ -98,6 +98,7 @@ protected:
template<typename Backend>
struct HashCacheStrategy : BaseCacheStrategy<Backend>, BaseHashCacheStrategy {
typedef typename BaseCacheStrategy<Backend>::BaseSlab BaseSlab;
typedef typename BaseCacheStrategy<Backend>::Slab Slab;
typedef HashCacheStrategy<Backend> Strategy;
@@ -119,14 +120,14 @@ struct HashCacheStrategy : BaseCacheStrategy<Backend>, 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<Backend>::SlabSize(0);
}
base_cache *Parent() const { return BaseCacheStrategy<Backend>::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);
+7 -3
View File
@@ -9,6 +9,7 @@
#ifndef _SLAB_MERGED_STRATEGY_H_
#define _SLAB_MERGED_STRATEGY_H_
#include <slab/Base.h>
#include <slab/Strategy.h>
@@ -29,6 +30,7 @@ namespace Private {
template<typename Backend>
class MergedLinkCacheStrategy : public BaseCacheStrategy<Backend> {
public:
typedef typename BaseCacheStrategy<Backend>::BaseSlab BaseSlab;
typedef typename BaseCacheStrategy<Backend>::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<Backend>::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
+2 -7
View File
@@ -9,11 +9,11 @@
#ifndef _SLAB_SLAB_H_
#define _SLAB_SLAB_H_
#ifdef __cplusplus
#include <slab/Depot.h>
#ifdef __cplusplus
#include <slab/Backend.h>
#include <slab/Base.h>
#include <slab/Depot.h>
#include <slab/MergedStrategy.h>
#include <slab/HashStrategy.h>
#include <slab/Utilities.h>
@@ -22,11 +22,6 @@
extern "C" {
#endif
enum {
CACHE_DONT_SLEEP = 1 << 0,
CACHE_ALIGN_TO_TOTAL = 1 << 16,
};
typedef void *object_cache_t;
+2
View File
@@ -47,6 +47,8 @@ protected:
Backend::FreePages(fParent, ((Slab *)slab)->id);
}
base_cache *Parent() const { return fParent; }
base_cache *fParent;
};