]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/moe/server/src/new.h
update
[l4.git] / l4 / pkg / moe / server / src / new.h
1 /*
2  * (c) 2008-2009 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #pragma once
10
11
12 #include <l4/cxx/slab_alloc.h>
13 #include <l4/cxx/std_tmpl.h>
14
15 #include "page_alloc.h"
16
17 template< int Obj_size >
18 class Slab_alloc_fn : public cxx::Base_slab<Obj_size, L4_PAGESIZE, 2, Single_page_alloc>
19 {
20 };
21
22 template<int size>
23 Slab_alloc_fn<size> &__get_slab_allocator(cxx::Int_to_type<size> const &)
24 {
25   static Slab_alloc_fn<size> s;
26   return s;
27 }
28
29 inline 
30 void *operator new (size_t size)
31 {
32   if (size <= sizeof(unsigned long))
33     return __get_slab_allocator(cxx::Int_to_type<sizeof(unsigned long)>()).alloc();
34 }
35
36