1
0

pool.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. typedef struct Pool Pool;
  10. struct Pool {
  11. char* name;
  12. u32 maxsize;
  13. u32 cursize;
  14. u32 curfree;
  15. u32 curalloc;
  16. u32 minarena; /* smallest size of new arena */
  17. u32 quantum; /* allocated blocks should be multiple of */
  18. u32 minblock; /* smallest newly allocated block */
  19. void* freeroot; /* actually Free* */
  20. void* arenalist; /* actually Arena* */
  21. void* (*alloc)(u32);
  22. int (*merge)(void*, void*);
  23. void (*move)(void* from, void* to);
  24. int flags;
  25. int nfree;
  26. int lastcompact;
  27. void (*lock)(Pool*);
  28. void (*unlock)(Pool*);
  29. void (*print)(Pool*, char*, ...);
  30. void (*panic)(Pool*, char*, ...);
  31. void (*logstack)(Pool*);
  32. void* private;
  33. };
  34. extern void* poolalloc(Pool*, u32);
  35. extern void* poolallocalign(Pool*, u32, u32, i32,
  36. u32);
  37. extern void poolfree(Pool*, void*);
  38. extern u32 poolmsize(Pool*, void*);
  39. extern void* poolrealloc(Pool*, void*, u32);
  40. extern void poolcheck(Pool*);
  41. extern int poolcompact(Pool*);
  42. extern void poolblockcheck(Pool*, void*);
  43. extern Pool* mainmem;
  44. enum { /* flags */
  45. POOL_ANTAGONISM = 1<<0,
  46. POOL_PARANOIA = 1<<1,
  47. POOL_VERBOSITY = 1<<2,
  48. POOL_DEBUGGING = 1<<3,
  49. POOL_LOGGING = 1<<4,
  50. POOL_TOLERANCE = 1<<5,
  51. POOL_NOREUSE = 1<<6,
  52. };