wlib-tlsf
Version:
TLSF memory allocator
33 lines • 3.32 kB
JSON
{
"name": "wlib-tlsf",
"description": "TLSF memory allocator",
"keywords": [
"wio",
"pkg",
"c",
"c++",
"waterloop",
"memory"
],
"readme": "# WLib TLSF\n\nTwo-level segregated-fit memory allocator package for WLib. Allocator created by Matthew Conte.\n\nModified API for WLib.\n\n# API Usage\n\nThe documentation is a little lacking on initialization but you essentially\npass a memory pool for TLSF to manage.\n\n```c++\nenum { STATIC_POOL_SIZE = 1 \u003c\u003c 20 };\nstatic char s_pool[STATIC_POOL_SIZE];\n\ntlsf_t instance = tlsf_create_with_pool(s_pool, STATIC_POOL_SIZE);\n\nvoid *data = tlsf_malloc(instance, 64);\ntlsf_free(instance, data);\n```\n\n# Configuration\nThree main flags are used to control the operation of the TLSF.\n\n#### `WLIB_TLSF_LOG2_DIV`\nLog of the number of subdivisions within a size class. Larger values\nintroduce more overhead to the TLSF structure but reduce fragmentation.\nValues should be at least 2. Typical values up to 5.\n\n#### `WLIB_TLSF_LOG2_ALIGN`\nLog of the alignment of memory and blocks. E.g. a value of 2 aligns to\n4 bytes. The alignment must be at least the architecture alignment;\nthat is, 2 bytes for 16-bit, 4 bytes for 32-bit, and 8 bytes for 64-bit.\n\nLarger values may be used to align to page boundaries.\n\n#### `WLIB_TLSF_LOG2_MAX`\nLog of the maximum possible allocation size. This value directly affects\nthe maximum pool size that can be managed by TLSF. Increasing it,\nhowever, will increase overhead.\n\n#### Specify Architecture\nOne of `WLIB_TLSF_16BIT`, `WLIB_TLSF_32BIT`, or `WLIB_TLSF_64BIT` must\nbe specified to select the architecture. TLSF attempts to dectect the\nspecific architecture to use builtins, but these can be specified as\n\n- `WLIB_TLSF_ARM`\n- `WLIB_TLSF_GHS`\n- `WLIB_TLSF_GNU`\n- `WLIB_TLSF_MSC`\n- `WLIB_TLSF_PPC`\n- `WLIB_TLSF_SNC`\n\nIf none is specified or autodetection fails, TLSF falls back to a \ngeneric implementation of CLZ.\n\n## Debugging\nThe flag `WLIB_TLSF_DEBUG_LEVEL` specifies the amount of printing and\nrun-time assertions. A value of `0` turns all off, a value of `1` will\nprint errors and run asserts, and a value of `2` will print some\nverbose output.\n\nCustom assert and print handlers can be implemented by defining\n`WLIB_TLSF_ASSERT` and `WLIB_TLSF_PRINTF` and then providing the functions\n\n```c\nvoid tlsf_printf(const char *fmt, ...) \n{ /* ... */ }\n\nvoid tlsf_assert(bool expr, const char *msg)\n{ /* ... */ }\n```\n\n## Usage on AVR\nRecommended settings are\n\n```yaml\npkg_compile_flags:\n- -DWLIB_TLSF_16BIT\n- -DWLIB_TLSF_LOG2_DIV=2\n- -DWLIB_TLSF_LOG2_ALIGN=1\n- -DWLIB_TLSF_LOG2_MAX=10\n- -DWLIB_TLSF_PRINTF\n- -DWLIB_TLSF_ASSERT\n```\n\nFor boards will limited RAM.\n",
"readmeFile": "README.md",
"version": "1.0.5",
"main": ".wio.js",
"dist": {
"integrity": "",
"shasum": "",
"tarball": "",
"fileCount": 0,
"unpackedSize": 0,
"npm-signature": ""
},
"scripts": null,
"dependencies": {},
"maintainers": null,
"contributors": null,
"bugs": "",
"author": "Jeff Niu \u003cjeffniu22@gmail.com\u003e (https://github.com/mogball)",
"license": "MIT",
"homepage": "",
"repository": "https://github.com/wloop/wlib-tlsf"
}