From 7a3f0a55d9a481f260935f26426ee4508d44cb18 Mon Sep 17 00:00:00 2001 From: Greg V Date: Wed, 17 Oct 2018 18:01:00 +0300 Subject: Add freebsd to more things --- std/debug/index.zig | 2 ++ 1 file changed, 2 insertions(+) (limited to 'std/debug/index.zig') diff --git a/std/debug/index.zig b/std/debug/index.zig index e6d8fe3fc6..cabeba14f7 100644 --- a/std/debug/index.zig +++ b/std/debug/index.zig @@ -1078,6 +1078,8 @@ pub const DebugInfo = switch (builtin.os) { self.elf.close(); } }, + builtin.Os.freebsd => struct.{ + }, else => @compileError("Unsupported OS"), }; -- cgit v1.2.3 From 4dafdc00d5c0d73511d64c5edf7481c8fe254a61 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 19 Nov 2018 17:28:18 -0500 Subject: zig fmt --- std/c/freebsd.zig | 7 ++----- std/debug/index.zig | 3 +-- std/mem.zig | 8 ++++---- std/os/freebsd/index.zig | 21 +++++++-------------- std/os/freebsd/x86_64.zig | 6 +++--- std/special/bootstrap.zig | 2 +- 6 files changed, 18 insertions(+), 29 deletions(-) (limited to 'std/debug/index.zig') diff --git a/std/c/freebsd.zig b/std/c/freebsd.zig index 6eb34929b5..421e964827 100644 --- a/std/c/freebsd.zig +++ b/std/c/freebsd.zig @@ -1,4 +1,3 @@ - const timespec = @import("../os/freebsd/index.zig").timespec; extern "c" fn __error() *c_int; @@ -18,7 +17,7 @@ pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usi pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int; /// Renamed from `kevent` to `Kevent` to avoid conflict with function name. -pub const Kevent = extern struct.{ +pub const Kevent = extern struct { ident: usize, filter: i16, flags: u16, @@ -28,9 +27,7 @@ pub const Kevent = extern struct.{ // TODO ext }; - -pub const pthread_attr_t = extern struct.{ +pub const pthread_attr_t = extern struct { __size: [56]u8, __align: c_long, }; - diff --git a/std/debug/index.zig b/std/debug/index.zig index a3509b3117..722f95ccb0 100644 --- a/std/debug/index.zig +++ b/std/debug/index.zig @@ -1101,8 +1101,7 @@ pub const DebugInfo = switch (builtin.os) { self.elf.close(); } }, - builtin.Os.freebsd => struct.{ - }, + builtin.Os.freebsd => struct {}, else => @compileError("Unsupported OS"), }; diff --git a/std/mem.zig b/std/mem.zig index 6b37dfe401..6b115a56f6 100644 --- a/std/mem.zig +++ b/std/mem.zig @@ -475,8 +475,8 @@ test "readIntBE/LE" { assert(readIntBE(u8, []u8{0x32}) == 0x32); assert(readIntLE(u8, []u8{0x12}) == 0x12); - assert(readIntBE(u16, []u8{0x12, 0x34}) == 0x1234); - assert(readIntLE(u16, []u8{0x12, 0x34}) == 0x3412); + assert(readIntBE(u16, []u8{ 0x12, 0x34 }) == 0x1234); + assert(readIntLE(u16, []u8{ 0x12, 0x34 }) == 0x3412); assert(readIntBE(u72, []u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024); assert(readIntLE(u72, []u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec); @@ -484,8 +484,8 @@ test "readIntBE/LE" { assert(readIntBE(i8, []u8{0xff}) == -1); assert(readIntLE(i8, []u8{0xfe}) == -2); - assert(readIntBE(i16, []u8{0xff, 0xfd}) == -3); - assert(readIntLE(i16, []u8{0xfc, 0xff}) == -4); + assert(readIntBE(i16, []u8{ 0xff, 0xfd }) == -3); + assert(readIntLE(i16, []u8{ 0xfc, 0xff }) == -4); } /// Writes an integer to memory with size equal to bytes.len. Pads with zeroes diff --git a/std/os/freebsd/index.zig b/std/os/freebsd/index.zig index 1793379fb5..75389fc403 100644 --- a/std/os/freebsd/index.zig +++ b/std/os/freebsd/index.zig @@ -377,7 +377,6 @@ pub const NOTE_FFCOPY = 0xc0000000; pub const NOTE_FFCTRLMASK = 0xc0000000; pub const NOTE_FFLAGSMASK = 0x00ffffff; - /// low water mark pub const NOTE_LOWAT = 0x00000001; @@ -445,8 +444,6 @@ pub const NOTE_NSECONDS = 0x00000008; /// timeout is absolute pub const NOTE_ABSTIME = 0x00000010; - - pub const TCGETS = 0x5401; pub const TCSETS = 0x5402; pub const TCSETSW = 0x5403; @@ -528,7 +525,7 @@ pub fn WIFSIGNALED(s: i32) bool { return (unsigned(s) & 0xffff) -% 1 < 0xff; } -pub const winsize = extern struct.{ +pub const winsize = extern struct { ws_row: u16, ws_col: u16, ws_xpixel: u16, @@ -703,11 +700,11 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti const NSIG = 65; const sigset_t = [128 / @sizeOf(usize)]usize; -const all_mask = []usize.{@maxValue(usize)}; -const app_mask = []usize.{0xfffffffc7fffffff}; +const all_mask = []usize{@maxValue(usize)}; +const app_mask = []usize{0xfffffffc7fffffff}; /// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall. -pub const Sigaction = struct.{ +pub const Sigaction = struct { // TODO: Adjust to use freebsd struct layout handler: extern fn (i32) void, mask: sigset_t, @@ -717,7 +714,7 @@ pub const Sigaction = struct.{ pub const SIG_ERR = @intToPtr(extern fn (i32) void, @maxValue(usize)); pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0); pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1); -pub const empty_sigset = []usize.{0} ** sigset_t.len; +pub const empty_sigset = []usize{0} ** sigset_t.len; pub fn raise(sig: i32) usize { // TODO implement, see linux equivalent for what we want to try and do @@ -753,12 +750,12 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize { return arch.syscall2(SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf)); } -pub const iovec = extern struct.{ +pub const iovec = extern struct { iov_base: [*]u8, iov_len: usize, }; -pub const iovec_const = extern struct.{ +pub const iovec_const = extern struct { iov_base: [*]const u8, iov_len: usize, }; @@ -790,13 +787,9 @@ pub fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) usize { return errnoWrap(c.sysctlnametomib(name, wibp, sizep)); } - - /// Takes the return value from a syscall and formats it back in the way /// that the kernel represents it to libc. Errno was a mistake, let's make /// it go away forever. fn errnoWrap(value: isize) usize { return @bitCast(usize, if (value == -1) -isize(c._errno().*) else value); } - - diff --git a/std/os/freebsd/x86_64.zig b/std/os/freebsd/x86_64.zig index 28ae2d5471..20a6710596 100644 --- a/std/os/freebsd/x86_64.zig +++ b/std/os/freebsd/x86_64.zig @@ -97,7 +97,7 @@ pub nakedcc fn restore_rt() void { ); } -pub const msghdr = extern struct.{ +pub const msghdr = extern struct { msg_name: &u8, msg_namelen: socklen_t, msg_iov: &iovec, @@ -110,7 +110,7 @@ pub const msghdr = extern struct.{ }; /// Renamed to Stat to not conflict with the stat function. -pub const Stat = extern struct.{ +pub const Stat = extern struct { dev: u64, ino: u64, nlink: usize, @@ -130,7 +130,7 @@ pub const Stat = extern struct.{ __unused: [3]isize, }; -pub const timespec = extern struct.{ +pub const timespec = extern struct { tv_sec: isize, tv_nsec: isize, }; diff --git a/std/special/bootstrap.zig b/std/special/bootstrap.zig index 070a26bf71..a15be317ab 100644 --- a/std/special/bootstrap.zig +++ b/std/special/bootstrap.zig @@ -23,7 +23,7 @@ nakedcc fn _start() noreturn { builtin.Arch.x86_64 => switch (builtin.os) { builtin.Os.freebsd => { argc_ptr = asm ("lea (%%rdi), %[argc]" - : [argc] "=r" (-> [*]usize) + : [argc] "=r" (-> [*]usize) ); }, else => { -- cgit v1.2.3