Skip to content

Commit

Permalink
Merge pull request RIOT-OS#20723 from benpicco/tests/thread_stack_ali…
Browse files Browse the repository at this point in the history
…gnment-usage

measure_stack_free_internal(): don't try to align end of stack
  • Loading branch information
maribu authored Jun 4, 2024
2 parents 5668de6 + 5b73294 commit ec71eba
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
3 changes: 0 additions & 3 deletions core/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,6 @@ uintptr_t measure_stack_free_internal(const char *stack, size_t size)
uintptr_t *stackp = (uintptr_t *)(uintptr_t)stack;
uintptr_t end = (uintptr_t)stack + size;

/* better be safe than sorry: align end of stack just in case */
end &= (sizeof(uintptr_t) - 1);

/* assume that the stack grows "downwards" */
while (((uintptr_t)stackp < end) && (*stackp == (uintptr_t)stackp)) {
stackp++;
Expand Down
1 change: 1 addition & 0 deletions tests/core/thread_stack_alignment/tests/01-run.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def testfunc(child):
child.expect(r"(\{[^\n\r]*\})\r\n")
stats = json.loads(child.match.group(1))["threads"][0]
assert stats["name"] == "test"
assert stats["stack_used"] < stats["stack_size"]
if stack_used_max < stats["stack_used"]:
stack_used_max = stats["stack_used"]
if stack_used_min > stats["stack_used"]:
Expand Down

0 comments on commit ec71eba

Please sign in to comment.