-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(libstore): add page size system feature
- Loading branch information
1 parent
c5621b9
commit 3d61f26
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const std = @import("std"); | ||
|
||
pub fn getDefaultSystemFeatures() callconv(.C) ?[*:null]const ?[*:0]const u8 { | ||
var list = std.ArrayList(?[*:0]const u8).init(std.heap.c_allocator); | ||
defer list.deinit(); | ||
|
||
const pgsize = std.heap.pageSize(); | ||
|
||
if (pgsize == std.heap.page_size_max) { | ||
list.append(std.fmt.allocPrintZ(std.heap.c_allocator, "pages-{d}k", .{pgsize / 1024}) catch return null) catch return null; | ||
} else { | ||
var i = pgsize; | ||
while (i < std.heap.page_size_max) : (i *= 2) { | ||
list.append(std.fmt.allocPrintZ(std.heap.c_allocator, "pages-{d}k", .{i / 1024}) catch return null) catch return null; | ||
} | ||
} | ||
|
||
return list.toOwnedSliceSentinel(null) catch return null; | ||
} | ||
|
||
comptime { | ||
@export(&getDefaultSystemFeatures, .{ .name = "nix_libstore_get_default_system_features" }); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pub const globals = @import("globals.zig"); | ||
|
||
comptime { | ||
_ = globals; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters