authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-19 17:28:18-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-11-19 17:28:18-05:00
log4dafdc00d5c0d73511d64c5edf7481c8fe254a61
tree0271d2f18d8044027610e5fb328be84ef54ae08d
parent9493738e5448ca166344a2d57abc44b29bb00081
signature Commit is signed but in an unrecognized format.

zig fmt


6 files changed, 18 insertions(+), 29 deletions(-)

std/c/freebsd.zig+2-5
...@@ -1,4 +1,3 @@...@@ -1,4 +1,3 @@
1
2const timespec = @import("../os/freebsd/index.zig").timespec;1const timespec = @import("../os/freebsd/index.zig").timespec;
32
4extern "c" fn __error() *c_int;3extern "c" fn __error() *c_int;
...@@ -18,7 +17,7 @@ pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usi...@@ -18,7 +17,7 @@ pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usi
18pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;17pub extern "c" fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) c_int;
1918
20/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.19/// Renamed from `kevent` to `Kevent` to avoid conflict with function name.
21pub const Kevent = extern struct.{20pub const Kevent = extern struct {
22 ident: usize,21 ident: usize,
23 filter: i16,22 filter: i16,
24 flags: u16,23 flags: u16,
...@@ -28,9 +27,7 @@ pub const Kevent = extern struct.{...@@ -28,9 +27,7 @@ pub const Kevent = extern struct.{
28 // TODO ext27 // TODO ext
29};28};
3029
3130pub const pthread_attr_t = extern struct {
32pub const pthread_attr_t = extern struct.{
33 __size: [56]u8,31 __size: [56]u8,
34 __align: c_long,32 __align: c_long,
35};33};
36
std/debug/index.zig+1-2
...@@ -1101,8 +1101,7 @@ pub const DebugInfo = switch (builtin.os) {...@@ -1101,8 +1101,7 @@ pub const DebugInfo = switch (builtin.os) {
1101 self.elf.close();1101 self.elf.close();
1102 }1102 }
1103 },1103 },
1104 builtin.Os.freebsd => struct.{1104 builtin.Os.freebsd => struct {},
1105 },
1106 else => @compileError("Unsupported OS"),1105 else => @compileError("Unsupported OS"),
1107};1106};
11081107
std/mem.zig+4-4
...@@ -475,8 +475,8 @@ test "readIntBE/LE" {...@@ -475,8 +475,8 @@ test "readIntBE/LE" {
475 assert(readIntBE(u8, []u8{0x32}) == 0x32);475 assert(readIntBE(u8, []u8{0x32}) == 0x32);
476 assert(readIntLE(u8, []u8{0x12}) == 0x12);476 assert(readIntLE(u8, []u8{0x12}) == 0x12);
477477
478 assert(readIntBE(u16, []u8{0x12, 0x34}) == 0x1234);478 assert(readIntBE(u16, []u8{ 0x12, 0x34 }) == 0x1234);
479 assert(readIntLE(u16, []u8{0x12, 0x34}) == 0x3412);479 assert(readIntLE(u16, []u8{ 0x12, 0x34 }) == 0x3412);
480480
481 assert(readIntBE(u72, []u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024);481 assert(readIntBE(u72, []u8{ 0x12, 0x34, 0x56, 0x78, 0x9a, 0xbc, 0xde, 0xf0, 0x24 }) == 0x123456789abcdef024);
482 assert(readIntLE(u72, []u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec);482 assert(readIntLE(u72, []u8{ 0xec, 0x10, 0x32, 0x54, 0x76, 0x98, 0xba, 0xdc, 0xfe }) == 0xfedcba9876543210ec);
...@@ -484,8 +484,8 @@ test "readIntBE/LE" {...@@ -484,8 +484,8 @@ test "readIntBE/LE" {
484 assert(readIntBE(i8, []u8{0xff}) == -1);484 assert(readIntBE(i8, []u8{0xff}) == -1);
485 assert(readIntLE(i8, []u8{0xfe}) == -2);485 assert(readIntLE(i8, []u8{0xfe}) == -2);
486486
487 assert(readIntBE(i16, []u8{0xff, 0xfd}) == -3);487 assert(readIntBE(i16, []u8{ 0xff, 0xfd }) == -3);
488 assert(readIntLE(i16, []u8{0xfc, 0xff}) == -4);488 assert(readIntLE(i16, []u8{ 0xfc, 0xff }) == -4);
489}489}
490490
491/// Writes an integer to memory with size equal to bytes.len. Pads with zeroes491/// Writes an integer to memory with size equal to bytes.len. Pads with zeroes
std/os/freebsd/index.zig+7-14
...@@ -377,7 +377,6 @@ pub const NOTE_FFCOPY = 0xc0000000;...@@ -377,7 +377,6 @@ pub const NOTE_FFCOPY = 0xc0000000;
377pub const NOTE_FFCTRLMASK = 0xc0000000;377pub const NOTE_FFCTRLMASK = 0xc0000000;
378pub const NOTE_FFLAGSMASK = 0x00ffffff;378pub const NOTE_FFLAGSMASK = 0x00ffffff;
379379
380
381/// low water mark380/// low water mark
382pub const NOTE_LOWAT = 0x00000001;381pub const NOTE_LOWAT = 0x00000001;
383382
...@@ -445,8 +444,6 @@ pub const NOTE_NSECONDS = 0x00000008;...@@ -445,8 +444,6 @@ pub const NOTE_NSECONDS = 0x00000008;
445/// timeout is absolute444/// timeout is absolute
446pub const NOTE_ABSTIME = 0x00000010;445pub const NOTE_ABSTIME = 0x00000010;
447446
448
449
450pub const TCGETS = 0x5401;447pub const TCGETS = 0x5401;
451pub const TCSETS = 0x5402;448pub const TCSETS = 0x5402;
452pub const TCSETSW = 0x5403;449pub const TCSETSW = 0x5403;
...@@ -528,7 +525,7 @@ pub fn WIFSIGNALED(s: i32) bool {...@@ -528,7 +525,7 @@ pub fn WIFSIGNALED(s: i32) bool {
528 return (unsigned(s) & 0xffff) -% 1 < 0xff;525 return (unsigned(s) & 0xffff) -% 1 < 0xff;
529}526}
530527
531pub const winsize = extern struct.{528pub const winsize = extern struct {
532 ws_row: u16,529 ws_row: u16,
533 ws_col: u16,530 ws_col: u16,
534 ws_xpixel: u16,531 ws_xpixel: u16,
...@@ -703,11 +700,11 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti...@@ -703,11 +700,11 @@ pub fn sigaction(sig: u6, noalias act: *const Sigaction, noalias oact: ?*Sigacti
703700
704const NSIG = 65;701const NSIG = 65;
705const sigset_t = [128 / @sizeOf(usize)]usize;702const sigset_t = [128 / @sizeOf(usize)]usize;
706const all_mask = []usize.{@maxValue(usize)};703const all_mask = []usize{@maxValue(usize)};
707const app_mask = []usize.{0xfffffffc7fffffff};704const app_mask = []usize{0xfffffffc7fffffff};
708705
709/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.706/// Renamed from `sigaction` to `Sigaction` to avoid conflict with the syscall.
710pub const Sigaction = struct.{707pub const Sigaction = struct {
711 // TODO: Adjust to use freebsd struct layout708 // TODO: Adjust to use freebsd struct layout
712 handler: extern fn (i32) void,709 handler: extern fn (i32) void,
713 mask: sigset_t,710 mask: sigset_t,
...@@ -717,7 +714,7 @@ pub const Sigaction = struct.{...@@ -717,7 +714,7 @@ pub const Sigaction = struct.{
717pub const SIG_ERR = @intToPtr(extern fn (i32) void, @maxValue(usize));714pub const SIG_ERR = @intToPtr(extern fn (i32) void, @maxValue(usize));
718pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);715pub const SIG_DFL = @intToPtr(extern fn (i32) void, 0);
719pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);716pub const SIG_IGN = @intToPtr(extern fn (i32) void, 1);
720pub const empty_sigset = []usize.{0} ** sigset_t.len;717pub const empty_sigset = []usize{0} ** sigset_t.len;
721718
722pub fn raise(sig: i32) usize {719pub fn raise(sig: i32) usize {
723 // TODO implement, see linux equivalent for what we want to try and do720 // 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 {...@@ -753,12 +750,12 @@ pub fn fstat(fd: i32, stat_buf: *Stat) usize {
753 return arch.syscall2(SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf));750 return arch.syscall2(SYS_fstat, @intCast(usize, fd), @ptrToInt(stat_buf));
754}751}
755752
756pub const iovec = extern struct.{753pub const iovec = extern struct {
757 iov_base: [*]u8,754 iov_base: [*]u8,
758 iov_len: usize,755 iov_len: usize,
759};756};
760757
761pub const iovec_const = extern struct.{758pub const iovec_const = extern struct {
762 iov_base: [*]const u8,759 iov_base: [*]const u8,
763 iov_len: usize,760 iov_len: usize,
764};761};
...@@ -790,13 +787,9 @@ pub fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) usize {...@@ -790,13 +787,9 @@ pub fn sysctlnametomib(name: [*]const u8, mibp: ?*c_int, sizep: ?*usize) usize {
790 return errnoWrap(c.sysctlnametomib(name, wibp, sizep));787 return errnoWrap(c.sysctlnametomib(name, wibp, sizep));
791}788}
792789
793
794
795/// Takes the return value from a syscall and formats it back in the way790/// Takes the return value from a syscall and formats it back in the way
796/// that the kernel represents it to libc. Errno was a mistake, let's make791/// that the kernel represents it to libc. Errno was a mistake, let's make
797/// it go away forever.792/// it go away forever.
798fn errnoWrap(value: isize) usize {793fn errnoWrap(value: isize) usize {
799 return @bitCast(usize, if (value == -1) -isize(c._errno().*) else value);794 return @bitCast(usize, if (value == -1) -isize(c._errno().*) else value);
800}795}
801
802
std/os/freebsd/x86_64.zig+3-3
...@@ -97,7 +97,7 @@ pub nakedcc fn restore_rt() void {...@@ -97,7 +97,7 @@ pub nakedcc fn restore_rt() void {
97 );97 );
98}98}
9999
100pub const msghdr = extern struct.{100pub const msghdr = extern struct {
101 msg_name: &u8,101 msg_name: &u8,
102 msg_namelen: socklen_t,102 msg_namelen: socklen_t,
103 msg_iov: &iovec,103 msg_iov: &iovec,
...@@ -110,7 +110,7 @@ pub const msghdr = extern struct.{...@@ -110,7 +110,7 @@ pub const msghdr = extern struct.{
110};110};
111111
112/// Renamed to Stat to not conflict with the stat function.112/// Renamed to Stat to not conflict with the stat function.
113pub const Stat = extern struct.{113pub const Stat = extern struct {
114 dev: u64,114 dev: u64,
115 ino: u64,115 ino: u64,
116 nlink: usize,116 nlink: usize,
...@@ -130,7 +130,7 @@ pub const Stat = extern struct.{...@@ -130,7 +130,7 @@ pub const Stat = extern struct.{
130 __unused: [3]isize,130 __unused: [3]isize,
131};131};
132132
133pub const timespec = extern struct.{133pub const timespec = extern struct {
134 tv_sec: isize,134 tv_sec: isize,
135 tv_nsec: isize,135 tv_nsec: isize,
136};136};
std/special/bootstrap.zig+1-1
...@@ -23,7 +23,7 @@ nakedcc fn _start() noreturn {...@@ -23,7 +23,7 @@ nakedcc fn _start() noreturn {
23 builtin.Arch.x86_64 => switch (builtin.os) {23 builtin.Arch.x86_64 => switch (builtin.os) {
24 builtin.Os.freebsd => {24 builtin.Os.freebsd => {
25 argc_ptr = asm ("lea (%%rdi), %[argc]"25 argc_ptr = asm ("lea (%%rdi), %[argc]"
26 : [argc] "=r" (-> [*]usize)26 : [argc] "=r" (-> [*]usize)
27 );27 );
28 },28 },
29 else => {29 else => {