Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

UEFI Allocator: Implementcoresallocator_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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
phip1611 wants to merge3 commits intomainfromuefi-alloc-api

Conversation

phip1611
Copy link
Member

@phip1611phip1611 commentedApr 14, 2025
edited
Loading

Implement the allocator API (ofcore) for the UEFI allocator.

Checklist

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

@phip1611phip1611 marked this pull request as draftApril 14, 2025 20:11
@phip1611phip1611 reopened thisApr 14, 2025
@phip1611phip1611 changed the titleuefi allocator: implement core allocator api(Global) UEFI Allocator: Implementcoresallocator_apiApr 14, 2025
@phip1611phip1611 changed the title(Global) UEFI Allocator: Implementcoresallocator_apiUEFI Allocator: Implementcoresallocator_apiApr 14, 2025
@phip1611phip1611 mentioned this pull requestApr 10, 2025
15 tasks
@phip1611phip1611 marked this pull request as ready for reviewApril 19, 2025 09:52
No need for this so far, but this provides downstream users moreflexibility.
#[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) };

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 theAllocator trait, but I noticed this in thedocumentation:

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

Copy link
MemberAuthor

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
MemberAuthor

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

@@ -53,6 +51,44 @@ mod bootservices {
}
unsafe { boot::free_pool(ptr) }.unwrap();
}

/// Tests getting the memory map.
pub fn test_memory_map() {

Choose a reason for hiding this comment

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

Moving this function seems unrelated to the rest of the PR -- could you drop this change or move it to a separate PR?

unsafe impl core::alloc::Allocator for Allocator {
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, core::alloc::AllocError> {
// Stable alternative for Layout::dangling()
fn dangling_for_layout(layout: Layout) -> NonNull<u8> {

Choose a reason for hiding this comment

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

Since this is gated byunstable anyway, I think we might as well enablealloc_layout_extra and useLayout::dangling directly.

@phip1611phip1611 mentioned this pull requestMay 5, 2025
10 tasks
@phip1611
Copy link
MemberAuthor

Closing for the same reason as discussed here:#1606 (comment)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@nicholasbishopnicholasbishopnicholasbishop left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@phip1611@nicholasbishop

[8]ページ先頭

©2009-2025 Movatter.jp