summaryrefslogtreecommitdiffstats
path: root/include/tlsf.h
diff options
context:
space:
mode:
authorAntony Pavlov <antonynpavlov@gmail.com>2011-12-08 18:03:47 +0400
committerSascha Hauer <s.hauer@pengutronix.de>2011-12-23 11:26:42 +0100
commitd5b733a6449e6c285309880cdb65933a21ba5a76 (patch)
tree00c9416f9cf3f775a7b11c5dd334705e85e1313f /include/tlsf.h
parent81e1f6d0201a6cb15629ba81757f6acd80e01a60 (diff)
downloadbarebox-d5b733a6449e6c285309880cdb65933a21ba5a76.tar.gz
barebox-d5b733a6449e6c285309880cdb65933a21ba5a76.tar.xz
import TLSF 2.0 from http://tlsf.baisoku.org/tlsf-2.0.zip
TLSF: Two Level Segregated Fit memory allocator implementation. Written by Matthew Conte (matt@baisoku.org). Public Domain, no restrictions. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'include/tlsf.h')
-rw-r--r--include/tlsf.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/include/tlsf.h b/include/tlsf.h
new file mode 100644
index 0000000000..de7f90b54f
--- /dev/null
+++ b/include/tlsf.h
@@ -0,0 +1,52 @@
+#ifndef INCLUDED_tlsf
+#define INCLUDED_tlsf
+
+/*
+** Two Level Segregated Fit memory allocator, version 1.9.
+** Written by Matthew Conte, and placed in the Public Domain.
+** http://tlsf.baisoku.org
+**
+** Based on the original documentation by Miguel Masmano:
+** http://rtportal.upv.es/rtmalloc/allocators/tlsf/index.shtml
+**
+** Please see the accompanying Readme.txt for implementation
+** notes and caveats.
+**
+** This implementation was written to the specification
+** of the document, therefore no GPL restrictions apply.
+*/
+
+#include <stddef.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+/* Create/destroy a memory pool. */
+typedef void* tlsf_pool;
+tlsf_pool tlsf_create(void* mem, size_t bytes);
+void tlsf_destroy(tlsf_pool pool);
+
+/* malloc/memalign/realloc/free replacements. */
+void* tlsf_malloc(tlsf_pool pool, size_t bytes);
+void* tlsf_memalign(tlsf_pool pool, size_t align, size_t bytes);
+void* tlsf_realloc(tlsf_pool pool, void* ptr, size_t size);
+void tlsf_free(tlsf_pool pool, void* ptr);
+
+/* Debugging. */
+typedef void (*tlsf_walker)(void* ptr, size_t size, int used, void* user);
+void tlsf_walk_heap(tlsf_pool pool, tlsf_walker walker, void* user);
+/* Returns nonzero if heap check fails. */
+int tlsf_check_heap(tlsf_pool pool);
+
+/* Returns internal block size, not original request size */
+size_t tlsf_block_size(void* ptr);
+
+/* Overhead of per-pool internal structures. */
+size_t tlsf_overhead();
+
+#if defined(__cplusplus)
+};
+#endif
+
+#endif