aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-12-02 12:08:51 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:05:25 -0700
commit2035e136c41f24b9b991917fd0ead512e4fd3fd8 (patch)
tree9151d61dd60d8f1d8087e9d97b62b89e1484ccfe /allocate.h
parentMove declaration of "die()" to lib.h and check its format. (diff)
downloadsparse-2035e136c41f24b9b991917fd0ead512e4fd3fd8.tar.gz
sparse-2035e136c41f24b9b991917fd0ead512e4fd3fd8.tar.bz2
sparse-2035e136c41f24b9b991917fd0ead512e4fd3fd8.zip
Split out the blob allocator from lib.c into allocate.c.
It's disgusting how intimate lib.c is with all the types, and this is slowly trying to split things up a bit. Now the intimate part is in allocate.c, but maybe we can get to the point where each allocation user just declares its own allocation strategy, and just uses the generic routines in allocate.c
Diffstat (limited to 'allocate.h')
-rw-r--r--allocate.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/allocate.h b/allocate.h
new file mode 100644
index 0000000..56abb0c
--- /dev/null
+++ b/allocate.h
@@ -0,0 +1,46 @@
+#ifndef ALLOCATE_H
+#define ALLOCATE_H
+
+struct allocation_blob {
+ struct allocation_blob *next;
+ unsigned int left, offset;
+ unsigned char data[];
+};
+
+struct allocator_struct {
+ const char *name;
+ struct allocation_blob *blobs;
+ unsigned int alignment;
+ unsigned int chunking;
+ void *freelist;
+ /* statistics */
+ unsigned int allocations, total_bytes, useful_bytes;
+};
+
+extern void drop_all_allocations(struct allocator_struct *desc);
+extern void *allocate(struct allocator_struct *desc, unsigned int size);
+extern void free_one_entry(struct allocator_struct *desc, void *entry);
+
+#define __DECLARE_ALLOCATOR(type, x) \
+ extern type *__alloc_##x(int); \
+ extern void __free_##x(type *); \
+ extern void show_##x##_alloc(void); \
+ extern void clear_##x##_alloc(void);
+#define DECLARE_ALLOCATOR(x) __DECLARE_ALLOCATOR(struct x, x)
+
+DECLARE_ALLOCATOR(ident);
+DECLARE_ALLOCATOR(token);
+DECLARE_ALLOCATOR(symbol);
+DECLARE_ALLOCATOR(expression);
+DECLARE_ALLOCATOR(statement);
+DECLARE_ALLOCATOR(string);
+DECLARE_ALLOCATOR(scope);
+__DECLARE_ALLOCATOR(void, bytes);
+DECLARE_ALLOCATOR(basic_block);
+DECLARE_ALLOCATOR(entrypoint);
+DECLARE_ALLOCATOR(instruction);
+DECLARE_ALLOCATOR(multijmp);
+DECLARE_ALLOCATOR(phi);
+DECLARE_ALLOCATOR(pseudo);
+
+#endif