-
Notifications
You must be signed in to change notification settings - Fork 52
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
Change usage example for statically allocated heap #53
Conversation
The linker needs to know how big the heap is, otherwise, it could place some of the global variables in the heap region.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @therealprof (or someone else) soon. Please see the contribution instructions for more information. |
cortex-m-rt's However, nothing prevents the user specifying a heap that's too large, whereas your example will ensure the heap space is statically allocated and known about by the linker, which I think is basically better in every way. Probably Could you update the example to move If anyone else @rust-embedded/cortex-m has thoughts about this please shout out though... I think it's mostly just that MaybeUninit and Rust's general concept of uninitialised memory was much less well developed when this was first written. |
I think this also comes from the classic UNIX approach of "heap goes up, stack comes down" and you use the "sbrk" (Stack Break) syscall to move the dividing line between them. If we don't have that flexibility, then yes, the heap might as well be a static. |
I was just about to merge this but I wonder if the example would be clearer with Anyway, thanks for the PR! bors r+ |
👎 Rejected by too few approved reviews |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Build succeeded: |
The linker needs to know how big the heap is, otherwise, it could place some of the global variables in the heap region.
This commit changes the example code to do that.