Alexander Viro wrote:
>
> On Thu, 13 Jul 2000, Andrew Morton wrote:
>
> > inline void *operator new(size_t size)
> > {
> > return kmalloc(size);
> > }
>
> Yes? Care to compile that? FYI, kmalloc() has _two_ arguments.
I _knew_ I shouldn't have sent that email. Sigh.
It was a proof-of-concept. Here ya go:
#define GFP_ATOMIC 1
#define GFP_KERNEL 2
typedef unsigned int size_t;
extern "C" void *kmalloc(size_t size, int flags);
char gfp_atomic[1];
char gfp_kernel[1];
inline void *operator new[](size_t size, char *where)
{
if (where == gfp_atomic)
return kmalloc(size, GFP_ATOMIC);
else if (where == gfp_kernel)
return kmalloc(size, GFP_KERNEL);
return 0;
}
char *foo(int n)
{
return new (gfp_atomic) char[n];
}
> Yes, usually C++ compiler can do choices
> of that kind. And that works for normal userland stuff. Here it's not an
> option.
But it's fun trying.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Sat Jul 15 2000 - 21:00:16 EST