aboutsummaryrefslogtreecommitdiff
path: root/lib/std/os/linux.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-02-07 06:21:51 -0800
committerGitHub <noreply@github.com>2025-02-07 06:21:51 -0800
commit6a6e72fff820fb641aa1b00700f6835430dae72e (patch)
treeea70863e08ba9167cfe954287691cce98716d918 /lib/std/os/linux.zig
parent8ad0732954df80f0f9a0248525c2bded7e82ba27 (diff)
parentb8f5cfed457726a77082b7ffe6672b6066c0a66e (diff)
downloadzig-6a6e72fff820fb641aa1b00700f6835430dae72e.tar.gz
zig-6a6e72fff820fb641aa1b00700f6835430dae72e.zip
Merge pull request #20511 from archbirdplus
runtime page size detection rework GeneralPurposeAllocator to reduce active mapping count Allocator VTable API update
Diffstat (limited to 'lib/std/os/linux.zig')
-rw-r--r--lib/std/os/linux.zig22
1 files changed, 18 insertions, 4 deletions
diff --git a/lib/std/os/linux.zig b/lib/std/os/linux.zig
index 365fb9f05f..1183408694 100644
--- a/lib/std/os/linux.zig
+++ b/lib/std/os/linux.zig
@@ -305,6 +305,13 @@ pub const MAP = switch (native_arch) {
else => @compileError("missing std.os.linux.MAP constants for this architecture"),
};
+pub const MREMAP = packed struct(u32) {
+ MAYMOVE: bool = false,
+ FIXED: bool = false,
+ DONTUNMAP: bool = false,
+ _: u29 = 0,
+};
+
pub const O = switch (native_arch) {
.x86_64 => packed struct(u32) {
ACCMODE: ACCMODE = .RDONLY,
@@ -892,10 +899,6 @@ pub fn umount2(special: [*:0]const u8, flags: u32) usize {
pub fn mmap(address: ?[*]u8, length: usize, prot: usize, flags: MAP, fd: i32, offset: i64) usize {
if (@hasField(SYS, "mmap2")) {
- // Make sure the offset is also specified in multiples of page size
- if ((offset & (MMAP2_UNIT - 1)) != 0)
- return @bitCast(-@as(isize, @intFromEnum(E.INVAL)));
-
return syscall6(
.mmap2,
@intFromPtr(address),
@@ -934,6 +937,17 @@ pub fn mprotect(address: [*]const u8, length: usize, protection: usize) usize {
return syscall3(.mprotect, @intFromPtr(address), length, protection);
}
+pub fn mremap(old_addr: ?[*]const u8, old_len: usize, new_len: usize, flags: MREMAP, new_addr: ?[*]const u8) usize {
+ return syscall5(
+ .mremap,
+ @intFromPtr(old_addr),
+ old_len,
+ new_len,
+ @as(u32, @bitCast(flags)),
+ @intFromPtr(new_addr),
+ );
+}
+
pub const MSF = struct {
pub const ASYNC = 1;
pub const INVALIDATE = 2;