-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
Labels
proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
Description
Using a undefined symbol is a compiler error:
/home/shawn/git/zig/std/os/linux/index.zig:840:21: error: use of undeclared identifier 'SYS_mmap2'
return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @intCast(usize, fd), @bitCast(usize, offset / 4096));
It is possible to work around this by using buildin.arch and listing which arches have mmap2 (the 32-bit ones)
if (builtin.arch == builtin.Arch.armv7) {
return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @intCast(usize, fd), @bitCast(usize, offset / 4096));
But instead of making all these assumption with code like that it would be cleaner to be able to comptime branch of a identifier existing:
if (@defined(SYS_mmap2)) {
return syscall6(SYS_mmap2, @ptrToInt(address), length, prot, flags, @intCast(usize, fd), @bitCast(usize, offset / 4096));
} else {
return syscall6(SYS_mmap, @ptrToInt(address), length, prot, flags, @intCast(usize, fd), @bitCast(usize, offset));
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
proposalThis issue suggests modifications. If it also has the "accepted" label then it is planned.This issue suggests modifications. If it also has the "accepted" label then it is planned.