diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-08-30 14:43:46 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-09-01 17:54:06 -0700 |
| commit | a2ff3a13fe22b5693bbd719bf4eaee06a9d6be57 (patch) | |
| tree | 626a60b82ce79406994ba0bb2ff61387979a4b33 /lib/std/os/linux | |
| parent | ca21cad2bf3dcd765753dc93d608e67ae3661f10 (diff) | |
| download | zig-a2ff3a13fe22b5693bbd719bf4eaee06a9d6be57.tar.gz zig-a2ff3a13fe22b5693bbd719bf4eaee06a9d6be57.zip | |
std, compiler-rt: remove test names where applicable
Tests with no names are executed when using `zig test` regardless of the
`--test-filter` used. Non-named tests should be used when simply
importing unit tests from another file. This allows `zig test` to find
all the appropriate tests, even when using `--test-filter`.
Diffstat (limited to 'lib/std/os/linux')
| -rw-r--r-- | lib/std/os/linux/arm-eabi.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/linux/arm64.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/bpf.zig | 15 | ||||
| -rw-r--r-- | lib/std/os/linux/bpf/btf.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/linux/bpf/helpers.zig | 5 | ||||
| -rw-r--r-- | lib/std/os/linux/i386.zig | 24 | ||||
| -rw-r--r-- | lib/std/os/linux/mips.zig | 1 | ||||
| -rw-r--r-- | lib/std/os/linux/powerpc.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/linux/powerpc64.zig | 2 | ||||
| -rw-r--r-- | lib/std/os/linux/sparc64.zig | 1 |
10 files changed, 33 insertions, 22 deletions
diff --git a/lib/std/os/linux/arm-eabi.zig b/lib/std/os/linux/arm-eabi.zig index 8f472b87f5..700761fe35 100644 --- a/lib/std/os/linux/arm-eabi.zig +++ b/lib/std/os/linux/arm-eabi.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const linux = std.os.linux; const iovec = std.os.iovec; const iovec_const = std.os.iovec_const; @@ -8,6 +9,7 @@ const sigset_t = linux.sigset_t; const uid_t = linux.uid_t; const gid_t = linux.gid_t; const pid_t = linux.pid_t; +const sockaddr = linux.sockaddr; pub fn syscall0(number: SYS) usize { return asm volatile ("svc #0" diff --git a/lib/std/os/linux/arm64.zig b/lib/std/os/linux/arm64.zig index 1c3033a226..13321f4595 100644 --- a/lib/std/os/linux/arm64.zig +++ b/lib/std/os/linux/arm64.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const linux = std.os.linux; const socklen_t = linux.socklen_t; const sockaddr = linux.sockaddr; diff --git a/lib/std/os/linux/bpf.zig b/lib/std/os/linux/bpf.zig index a1d2a86bb6..4cb9dbf5c5 100644 --- a/lib/std/os/linux/bpf.zig +++ b/lib/std/os/linux/bpf.zig @@ -5,6 +5,11 @@ const expectEqual = std.testing.expectEqual; const expectError = std.testing.expectError; const expect = std.testing.expect; +const linux = std.os.linux; +const fd_t = linux.fd_t; +const pid_t = linux.pid_t; +const getErrno = linux.getErrno; + pub const btf = @import("bpf/btf.zig"); pub const kern = @import("bpf/kern.zig"); @@ -1501,7 +1506,7 @@ pub fn map_create(map_type: MapType, key_size: u32, value_size: u32, max_entries attr.map_create.value_size = value_size; attr.map_create.max_entries = max_entries; - const rc = bpf(.map_create, &attr, @sizeOf(MapCreateAttr)); + const rc = linux.bpf(.map_create, &attr, @sizeOf(MapCreateAttr)); switch (errno(rc)) { .SUCCESS => return @intCast(fd_t, rc), .INVAL => return error.MapTypeOrAttrInvalid, @@ -1525,7 +1530,7 @@ pub fn map_lookup_elem(fd: fd_t, key: []const u8, value: []u8) !void { attr.map_elem.key = @ptrToInt(key.ptr); attr.map_elem.result.value = @ptrToInt(value.ptr); - const rc = bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr)); + const rc = linux.bpf(.map_lookup_elem, &attr, @sizeOf(MapElemAttr)); switch (errno(rc)) { .SUCCESS => return, .BADF => return error.BadFd, @@ -1547,7 +1552,7 @@ pub fn map_update_elem(fd: fd_t, key: []const u8, value: []const u8, flags: u64) attr.map_elem.result = .{ .value = @ptrToInt(value.ptr) }; attr.map_elem.flags = flags; - const rc = bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr)); + const rc = linux.bpf(.map_update_elem, &attr, @sizeOf(MapElemAttr)); switch (errno(rc)) { .SUCCESS => return, .@"2BIG" => return error.ReachedMaxEntries, @@ -1568,7 +1573,7 @@ pub fn map_delete_elem(fd: fd_t, key: []const u8) !void { attr.map_elem.map_fd = fd; attr.map_elem.key = @ptrToInt(key.ptr); - const rc = bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr)); + const rc = linux.bpf(.map_delete_elem, &attr, @sizeOf(MapElemAttr)); switch (errno(rc)) { .SUCCESS => return, .BADF => return error.BadFd, @@ -1631,7 +1636,7 @@ pub fn prog_load( attr.prog_load.log_level = l.level; } - const rc = bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr)); + const rc = linux.bpf(.prog_load, &attr, @sizeOf(ProgLoadAttr)); return switch (errno(rc)) { .SUCCESS => @intCast(fd_t, rc), .ACCES => error.UnsafeProgram, diff --git a/lib/std/os/linux/bpf/btf.zig b/lib/std/os/linux/bpf/btf.zig index 35eaf10561..8da3bbbe4c 100644 --- a/lib/std/os/linux/bpf/btf.zig +++ b/lib/std/os/linux/bpf/btf.zig @@ -1,3 +1,5 @@ +const std = @import("../../../std.zig"); + const magic = 0xeb9f; const version = 1; diff --git a/lib/std/os/linux/bpf/helpers.zig b/lib/std/os/linux/bpf/helpers.zig index 86c86c1ec5..3b0df9673c 100644 --- a/lib/std/os/linux/bpf/helpers.zig +++ b/lib/std/os/linux/bpf/helpers.zig @@ -1,5 +1,10 @@ +const std = @import("../../../std.zig"); const kern = @import("kern.zig"); +const PtRegs = @compileError("TODO missing os bits: PtRegs"); +const TcpHdr = @compileError("TODO missing os bits: TcpHdr"); +const SkFullSock = @compileError("TODO missing os bits: SkFullSock"); + // in BPF, all the helper calls // TODO: when https://github.com/ziglang/zig/issues/1717 is here, make a nice // function that uses the Helper enum diff --git a/lib/std/os/linux/i386.zig b/lib/std/os/linux/i386.zig index bedc2ec6c3..8efe21a8e4 100644 --- a/lib/std/os/linux/i386.zig +++ b/lib/std/os/linux/i386.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const linux = std.os.linux; const socklen_t = linux.socklen_t; const iovec = linux.iovec; @@ -8,6 +9,7 @@ const gid_t = linux.gid_t; const pid_t = linux.pid_t; const stack_t = linux.stack_t; const sigset_t = linux.sigset_t; +const sockaddr = linux.sockaddr; pub fn syscall0(number: SYS) usize { return asm volatile ("int $0x80" @@ -628,40 +630,28 @@ pub const LOCK = struct { pub const MAP = struct { /// Share changes pub const SHARED = 0x01; - /// Changes are private pub const PRIVATE = 0x02; - /// share + validate extension flags pub const SHARED_VALIDATE = 0x03; - /// Mask for type of mapping pub const TYPE = 0x0f; - /// Interpret addr exactly pub const FIXED = 0x10; - /// don't use a file - pub const ANONYMOUS = if (is_mips) 0x800 else 0x20; - + pub const ANONYMOUS = 0x20; /// populate (prefault) pagetables - pub const POPULATE = if (is_mips) 0x10000 else 0x8000; - + pub const POPULATE = 0x8000; /// do not block on IO - pub const NONBLOCK = if (is_mips) 0x20000 else 0x10000; - + pub const NONBLOCK = 0x10000; /// give out an address that is best suited for process/thread stacks - pub const STACK = if (is_mips) 0x40000 else 0x20000; - + pub const STACK = 0x20000; /// create a huge page mapping - pub const HUGETLB = if (is_mips) 0x80000 else 0x40000; - + pub const HUGETLB = 0x40000; /// perform synchronous page faults for the mapping pub const SYNC = 0x80000; - /// FIXED which doesn't unmap underlying mapping pub const FIXED_NOREPLACE = 0x100000; - /// For anonymous mmap, memory could be uninitialized pub const UNINITIALIZED = 0x4000000; diff --git a/lib/std/os/linux/mips.zig b/lib/std/os/linux/mips.zig index cc8334cf49..f4bdef609d 100644 --- a/lib/std/os/linux/mips.zig +++ b/lib/std/os/linux/mips.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const linux = std.os.linux; const socklen_t = linux.socklen_t; const iovec = linux.iovec; diff --git a/lib/std/os/linux/powerpc.zig b/lib/std/os/linux/powerpc.zig index 51c85d1472..e0c1d32390 100644 --- a/lib/std/os/linux/powerpc.zig +++ b/lib/std/os/linux/powerpc.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const linux = std.os.linux; const socklen_t = linux.socklen_t; const iovec = linux.iovec; @@ -8,6 +9,7 @@ const gid_t = linux.gid_t; const pid_t = linux.pid_t; const stack_t = linux.stack_t; const sigset_t = linux.sigset_t; +const sockaddr = linux.sockaddr; pub fn syscall0(number: SYS) usize { return asm volatile ( diff --git a/lib/std/os/linux/powerpc64.zig b/lib/std/os/linux/powerpc64.zig index 366ddbffa8..62586eb0f7 100644 --- a/lib/std/os/linux/powerpc64.zig +++ b/lib/std/os/linux/powerpc64.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const linux = std.os.linux; const socklen_t = linux.socklen_t; const iovec = linux.iovec; @@ -8,6 +9,7 @@ const gid_t = linux.gid_t; const pid_t = linux.pid_t; const stack_t = linux.stack_t; const sigset_t = linux.sigset_t; +const sockaddr = linux.sockaddr; pub fn syscall0(number: SYS) usize { return asm volatile ( diff --git a/lib/std/os/linux/sparc64.zig b/lib/std/os/linux/sparc64.zig index fd34b34ae4..aa50b8364b 100644 --- a/lib/std/os/linux/sparc64.zig +++ b/lib/std/os/linux/sparc64.zig @@ -1,4 +1,5 @@ const std = @import("../../std.zig"); +const maxInt = std.math.maxInt; const pid_t = linux.pid_t; const uid_t = linux.uid_t; const clock_t = linux.clock_t; |
