2011-12-22 15:19:25 +00:00
|
|
|
/*
|
|
|
|
* \brief Typed slab allocator
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2006-05-17
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 12:23:52 +00:00
|
|
|
* Copyright (C) 2006-2017 Genode Labs GmbH
|
2011-12-22 15:19:25 +00:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 12:23:52 +00:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2011-12-22 15:19:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE__BASE__TSLAB_H_
|
|
|
|
#define _INCLUDE__BASE__TSLAB_H_
|
|
|
|
|
|
|
|
#include <base/slab.h>
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
namespace Genode { template <typename, size_t> struct Tslab; }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
|
2015-03-04 20:12:14 +00:00
|
|
|
template <typename T, Genode::size_t BLOCK_SIZE>
|
|
|
|
struct Genode::Tslab : Slab
|
|
|
|
{
|
2016-03-31 16:17:07 +00:00
|
|
|
Tslab(Allocator *backing_store, void *initial_sb = 0)
|
2015-03-04 20:12:14 +00:00
|
|
|
: Slab(sizeof(T), BLOCK_SIZE, initial_sb, backing_store)
|
|
|
|
{ }
|
2011-12-22 15:19:25 +00:00
|
|
|
|
2017-05-07 21:15:49 +00:00
|
|
|
Tslab(Allocator &backing_store, void *initial_sb = 0)
|
|
|
|
: Slab(sizeof(T), BLOCK_SIZE, initial_sb, &backing_store)
|
|
|
|
{ }
|
|
|
|
|
2016-03-31 16:17:07 +00:00
|
|
|
T *first_object() { return (T *)Slab::any_used_elem(); }
|
2015-03-04 20:12:14 +00:00
|
|
|
};
|
2011-12-22 15:19:25 +00:00
|
|
|
|
|
|
|
#endif /* _INCLUDE__BASE__TSLAB_H_ */
|