mirror of
https://github.com/espressif/tlsf.git
synced 2025-12-05 15:15:47 +00:00
tlsf_public and tlsf_private moved to tlsf_config enum in tlsf_common.h header
This commit is contained in:
committed by
Guillaume Souchere
parent
1f77a1d2a1
commit
6723d4fc98
53
tlsf.c
53
tlsf.c
@@ -199,59 +199,6 @@ tlsf_decl int tlsf_fls_sizet(size_t size)
|
|||||||
|
|
||||||
#undef tlsf_decl
|
#undef tlsf_decl
|
||||||
|
|
||||||
/*
|
|
||||||
** Constants.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Public constants: may be modified. */
|
|
||||||
enum tlsf_public
|
|
||||||
{
|
|
||||||
/* log2 of number of linear subdivisions of block sizes. Larger
|
|
||||||
** values require more memory in the control structure. Values of
|
|
||||||
** 4 or 5 are typical.
|
|
||||||
*/
|
|
||||||
SL_INDEX_COUNT_LOG2 = 5,
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Private constants: do not modify. */
|
|
||||||
enum tlsf_private
|
|
||||||
{
|
|
||||||
#if defined (TLSF_64BIT)
|
|
||||||
/* All allocation sizes and addresses are aligned to 8 bytes. */
|
|
||||||
ALIGN_SIZE_LOG2 = 3,
|
|
||||||
#else
|
|
||||||
/* All allocation sizes and addresses are aligned to 4 bytes. */
|
|
||||||
ALIGN_SIZE_LOG2 = 2,
|
|
||||||
#endif
|
|
||||||
ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2),
|
|
||||||
|
|
||||||
/*
|
|
||||||
** We support allocations of sizes up to (1 << FL_INDEX_MAX) bits.
|
|
||||||
** However, because we linearly subdivide the second-level lists, and
|
|
||||||
** our minimum size granularity is 4 bytes, it doesn't make sense to
|
|
||||||
** create first-level lists for sizes smaller than SL_INDEX_COUNT * 4,
|
|
||||||
** or (1 << (SL_INDEX_COUNT_LOG2 + 2)) bytes, as there we will be
|
|
||||||
** trying to split size ranges into more slots than we have available.
|
|
||||||
** Instead, we calculate the minimum threshold size, and place all
|
|
||||||
** blocks below that size into the 0th first-level list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if defined (TLSF_64BIT)
|
|
||||||
/*
|
|
||||||
** TODO: We can increase this to support larger sizes, at the expense
|
|
||||||
** of more overhead in the TLSF structure.
|
|
||||||
*/
|
|
||||||
FL_INDEX_MAX = 32,
|
|
||||||
#else
|
|
||||||
FL_INDEX_MAX = 30,
|
|
||||||
#endif
|
|
||||||
SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2),
|
|
||||||
FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2),
|
|
||||||
FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1),
|
|
||||||
|
|
||||||
SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Cast and min/max macros.
|
** Cast and min/max macros.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -6,10 +6,53 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#if defined __has_include && __has_include("tlsf_platform.h")
|
||||||
|
#include "tlsf_platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
enum tlsf_config
|
||||||
|
{
|
||||||
|
/* log2 of number of linear subdivisions of block sizes. Larger
|
||||||
|
** values require more memory in the control structure. Values of
|
||||||
|
** 4 or 5 are typical.
|
||||||
|
*/
|
||||||
|
SL_INDEX_COUNT_LOG2 = 5,
|
||||||
|
|
||||||
|
/* All allocation sizes and addresses are aligned to 4 bytes. */
|
||||||
|
ALIGN_SIZE_LOG2 = 2,
|
||||||
|
ALIGN_SIZE = (1 << ALIGN_SIZE_LOG2),
|
||||||
|
|
||||||
|
/*
|
||||||
|
** We support allocations of sizes up to (1 << FL_INDEX_MAX) bits.
|
||||||
|
** However, because we linearly subdivide the second-level lists, and
|
||||||
|
** our minimum size granularity is 4 bytes, it doesn't make sense to
|
||||||
|
** create first-level lists for sizes smaller than SL_INDEX_COUNT * 4,
|
||||||
|
** or (1 << (SL_INDEX_COUNT_LOG2 + 2)) bytes, as there we will be
|
||||||
|
** trying to split size ranges into more slots than we have available.
|
||||||
|
** Instead, we calculate the minimum threshold size, and place all
|
||||||
|
** blocks below that size into the 0th first-level list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Tunning the first level, we can reduce TLSF pool overhead
|
||||||
|
* in exchange of manage a pool smaller than 4GB
|
||||||
|
*/
|
||||||
|
#ifdef FL_INDEX_MAX_PLATFORM
|
||||||
|
FL_INDEX_MAX = FL_INDEX_MAX_PLATFORM,
|
||||||
|
#else
|
||||||
|
FL_INDEX_MAX = 30,
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SL_INDEX_COUNT = (1 << SL_INDEX_COUNT_LOG2),
|
||||||
|
FL_INDEX_SHIFT = (SL_INDEX_COUNT_LOG2 + ALIGN_SIZE_LOG2),
|
||||||
|
FL_INDEX_COUNT = (FL_INDEX_MAX - FL_INDEX_SHIFT + 1),
|
||||||
|
|
||||||
|
SMALL_BLOCK_SIZE = (1 << FL_INDEX_SHIFT),
|
||||||
|
};
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user