2 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
9 * As a special exception, you may use this file as part of a free software
10 * library without restriction. Specifically, if other files instantiate
11 * templates or use macros or inline functions from this file, or you compile
12 * this file and link it with other files to produce an executable, this
13 * file does not by itself cause the resulting executable to be covered by
14 * the GNU General Public License. This exception does not however
15 * invalidate any other reasons why the executable file might be covered by
16 * the GNU General Public License.
20 template< unsigned O_SIZE, unsigned N = 10 >
21 struct Simple_store_sz
25 Item_size = (O_SIZE + sizeof(unsigned long) - 1) / sizeof(unsigned long)
30 unsigned long _str[Item_size];
39 Simple_store_sz() throw();
41 void *alloc() throw();
42 void free(void *b) throw();
46 template< unsigned O, unsigned N >
47 Simple_store_sz<O,N>::Simple_store_sz() throw() : first(_o)
49 for (unsigned i = 0; i < MAX - 1; ++i)
50 _o[i].next = _o + i + 1;
55 template< unsigned O, unsigned N >
58 Simple_store_sz<O,N>::alloc() throw()
65 return (void*)(i->_str);
71 template< unsigned O, unsigned N >
74 Simple_store_sz<O,N>::free(void *b) throw()
76 Item *i = reinterpret_cast<Item*>(b);
82 template< typename O, unsigned N = 10 >
83 struct Simple_store : public Simple_store_sz<sizeof(O), N> {};