feature. See also
. The project being documented here (as the example) is the Zig library itself.
tls.mmap_tls
inline fn mmap_tls(length: usize) usize
File
Code
inline fn mmap_tls(length: usize) usize {
const prot: linux.PROT = .{ .READ = true, .WRITE = true };
const flags: linux.MAP = .{ .TYPE = .PRIVATE, .ANONYMOUS = true };
if (@hasField(linux.SYS, "mmap2")) {
return @call(.always_inline, linux.syscall6, .{
.mmap2,
0,
length,
@as(u32, @bitCast(prot)),
@as(u32, @bitCast(flags)),
@as(usize, @bitCast(@as(isize, -1))),
0,
});
} else {
// it takes a single pointer to an array of arguments instead.
return if (native_arch == .s390x) @call(.always_inline, linux.syscall1, .{
.mmap,
@intFromPtr(&[_]usize{
0,
length,
@as(u32, @bitCast(prot)),
@as(u32, @bitCast(flags)),
@as(usize, @bitCast(@as(isize, -1))),
0,
}),
}) else @call(.always_inline, linux.syscall6, .{
.mmap,
0,
length,
@as(u32, @bitCast(prot)),
@as(u32, @bitCast(flags)),
@as(usize, @bitCast(@as(isize, -1))),
0,
});
}
}