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.4 2005/04/11 19:10:28 bernie
17 *#* Include top-level headers from cfg/ subdir.
19 *#* Revision 1.3 2004/12/08 08:09:01 bernie
20 *#* Add missing header.
26 #include <cfg/macros.h>
27 #include <mware/list.h>
29 #define EXTERN_POOL(name) \
32 #define DECLARE_POOL_WITH_STORAGE(name, type, num, storage) \
33 static type name##_items[num]; \
35 INLINE void name##_init(void (*init_func)(type*)) \
39 for (i=0;i<countof(name##_items);++i) \
41 if (init_func) init_func(&name##_items[i]); \
42 ADDTAIL(&name, (Node*)&name##_items[i]); \
45 INLINE void name##_init(void (*init_func)(type*)) \
48 #define DECLARE_POOL(name, type, num) \
49 DECLARE_POOL_WITH_STORAGE(name, type, num, List)
51 #define DECLARE_POOL_STATIC(name, type, num) \
52 DECLARE_POOL_WITH_STORAGE(name, type, num, static List)
54 #define pool_init(name, init_func) (*(name##_init))(init_func)
55 #define pool_alloc(name) REMHEAD(name)
56 #define pool_free(name, elem) ADDHEAD(name, (Node*)elem)
57 #define pool_empty(name) ISLISTEMPTY(name)
59 #endif /* MWARE_POOL_H */