Skip to content

UEFI Allocator: Implement cores allocator_api #1632

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

phip1611
Copy link
Member

@phip1611 phip1611 commented Apr 14, 2025

Implement the allocator API (of core) for the UEFI allocator.

Checklist

  • Sensible git history (for example, squash "typo" or "fix" commits). See the Rewriting History guide for help.
  • Update the changelog (if necessary)

@phip1611 phip1611 marked this pull request as draft April 14, 2025 20:11
@phip1611 phip1611 closed this Apr 14, 2025
@phip1611 phip1611 reopened this Apr 14, 2025
@phip1611 phip1611 changed the title uefi allocator: implement core allocator api (Global) UEFI Allocator: Implement cores allocator_api Apr 14, 2025
@phip1611 phip1611 changed the title (Global) UEFI Allocator: Implement cores allocator_api UEFI Allocator: Implement cores allocator_api Apr 14, 2025
@phip1611 phip1611 mentioned this pull request Apr 10, 2025
15 tasks
@phip1611 phip1611 marked this pull request as ready for review April 19, 2025 09:52
@phip1611 phip1611 requested a review from nicholasbishop April 19, 2025 09:53
No need for this so far, but this provides downstream users more
flexibility.
#[cfg(feature = "unstable")]
unsafe impl core::alloc::Allocator for Allocator {
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, core::alloc::AllocError> {
let ptr = unsafe { <Allocator as GlobalAlloc>::alloc(self, layout) };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to do something here to handle ZSTs? I'm not familiar with the details of the Allocator trait, but I noticed this in the documentation:

In contrast to GlobalAlloc, Allocator allows zero-sized allocations. If an underlying allocator does not support this (like jemalloc) or responds by returning a null pointer (such as libc::malloc), this must be caught by the implementation.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm just not sure how to handle it :D but I can figure it out, I guess

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use case but you're right. I added it in a dedicated commit

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.

2 participants