4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See devlib/README for information.
11 * \author Giovanni Bajo <rasky@develer.com>
16 *#* Revision 1.3 2004/12/08 08:09:01 bernie
17 *#* Add missing header.
24 #include <mware/list.h>
26 #define EXTERN_POOL(name) \
29 #define DECLARE_POOL_WITH_STORAGE(name, type, num, storage) \
30 static type name##_items[num]; \
32 INLINE void name##_init(void (*init_func)(type*)) \
36 for (i=0;i<countof(name##_items);++i) \
38 if (init_func) init_func(&name##_items[i]); \
39 ADDTAIL(&name, (Node*)&name##_items[i]); \
42 INLINE void name##_init(void (*init_func)(type*)) \
45 #define DECLARE_POOL(name, type, num) \
46 DECLARE_POOL_WITH_STORAGE(name, type, num, List)
48 #define DECLARE_POOL_STATIC(name, type, num) \
49 DECLARE_POOL_WITH_STORAGE(name, type, num, static List)
51 #define pool_init(name, init_func) (*(name##_init))(init_func)
52 #define pool_alloc(name) REMHEAD(name)
53 #define pool_free(name, elem) ADDHEAD(name, (Node*)elem)
54 #define pool_empty(name) ISLISTEMPTY(name)
56 #endif /* MWARE_POOL_H */