[lkml]   [2000]   [Jul]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: Object Oriented Linux
    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
    Please read the FAQ at

     \ /
      Last update: 2005-03-22 13:57    [W:0.020 / U:7.100 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site