[libc] Add arena-based memory allocator for OpenWatcom large model #2138
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The new "amalloc" arena allocator is finally implemented and working! This PR adds the capability of managing lots of small allocations in up to a 64K block (arena) of memory obtained through fmemalloc at startup. This will allow for a set of wrapper routines to be used to either allocate small allocations, up to 64k worth from this allocator, while directly allocating large blocks from fmemalloc itself. That threshold will be dynamically adjustable for each application.
In addition, a very comprehensive "debug malloc" is introduced using code from the previously existing-but-not-well-integrated UNIX v7 malloc classic algorithm. amalloc also contains the same heap integrity checking and walking code. The debug display output can be dynamically turned on using
sysctl malloc.debug=2
from the shell for basic allocation summary, and =3 for a detailed heap dump after every allocation or free.A general replacement of realloc and a few top-level wrapper routines will be required for this to be seamlessly integrated into the 8086 toolchain, coming in another PR.
Tested on OWC. Not ready for use with ia16-elf-gcc (small model) applications.