Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libc] Fixes to v7malloc.c for OpenWatcom #2131

Merged
merged 2 commits into from
Dec 13, 2024
Merged

[libc] Fixes to v7malloc.c for OpenWatcom #2131

merged 2 commits into from
Dec 13, 2024

Conversation

ghaerr
Copy link
Owner

@ghaerr ghaerr commented Dec 13, 2024

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 a va_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.

@ghaerr ghaerr merged commit 49aba33 into master Dec 13, 2024
2 checks passed
@ghaerr ghaerr deleted the v7malloc2 branch December 13, 2024 05:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant