4 * Copyright 2004 Develer S.r.l. (http://www.develer.com/)
5 * This file is part of DevLib - See README.devlib for information.
11 * \author Giovanni Bajo <rasky@develer.com>
16 *#* Revision 1.5 2005/11/04 16:20:02 bernie
17 *#* Fix reference to README.devlib in header.
19 *#* Revision 1.4 2005/04/11 19:10:28 bernie
20 *#* Include top-level headers from cfg/ subdir.
22 *#* Revision 1.3 2004/12/08 08:09:01 bernie
23 *#* Add missing header.
29 #include <cfg/macros.h>
30 #include <mware/list.h>
32 #define EXTERN_POOL(name) \
35 #define DECLARE_POOL_WITH_STORAGE(name, type, num, storage) \
36 static type name##_items[num]; \
38 INLINE void name##_init(void (*init_func)(type*)) \
42 for (i=0;i<countof(name##_items);++i) \
44 if (init_func) init_func(&name##_items[i]); \
45 ADDTAIL(&name, (Node*)&name##_items[i]); \
48 INLINE void name##_init(void (*init_func)(type*)) \
51 #define DECLARE_POOL(name, type, num) \
52 DECLARE_POOL_WITH_STORAGE(name, type, num, List)
54 #define DECLARE_POOL_STATIC(name, type, num) \
55 DECLARE_POOL_WITH_STORAGE(name, type, num, static List)
57 #define pool_init(name, init_func) (*(name##_init))(init_func)
58 #define pool_alloc(name) REMHEAD(name)
59 #define pool_free(name, elem) ADDHEAD(name, (Node*)elem)
60 #define pool_empty(name) ISLISTEMPTY(name)
62 #endif /* MWARE_POOL_H */