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:
@@ -20,6 +20,11 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum {
|
||||||
|
CACHE_DONT_SLEEP = 1 << 0,
|
||||||
|
CACHE_ALIGN_TO_TOTAL = 1 << 16,
|
||||||
|
};
|
||||||
|
|
||||||
static const int kMinimumSlabItems = 32;
|
static const int kMinimumSlabItems = 32;
|
||||||
|
|
||||||
typedef void (*base_cache_constructor)(void *cookie, void *object);
|
typedef void (*base_cache_constructor)(void *cookie, void *object);
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ protected:
|
|||||||
|
|
||||||
template<typename Backend>
|
template<typename Backend>
|
||||||
struct HashCacheStrategy : BaseCacheStrategy<Backend>, BaseHashCacheStrategy {
|
struct HashCacheStrategy : BaseCacheStrategy<Backend>, BaseHashCacheStrategy {
|
||||||
|
typedef typename BaseCacheStrategy<Backend>::BaseSlab BaseSlab;
|
||||||
typedef typename BaseCacheStrategy<Backend>::Slab Slab;
|
typedef typename BaseCacheStrategy<Backend>::Slab Slab;
|
||||||
typedef HashCacheStrategy<Backend> Strategy;
|
typedef HashCacheStrategy<Backend> Strategy;
|
||||||
|
|
||||||
@@ -119,14 +120,14 @@ struct HashCacheStrategy : BaseCacheStrategy<Backend>, BaseHashCacheStrategy {
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
void *pages;
|
void *pages;
|
||||||
if (Backend::AllocatePages(fParent, &slab->id, &pages, byteCount,
|
if (Backend::AllocatePages(Parent(), &slab->id, &pages, byteCount,
|
||||||
flags) < B_OK) {
|
flags) < B_OK) {
|
||||||
fSlabCache.Free(slab);
|
fSlabCache.Free(slab);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_PrepareSlab(slab, pages, byteCount, flags) < B_OK) {
|
if (_PrepareSlab(slab, pages, byteCount, flags) < B_OK) {
|
||||||
Backend::FreePages(fParent, slab->id);
|
Backend::FreePages(Parent(), slab->id);
|
||||||
fSlabCache.Free(slab);
|
fSlabCache.Free(slab);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -150,12 +151,14 @@ private:
|
|||||||
return BaseCacheStrategy<Backend>::SlabSize(0);
|
return BaseCacheStrategy<Backend>::SlabSize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base_cache *Parent() const { return BaseCacheStrategy<Backend>::Parent(); }
|
||||||
|
|
||||||
status_t _PrepareSlab(Slab *slab, void *pages, size_t byteCount,
|
status_t _PrepareSlab(Slab *slab, void *pages, size_t byteCount,
|
||||||
uint32_t flags)
|
uint32_t flags)
|
||||||
{
|
{
|
||||||
uint8_t *data = (uint8_t *)pages;
|
uint8_t *data = (uint8_t *)pages;
|
||||||
for (uint8_t *it = data;
|
for (uint8_t *it = data;
|
||||||
it < (data + byteCount); it += fParent->object_size) {
|
it < (data + byteCount); it += Parent()->object_size) {
|
||||||
Link *link = fLinkCache.Alloc(flags);
|
Link *link = fLinkCache.Alloc(flags);
|
||||||
|
|
||||||
if (link == NULL) {
|
if (link == NULL) {
|
||||||
@@ -178,7 +181,7 @@ private:
|
|||||||
|
|
||||||
void _ClearSlabRange(uint8_t *data, uint8_t *end)
|
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);
|
Link *link = _Linkage(it);
|
||||||
fHashTable.Remove(link);
|
fHashTable.Remove(link);
|
||||||
fLinkCache.Free(link);
|
fLinkCache.Free(link);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#ifndef _SLAB_MERGED_STRATEGY_H_
|
#ifndef _SLAB_MERGED_STRATEGY_H_
|
||||||
#define _SLAB_MERGED_STRATEGY_H_
|
#define _SLAB_MERGED_STRATEGY_H_
|
||||||
|
|
||||||
|
#include <slab/Base.h>
|
||||||
#include <slab/Strategy.h>
|
#include <slab/Strategy.h>
|
||||||
|
|
||||||
|
|
||||||
@@ -29,6 +30,7 @@ namespace Private {
|
|||||||
template<typename Backend>
|
template<typename Backend>
|
||||||
class MergedLinkCacheStrategy : public BaseCacheStrategy<Backend> {
|
class MergedLinkCacheStrategy : public BaseCacheStrategy<Backend> {
|
||||||
public:
|
public:
|
||||||
|
typedef typename BaseCacheStrategy<Backend>::BaseSlab BaseSlab;
|
||||||
typedef typename BaseCacheStrategy<Backend>::Slab Slab;
|
typedef typename BaseCacheStrategy<Backend>::Slab Slab;
|
||||||
typedef cache_object_link Link;
|
typedef cache_object_link Link;
|
||||||
|
|
||||||
@@ -42,7 +44,7 @@ public:
|
|||||||
|
|
||||||
void *Object(Link *link) const
|
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
|
CacheObjectInfo ObjectInformation(void *object) const
|
||||||
@@ -60,7 +62,7 @@ public:
|
|||||||
// in order to save a pointer per object or a hash table to
|
// 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
|
// map objects to slabs we required this set of pages to be
|
||||||
// aligned in a (pageCount * PAGE_SIZE) boundary.
|
// 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)
|
CACHE_ALIGN_TO_TOTAL | flags) < B_OK)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -84,10 +86,12 @@ private:
|
|||||||
return byteCount;
|
return byteCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base_cache *Parent() const { return BaseCacheStrategy<Backend>::Parent(); }
|
||||||
|
|
||||||
Link *_Linkage(void *object) const
|
Link *_Linkage(void *object) const
|
||||||
{
|
{
|
||||||
return (Link *)(((uint8_t *)object)
|
return (Link *)(((uint8_t *)object)
|
||||||
+ (fParent->object_size - sizeof(Link)));
|
+ (Parent()->object_size - sizeof(Link)));
|
||||||
}
|
}
|
||||||
|
|
||||||
Slab *_SlabInPages(const void *pages) const
|
Slab *_SlabInPages(const void *pages) const
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
#ifndef _SLAB_SLAB_H_
|
#ifndef _SLAB_SLAB_H_
|
||||||
#define _SLAB_SLAB_H_
|
#define _SLAB_SLAB_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#include <slab/Depot.h>
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
#include <slab/Backend.h>
|
#include <slab/Backend.h>
|
||||||
#include <slab/Base.h>
|
#include <slab/Base.h>
|
||||||
#include <slab/Depot.h>
|
|
||||||
#include <slab/MergedStrategy.h>
|
#include <slab/MergedStrategy.h>
|
||||||
#include <slab/HashStrategy.h>
|
#include <slab/HashStrategy.h>
|
||||||
#include <slab/Utilities.h>
|
#include <slab/Utilities.h>
|
||||||
@@ -22,11 +22,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum {
|
|
||||||
CACHE_DONT_SLEEP = 1 << 0,
|
|
||||||
CACHE_ALIGN_TO_TOTAL = 1 << 16,
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef void *object_cache_t;
|
typedef void *object_cache_t;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,8 @@ protected:
|
|||||||
Backend::FreePages(fParent, ((Slab *)slab)->id);
|
Backend::FreePages(fParent, ((Slab *)slab)->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
base_cache *Parent() const { return fParent; }
|
||||||
|
|
||||||
base_cache *fParent;
|
base_cache *fParent;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user