00001 // AUTOMATICALLY GENERATED -- DO NOT EDIT! -*- c++ -*- 00002 00003 #ifndef kmem_slab_simple_h 00004 #define kmem_slab_simple_h 00005 00006 #include <stddef.h> // size_t 00007 #include "helping_lock.h" // Helping_lock 00008 00009 #include "slab_cache_anon.h" // slab_cache_anon 00010 00011 // 00012 // INTERFACE definition follows 00013 // 00014 00015 00016 class Kmem_slab_simple : public slab_cache_anon 00017 { 00018 // DATA 00019 Helping_lock _lock; 00020 00021 public: 00022 // We only support slab size == PAGE_SIZE. 00023 Kmem_slab_simple(unsigned elem_size, unsigned alignment); 00024 00025 ~Kmem_slab_simple(); 00026 00027 // We overwrite some of slab_cache_anon's functions to faciliate locking. 00028 void * alloc(); // request initialized member from cache 00029 00030 void free(void *cache_entry); // return initialized member to cache 00031 00032 bool reap(); 00033 00034 void * operator new(size_t size); 00035 00036 void operator delete(void *block, size_t size); 00037 00038 protected: 00039 // Specializations providing their own block_alloc()/block_free() can 00040 // also request slab sizes larger than one page. 00041 Kmem_slab_simple(unsigned long slab_size, unsigned elem_size, unsigned alignment); 00042 00043 private: 00044 // Callback functions called by our super class, slab_cache_anon, to 00045 // allocate or free blocks 00046 virtual void * block_alloc(unsigned long size, unsigned long); 00047 00048 virtual void block_free(void *block, unsigned long); 00049 }; 00050 00051 #endif // kmem_slab_simple_h