Repository navigation
Add stackman_block_call for a malloc block - #28
Merged
Merged
Conversation
A static inline next to the stack-pointer macros. It turns a low address and a size into the far pointer stackman_call takes and the byte count toward near.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
stackman_block_callis astatic inlineinstackman.h, next to the stack-pointer macros. It takes a malloc block (the low address and the byte count) and fills in the pointer to pass tostackman_call, plus how many bytes of the block lie toward near.On a descending stack that pointer is the aligned high end. When the base and the size are already aligned,
call_sp == base + sizeandextent == size. On an ascending stack the pointer is the aligned low end, and an aligned base givescall_sp == base. Bytes dropped to reach the alignment are not part ofextent. A null base, a zero size, a missing out-pointer, a range that would wrap, or a block that alignment leaves empty returns 0 and writes nothing.Callers of
stackman_callalready do this conversion by hand, and the direction test is the part that gets copied wrong. The helper keeps that test in one place. A stack described as a far pointer and an extent stays in those terms; this function is only the step from a malloc pair to that pointer.No version bump. Native
make teston sysv_amd64 passed, includingtest_06for the descending case andbin/test_block_asc, which compiles the function withSTACKMAN_STACK_DIRset to 1. No supported ABI grows upward.