summaryrefslogtreecommitdiff
path: root/lib/resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/resource.h')
-rw-r--r--lib/resource.h21
1 files changed, 16 insertions, 5 deletions
diff --git a/lib/resource.h b/lib/resource.h
index 9ec41ed8..3e589e32 100644
--- a/lib/resource.h
+++ b/lib/resource.h
@@ -40,10 +40,15 @@ struct resclass {
/* Generic resource manipulation */
-typedef struct pool pool;
+typedef struct pool {
+ resource r;
+ list inside;
+ struct birdloop *loop;
+ const char *name;
+} pool;
void resource_init(void);
-pool *rp_new(pool *, const char *); /* Create new pool */
+
void rfree(void *); /* Free single resource */
void rdump(void *); /* Dump to debug output */
struct resmem rmemsize(void *res); /* Return size of memory used by the resource */
@@ -52,6 +57,11 @@ void rmove(void *, pool *); /* Move to a different pool */
void *ralloc(pool *, struct resclass *);
+pool *rp_new(pool *, struct birdloop *loop, const char *); /* Create new pool */
+void rp_free(pool *p, pool *parent); /* Free parent pool */
+struct resmem rp_memsize(pool *p); /* Return size of memory used by the pool */
+void rp_dump(pool *p); /* Dump pool to debug output */
+
extern pool root_pool;
/* Normal memory blocks */
@@ -82,7 +92,7 @@ void lp_restore(linpool *m, lp_state *p); /* Restore state */
extern const int lp_chunk_size;
#define LP_GAS 1024
#define LP_GOOD_SIZE(x) (((x + LP_GAS - 1) & (~(LP_GAS - 1))) - lp_chunk_size)
-#define lp_new_default(p) lp_new(p, LP_GOOD_SIZE(LP_GAS*4))
+#define lp_new_default(p) lp_new(p, 0)
/* Slabs */
@@ -100,11 +110,12 @@ void sl_free(slab *, void *);
void buffer_realloc(void **buf, unsigned *size, unsigned need, unsigned item_size);
+extern long page_size;
+
/* Allocator of whole pages; for use in slabs and other high-level allocators. */
-u64 get_page_size(void);
void *alloc_page(void);
void free_page(void *);
-extern uint pages_kept;
+#define PAGE_HEAD(x) ((void *) (((intptr_t) (x)) & ~(page_size-1)))
#ifdef HAVE_LIBDMALLOC
/*