00001
00002
00003 #ifndef _CORE_COMMON_BLIST_HPP
00004 #define _CORE_COMMON_BLIST_HPP
00005
00006
00007
00008 #include "src/ipc/lock.hpp"
00009
00010 namespace Memory{namespace Heap{
00011 class heapbox; } }
00012
00013 #define bli_dt(item,type) ((type) ((blist_s*) item ) -> data )
00014
00015
00016 struct blist_s
00017 {
00018 blist_s *prev;
00019 blist_s *next;
00020 class blist_t *tree;
00021
00022 uint32 size;
00023 void *data;
00024
00025
00026 const char *func, *file;
00027 uint32 line;
00028 };
00029
00070 class blist_t
00071 {
00072 private:
00073 IPC::Lock::lock_t lock_blist;
00074 friend struct blist_s *blistsort_link(blist_t *list, blist_s *item, int(*compar)(const void*,const void*), blist_s *head);
00075 public:
00076 blist_s *head, *tail;
00077 uint32 facility;
00078 class Memory::Heap::heapbox *heap;
00079
00080 void init (uint32 fac);
00081 void init (uint32 fac, class Memory::Heap::heapbox *hp);
00082 void init (const char *name, class Memory::Heap::heapbox *hp);
00083 void done();
00084
00085 blist_s *add(void *data, size_t size, blist_t *tree);
00086 blist_s *find(void *data);
00087 int del(blist_s *obj);
00088
00089 blist_s *move(blist_s *obj, blist_t *dest);
00090 blist_s *link(blist_s *obj);
00091 blist_s *unlink(blist_s *obj);
00092
00093 blist_s *ptr(void *data, blist_t *tree);
00094 };
00095
00096 #define BLISTADD(blist,data,size,tree) do { \
00097 struct blist_s __TEMPx14BL; \
00098 __TEMPx14BL= blist.add(data,size,tree); \
00099 __TEMPx14BL.func=__func__;\
00100 __TEMPx14BL.file=__file__;\
00101 __TEMPx14BL.line=__line__; \
00102 } while(0)
00103
00104 #define BLISTPTR(blist,data,tree) do { \
00105 struct blist_s __TEMPx14BL; \
00106 __TEMPx14BL= blist.add(data,tree); \
00107 __TEMPx14BL.func=__func__;\
00108 __TEMPx14BL.file=__file__;\
00109 __TEMPx14BL.line=__line__; \
00110 } while(0)
00111
00112 #endif