Skip to content

Add stackman_block_call for a malloc block - #28

Merged
kristjanvalur merged 1 commit into
stackless-dev:masterfrom
kristjanvalur:block-call
Oct 16, 2026
Merged

kristjanvalur merged 1 commit into
stackless-dev:masterfrom
kristjanvalur:block-call

Conversation

@kristjanvalur

Copy link
Copy Markdown
Collaborator

stackman_block_call is a static inline in stackman.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 to stackman_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 + size and extent == size. On an ascending stack the pointer is the aligned low end, and an aligned base gives call_sp == base. Bytes dropped to reach the alignment are not part of extent. 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_call already 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 test on sysv_amd64 passed, including test_06 for the descending case and bin/test_block_asc, which compiles the function with STACKMAN_STACK_DIR set to 1. No supported ABI grows upward.

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.
@kristjanvalur
kristjanvalur merged commit 0e6a4bd into stackless-dev:master Oct 16, 2026
16 checks passed
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