Ragnar
2003-09-03 10:29:23 UTC
Hello
I have a template in my kernel slab allocator, used to created object
caches.
template<class T, class A = void>
class ObjectCache
{
public:
explicit ObjectCache(char * name,mword Flags=0,mword
Alignment=0,mword ObjSize=0)
{
...
}
T * Alloc()
{
void * place = Cache->GetObject();
T * x = new (place) T;
return x;
}
T * Alloc(A CtorArg)
{
void * place = Cache->GetObject();
T * x = new (place) T(CtorArg);
return x;
}
private:
...
};
This is an object cache interface used to create kernel objects. The
objects can
take eithe one ctor arg or none, but not more than one.
The two Alloc() methods are for creating objects which have a default
ctor and for those that do not. Now this worked fine in my RH-7 gcc
2.96, but i recently upgraded to RH-9 which has gcc 3.2.2 and it
started giving errors for those instatiations which do not specify the
second type.
For example, the following instantiation compiles fine:
ObjectCache<Lwp, KrThread *> LwpCache("LWPCache");
The second type is specified here as KrThread
But this does not:
ObjectCache<KrThread> KrThreadCache("KernelThreadCache", KT_ALIGN);
gcc gives the error: invalid parameter type `void'
What is happening and how can i correct this ? Also, is there a
mechanism to pass any number of arguments to the ctors. That is
flexibility in the number of arguments.
Regard & Thanks
---
Ragnar
Capital Kernel Engineering
www.capitalos.4t.com
I have a template in my kernel slab allocator, used to created object
caches.
template<class T, class A = void>
class ObjectCache
{
public:
explicit ObjectCache(char * name,mword Flags=0,mword
Alignment=0,mword ObjSize=0)
{
...
}
T * Alloc()
{
void * place = Cache->GetObject();
T * x = new (place) T;
return x;
}
T * Alloc(A CtorArg)
{
void * place = Cache->GetObject();
T * x = new (place) T(CtorArg);
return x;
}
private:
...
};
This is an object cache interface used to create kernel objects. The
objects can
take eithe one ctor arg or none, but not more than one.
The two Alloc() methods are for creating objects which have a default
ctor and for those that do not. Now this worked fine in my RH-7 gcc
2.96, but i recently upgraded to RH-9 which has gcc 3.2.2 and it
started giving errors for those instatiations which do not specify the
second type.
For example, the following instantiation compiles fine:
ObjectCache<Lwp, KrThread *> LwpCache("LWPCache");
The second type is specified here as KrThread
But this does not:
ObjectCache<KrThread> KrThreadCache("KernelThreadCache", KT_ALIGN);
gcc gives the error: invalid parameter type `void'
What is happening and how can i correct this ? Also, is there a
mechanism to pass any number of arguments to the ctors. That is
flexibility in the number of arguments.
Regard & Thanks
---
Ragnar
Capital Kernel Engineering
www.capitalos.4t.com