[libc] Fixes to v7malloc.c for OpenWatcom #2131
Merged
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.
More fixes to v7malloc.c for OWC.
When an OWC
__near *
pointer is passed to a function, the compiler expands it to a__far *
pointer in large model by adding SS: as the segment. This caused problems in __dprintf, which is currently using ava_arg(..., unsigned int)
to get the pointer, which would not increment the va_arg pointer past the full 32-bits. This caused subsequent parameters to be displayed incorrectly. Since the pointers are all near, v7malloc debug statements have been converted from using the %p specification to using %04x for compatibility between __dprintf and fprintf. This was all caused by trying to build a super-small dprintf that doesn't drag in lots of code, for debugging purposes, possibly to be used in debug builds for all executables.Dprintf is also enhanced to display %x as hex, and allow field widths, with automatic 0 or space fill for radix 16 or 10, respectively. This allows the previous v7malloc debug output format strings to remain the same as was built for fprintf (which is a lot more to drag in).
I'm thinking the next step will be to rewrite v7malloc to use a base arena with unsigned int offsets into it, rather than near pointers. This will also aid the transition to converting it to a general-purpose arena allocator for near heaps created from far memory.