1- const std = @import ("../../ std.zig" );
1+ const std = @import ("../std.zig" );
22
33const mem = std .mem ;
44const uefi = std .os .uefi ;
@@ -7,13 +7,16 @@ const Allocator = mem.Allocator;
77
88const assert = std .debug .assert ;
99
10+ pub var global_page_allocator = PageAllocator {};
11+ pub var global_pool_allocator = PoolAllocator {};
12+
1013/// Allocates memory in pages.
1114///
1215/// This allocator is backed by `allocatePages` and is therefore only suitable for usage when Boot Services are available.
13- pub const Page = struct {
16+ pub const PageAllocator = struct {
1417 memory_type : uefi.tables.MemoryType = .LoaderData ,
1518
16- pub fn allocator (self : * Page ) Allocator {
19+ pub fn allocator (self : * PageAllocator ) Allocator {
1720 return Allocator {
1821 .ptr = self ,
1922 .vtable = & vtable ,
@@ -36,7 +39,7 @@ pub const Page = struct {
3639 _ = alignment ;
3740 _ = ret_addr ;
3841
39- const self : * Page = @ptrCast (@alignCast (ctx ));
42+ const self : * PageAllocator = @ptrCast (@alignCast (ctx ));
4043
4144 assert (len > 0 );
4245 const pages = mem .alignForward (usize , len , 4096 ) / 4096 ;
@@ -55,7 +58,7 @@ pub const Page = struct {
5558 _ = alignment ;
5659 _ = ret_addr ;
5760
58- const self : * Page = @ptrCast (@alignCast (ctx ));
61+ const self : * PageAllocator = @ptrCast (@alignCast (ctx ));
5962
6063 // If the buffer was originally larger than the new length, we can grow or shrink it in place.
6164 const original_len = mem .alignForward (usize , buf .len , 4096 );
@@ -109,10 +112,10 @@ pub const Page = struct {
109112/// Supports the full std.mem.Allocator interface, including up to page alignment.
110113///
111114/// This allocator is backed by `allocatePool` and is therefore only suitable for usage when Boot Services are available.
112- pub const Pool = struct {
115+ pub const PoolAllocator = struct {
113116 memory_type : uefi.tables.MemoryType = .LoaderData ,
114117
115- pub fn allocator (self : * Pool ) Allocator {
118+ pub fn allocator (self : * PoolAllocator ) Allocator {
116119 return Allocator {
117120 .ptr = self ,
118121 .vtable = & vtable ,
@@ -142,7 +145,7 @@ pub const Pool = struct {
142145 ret_addr : usize ,
143146 ) ? [* ]u8 {
144147 _ = ret_addr ;
145- const self : * Pool = @ptrCast (@alignCast (ctx ));
148+ const self : * PoolAllocator = @ptrCast (@alignCast (ctx ));
146149
147150 assert (len > 0 );
148151
@@ -218,10 +221,10 @@ pub const Pool = struct {
218221/// Asserts all allocations are at most 8 byte aligned. This is the highest alignment UEFI will give us directly.
219222///
220223/// This allocator is backed by `allocatePool` and is therefore only suitable for usage when Boot Services are available.
221- pub const RawPool = struct {
224+ pub const RawPoolAllocator = struct {
222225 memory_type : uefi.tables.MemoryType = .LoaderData ,
223226
224- pub fn allocator (self : * RawPool ) Allocator {
227+ pub fn allocator (self : * RawPoolAllocator ) Allocator {
225228 return Allocator {
226229 .ptr = self ,
227230 .vtable = & vtable ,
@@ -242,7 +245,7 @@ pub const RawPool = struct {
242245 ret_addr : usize ,
243246 ) ? [* ]u8 {
244247 _ = ret_addr ;
245- const self : * RawPool = @ptrCast (@alignCast (ctx ));
248+ const self : * RawPoolAllocator = @ptrCast (@alignCast (ctx ));
246249
247250 // UEFI pool allocations are 8 byte aligned, so we can't do better than that.
248251 std .debug .assert (@intFromEnum (alignment ) <= 3 );
0 commit comments