Commit a0c564d762

Andrew Kelley <superjoe30@gmail.com>
2018-07-09 07:23:47
zig fmt
1 parent 3ba4517
Changed files (4)
std/c/darwin.zig
@@ -7,11 +7,24 @@ pub extern "c" fn mach_absolute_time() u64;
 pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
 
 pub extern "c" fn kqueue() c_int;
-pub extern "c" fn kevent(kq: c_int, changelist: [*]const Kevent, nchanges: c_int,
-    eventlist: [*]Kevent, nevents: c_int, timeout: ?*const timespec) c_int;
-
-pub extern "c" fn kevent64(kq: c_int, changelist: [*]const kevent64_s, nchanges: c_int,
-    eventlist: [*]kevent64_s, nevents: c_int, flags: c_uint, timeout: ?*const timespec) c_int;
+pub extern "c" fn kevent(
+    kq: c_int,
+    changelist: [*]const Kevent,
+    nchanges: c_int,
+    eventlist: [*]Kevent,
+    nevents: c_int,
+    timeout: ?*const timespec,
+) c_int;
+
+pub extern "c" fn kevent64(
+    kq: c_int,
+    changelist: [*]const kevent64_s,
+    nchanges: c_int,
+    eventlist: [*]kevent64_s,
+    nevents: c_int,
+    flags: c_uint,
+    timeout: ?*const timespec,
+) c_int;
 
 pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
 pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
@@ -145,4 +158,3 @@ comptime {
     assert(@offsetOf(kevent64_s, "udata") == 24);
     assert(@offsetOf(kevent64_s, "ext") == 32);
 }
-
std/os/darwin.zig
@@ -264,17 +264,32 @@ pub const SIGUSR1 = 30;
 /// user defined signal 2
 pub const SIGUSR2 = 31;
 
-pub const KEVENT_FLAG_NONE = 0x000; /// no flag value
-pub const KEVENT_FLAG_IMMEDIATE = 0x001; /// immediate timeout
-pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; /// output events only include change
+/// no flag value
+pub const KEVENT_FLAG_NONE = 0x000;
 
-pub const EV_ADD = 0x0001; /// add event to kq (implies enable)
-pub const EV_DELETE = 0x0002; /// delete event from kq
-pub const EV_ENABLE = 0x0004; /// enable event
-pub const EV_DISABLE = 0x0008; /// disable event (not reported)
+/// immediate timeout
+pub const KEVENT_FLAG_IMMEDIATE = 0x001;
 
-pub const EV_ONESHOT = 0x0010; /// only report one occurrence
-pub const EV_CLEAR = 0x0020; /// clear event state after reporting
+/// output events only include change
+pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
+
+/// add event to kq (implies enable)
+pub const EV_ADD = 0x0001;
+
+/// delete event from kq
+pub const EV_DELETE = 0x0002;
+
+/// enable event
+pub const EV_ENABLE = 0x0004;
+
+/// disable event (not reported)
+pub const EV_DISABLE = 0x0008;
+
+/// only report one occurrence
+pub const EV_ONESHOT = 0x0010;
+
+/// clear event state after reporting
+pub const EV_CLEAR = 0x0020;
 
 /// force immediate event output
 /// ... with or without EV_ERROR
@@ -282,8 +297,11 @@ pub const EV_CLEAR = 0x0020; /// clear event state after reporting
 ///     on syscalls supporting flags
 pub const EV_RECEIPT = 0x0040;
 
-pub const EV_DISPATCH = 0x0080; /// disable event after reporting
-pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value
+/// disable event after reporting
+pub const EV_DISPATCH = 0x0080;
+
+/// unique kevent per udata value
+pub const EV_UDATA_SPECIFIC = 0x0100;
 
 /// ... in combination with EV_DELETE
 /// will defer delete until udata-specific
@@ -291,91 +309,178 @@ pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value
 /// returned to indicate the deferral
 pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
 
-/// report that source has vanished 
+/// report that source has vanished
 /// ... only valid with EV_DISPATCH2
 pub const EV_VANISHED = 0x0200;
 
-pub const EV_SYSFLAGS = 0xF000; /// reserved by system
-pub const EV_FLAG0 = 0x1000; /// filter-specific flag
-pub const EV_FLAG1 = 0x2000; /// filter-specific flag
-pub const EV_EOF = 0x8000; /// EOF detected
-pub const EV_ERROR = 0x4000; /// error, data contains errno
+/// reserved by system
+pub const EV_SYSFLAGS = 0xF000;
+
+/// filter-specific flag
+pub const EV_FLAG0 = 0x1000;
+
+/// filter-specific flag
+pub const EV_FLAG1 = 0x2000;
+
+/// EOF detected
+pub const EV_EOF = 0x8000;
+
+/// error, data contains errno
+pub const EV_ERROR = 0x4000;
 
 pub const EV_POLL = EV_FLAG0;
 pub const EV_OOBAND = EV_FLAG1;
 
 pub const EVFILT_READ = -1;
 pub const EVFILT_WRITE = -2;
-pub const EVFILT_AIO = -3; /// attached to aio requests
-pub const EVFILT_VNODE = -4; /// attached to vnodes
-pub const EVFILT_PROC = -5; /// attached to struct proc
-pub const EVFILT_SIGNAL = -6; /// attached to struct proc
-pub const EVFILT_TIMER = -7; /// timers
-pub const EVFILT_MACHPORT = -8; /// Mach portsets
-pub const EVFILT_FS = -9; /// Filesystem events
-pub const EVFILT_USER = -10; /// User events
-pub const EVFILT_VM = -12; /// Virtual memory events
-
-pub const EVFILT_EXCEPT = -15; /// Exception events
+
+/// attached to aio requests
+pub const EVFILT_AIO = -3;
+
+/// attached to vnodes
+pub const EVFILT_VNODE = -4;
+
+/// attached to struct proc
+pub const EVFILT_PROC = -5;
+
+/// attached to struct proc
+pub const EVFILT_SIGNAL = -6;
+
+/// timers
+pub const EVFILT_TIMER = -7;
+
+/// Mach portsets
+pub const EVFILT_MACHPORT = -8;
+
+/// Filesystem events
+pub const EVFILT_FS = -9;
+
+/// User events
+pub const EVFILT_USER = -10;
+
+/// Virtual memory events
+pub const EVFILT_VM = -12;
+
+/// Exception events
+pub const EVFILT_EXCEPT = -15;
 
 pub const EVFILT_SYSCOUNT = 17;
 
 /// On input, NOTE_TRIGGER causes the event to be triggered for output.
 pub const NOTE_TRIGGER = 0x01000000;
 
-pub const NOTE_FFNOP      = 0x00000000; /// ignore input fflags
-pub const NOTE_FFAND      = 0x40000000; /// and fflags
-pub const NOTE_FFOR       = 0x80000000; /// or fflags
-pub const NOTE_FFCOPY     = 0xc0000000; /// copy fflags
-pub const NOTE_FFCTRLMASK = 0xc0000000; /// mask for operations
+/// ignore input fflags
+pub const NOTE_FFNOP = 0x00000000;
+
+/// and fflags
+pub const NOTE_FFAND = 0x40000000;
+
+/// or fflags
+pub const NOTE_FFOR = 0x80000000;
+
+/// copy fflags
+pub const NOTE_FFCOPY = 0xc0000000;
+
+/// mask for operations
+pub const NOTE_FFCTRLMASK = 0xc0000000;
 pub const NOTE_FFLAGSMASK = 0x00ffffff;
 
-pub const NOTE_LOWAT = 0x00000001; /// low water mark
+/// low water mark
+pub const NOTE_LOWAT = 0x00000001;
+
+/// OOB data
+pub const NOTE_OOB = 0x00000002;
+
+/// vnode was removed
+pub const NOTE_DELETE = 0x00000001;
+
+/// data contents changed
+pub const NOTE_WRITE = 0x00000002;
+
+/// size increased
+pub const NOTE_EXTEND = 0x00000004;
+
+/// attributes changed
+pub const NOTE_ATTRIB = 0x00000008;
+
+/// link count changed
+pub const NOTE_LINK = 0x00000010;
+
+/// vnode was renamed
+pub const NOTE_RENAME = 0x00000020;
+
+/// vnode access was revoked
+pub const NOTE_REVOKE = 0x00000040;
+
+/// No specific vnode event: to test for EVFILT_READ      activation
+pub const NOTE_NONE = 0x00000080;
+
+/// vnode was unlocked by flock(2)
+pub const NOTE_FUNLOCK = 0x00000100;
+
+/// process exited
+pub const NOTE_EXIT = 0x80000000;
 
-pub const NOTE_OOB = 0x00000002; /// OOB data
+/// process forked
+pub const NOTE_FORK = 0x40000000;
 
-pub const NOTE_DELETE = 0x00000001;      /// vnode was removed
-pub const NOTE_WRITE  = 0x00000002;      /// data contents changed
-pub const NOTE_EXTEND = 0x00000004;      /// size increased
-pub const NOTE_ATTRIB = 0x00000008;      /// attributes changed
-pub const NOTE_LINK   = 0x00000010;      /// link count changed
-pub const NOTE_RENAME = 0x00000020;      /// vnode was renamed
-pub const NOTE_REVOKE = 0x00000040;      /// vnode access was revoked
-pub const NOTE_NONE   = 0x00000080;      /// No specific vnode event: to test for EVFILT_READ      activation
-pub const NOTE_FUNLOCK    = 0x00000100;      /// vnode was unlocked by flock(2)
+/// process exec'd
+pub const NOTE_EXEC = 0x20000000;
 
-pub const NOTE_EXIT       = 0x80000000; /// process exited
-pub const NOTE_FORK       = 0x40000000; /// process forked
-pub const NOTE_EXEC       = 0x20000000; /// process exec'd
-pub const NOTE_SIGNAL     = 0x08000000; /// shared with EVFILT_SIGNAL
-pub const NOTE_EXITSTATUS     = 0x04000000; /// exit status to be returned, valid for child       process only
-pub const NOTE_EXIT_DETAIL    = 0x02000000; /// provide details on reasons for exit
+/// shared with EVFILT_SIGNAL
+pub const NOTE_SIGNAL = 0x08000000;
 
-pub const NOTE_PDATAMASK  = 0x000fffff; /// mask for signal & exit status
-pub const NOTE_PCTRLMASK  = (~NOTE_PDATAMASK);
+/// exit status to be returned, valid for child       process only
+pub const NOTE_EXITSTATUS = 0x04000000;
 
-pub const NOTE_EXIT_DETAIL_MASK       = 0x00070000;
-pub const NOTE_EXIT_DECRYPTFAIL       = 0x00010000;
-pub const NOTE_EXIT_MEMORY        = 0x00020000;
-pub const NOTE_EXIT_CSERROR       = 0x00040000;
+/// provide details on reasons for exit
+pub const NOTE_EXIT_DETAIL = 0x02000000;
 
+/// mask for signal & exit status
+pub const NOTE_PDATAMASK = 0x000fffff;
+pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
 
-pub const NOTE_VM_PRESSURE            = 0x80000000;              /// will react on memory          pressure
-pub const NOTE_VM_PRESSURE_TERMINATE      = 0x40000000;             /// will quit on memory       pressure, possibly after cleaning up dirty state
-pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE   = 0x20000000;     /// will quit immediately on      memory pressure
-pub const NOTE_VM_ERROR               = 0x10000000;              /// there was an error
+pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
+pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
+pub const NOTE_EXIT_MEMORY = 0x00020000;
+pub const NOTE_EXIT_CSERROR = 0x00040000;
 
-pub const NOTE_SECONDS    = 0x00000001; /// data is seconds        
-pub const NOTE_USECONDS   = 0x00000002; /// data is microseconds  
-pub const NOTE_NSECONDS   = 0x00000004; /// data is nanoseconds  
-pub const NOTE_ABSOLUTE   = 0x00000008; /// absolute timeout    
+/// will react on memory          pressure
+pub const NOTE_VM_PRESSURE = 0x80000000;
 
-pub const NOTE_LEEWAY = 0x00000010; /// ext[1] holds leeway for power aware timers
-pub const NOTE_CRITICAL   = 0x00000020; /// system does minimal timer coalescing
-pub const NOTE_BACKGROUND = 0x00000040; /// system does maximum timer coalescing
-pub const NOTE_MACH_CONTINUOUS_TIME   = 0x00000080;
-pub const NOTE_MACHTIME =   0x00000100;             /// data is mach absolute time units
+/// will quit on memory       pressure, possibly after cleaning up dirty state
+pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
 
+/// will quit immediately on      memory pressure
+pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
+
+/// there was an error
+pub const NOTE_VM_ERROR = 0x10000000;
+
+/// data is seconds
+pub const NOTE_SECONDS = 0x00000001;
+
+/// data is microseconds
+pub const NOTE_USECONDS = 0x00000002;
+
+/// data is nanoseconds
+pub const NOTE_NSECONDS = 0x00000004;
+
+/// absolute timeout
+pub const NOTE_ABSOLUTE = 0x00000008;
+
+/// ext[1] holds leeway for power aware timers
+pub const NOTE_LEEWAY = 0x00000010;
+
+/// system does minimal timer coalescing
+pub const NOTE_CRITICAL = 0x00000020;
+
+/// system does maximum timer coalescing
+pub const NOTE_BACKGROUND = 0x00000040;
+pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
+
+/// data is mach absolute time units
+pub const NOTE_MACHTIME = 0x00000100;
 
 fn wstatus(x: i32) i32 {
     return x & 0o177;
@@ -503,12 +608,23 @@ pub fn kqueue() usize {
 }
 
 pub fn kevent(kq: i32, changelist: []const Kevent, eventlist: []Kevent, timeout: ?*const timespec) usize {
-    return errnoWrap(c.kevent(kq, changelist.ptr, @intCast(c_int, changelist.len), eventlist.ptr, @intCast(c_int, eventlist.len), timeout,));
-}
-
-pub fn kevent64(kq: i32, changelist: []const kevent64_s, eventlist: []kevent64_s, flags: u32,
-    timeout: ?*const timespec) usize
-{
+    return errnoWrap(c.kevent(
+        kq,
+        changelist.ptr,
+        @intCast(c_int, changelist.len),
+        eventlist.ptr,
+        @intCast(c_int, eventlist.len),
+        timeout,
+    ));
+}
+
+pub fn kevent64(
+    kq: i32,
+    changelist: []const kevent64_s,
+    eventlist: []kevent64_s,
+    flags: u32,
+    timeout: ?*const timespec,
+) usize {
     return errnoWrap(c.kevent64(kq, changelist.ptr, changelist.len, eventlist.ptr, eventlist.len, flags, timeout));
 }
 
std/os/index.zig
@@ -2810,7 +2810,7 @@ pub fn cpuCount(fallback_allocator: *mem.Allocator) CpuCountError!usize {
     }
 }
 
-pub const BsdKQueueError = error {
+pub const BsdKQueueError = error{
     /// The per-process limit on the number of open file descriptors has been reached.
     ProcessFdQuotaExceeded,
 
@@ -2831,7 +2831,7 @@ pub fn bsdKQueue() BsdKQueueError!i32 {
     }
 }
 
-pub const BsdKEventError = error {
+pub const BsdKEventError = error{
     /// The process does not have permission to register a filter.
     AccessDenied,
 
@@ -2845,9 +2845,12 @@ pub const BsdKEventError = error {
     ProcessNotFound,
 };
 
-pub fn bsdKEvent(kq: i32, changelist: []const posix.Kevent, eventlist: []posix.Kevent,
-    timeout: ?*const posix.timespec) BsdKEventError!usize
-{
+pub fn bsdKEvent(
+    kq: i32,
+    changelist: []const posix.Kevent,
+    eventlist: []posix.Kevent,
+    timeout: ?*const posix.timespec,
+) BsdKEventError!usize {
     while (true) {
         const rc = posix.kevent(kq, changelist, eventlist, timeout);
         const err = posix.getErrno(rc);
std/special/compiler_rt/extendXfYf2_test.zig
@@ -31,7 +31,7 @@ fn test__extendhfsf2(a: u16, expected: u32) void {
 
     if (rep == expected) {
         if (rep & 0x7fffffff > 0x7f800000) {
-            return;  // NaN is always unequal.
+            return; // NaN is always unequal.
         }
         if (x == @bitCast(f32, expected)) {
             return;
@@ -86,33 +86,33 @@ test "extenddftf2" {
 }
 
 test "extendhfsf2" {
-    test__extendhfsf2(0x7e00, 0x7fc00000);  // qNaN
-    test__extendhfsf2(0x7f00, 0x7fe00000);  // sNaN
-    test__extendhfsf2(0x7c01, 0x7f802000);  // sNaN
+    test__extendhfsf2(0x7e00, 0x7fc00000); // qNaN
+    test__extendhfsf2(0x7f00, 0x7fe00000); // sNaN
+    test__extendhfsf2(0x7c01, 0x7f802000); // sNaN
 
-    test__extendhfsf2(0, 0);  // 0
-    test__extendhfsf2(0x8000, 0x80000000);  // -0
+    test__extendhfsf2(0, 0); // 0
+    test__extendhfsf2(0x8000, 0x80000000); // -0
 
-    test__extendhfsf2(0x7c00, 0x7f800000);  // inf
-    test__extendhfsf2(0xfc00, 0xff800000);  // -inf
+    test__extendhfsf2(0x7c00, 0x7f800000); // inf
+    test__extendhfsf2(0xfc00, 0xff800000); // -inf
 
-    test__extendhfsf2(0x0001, 0x33800000);  // denormal (min), 2**-24
-    test__extendhfsf2(0x8001, 0xb3800000);  // denormal (min), -2**-24
+    test__extendhfsf2(0x0001, 0x33800000); // denormal (min), 2**-24
+    test__extendhfsf2(0x8001, 0xb3800000); // denormal (min), -2**-24
 
-    test__extendhfsf2(0x03ff, 0x387fc000);  // denormal (max), 2**-14 - 2**-24
-    test__extendhfsf2(0x83ff, 0xb87fc000);  // denormal (max), -2**-14 + 2**-24
+    test__extendhfsf2(0x03ff, 0x387fc000); // denormal (max), 2**-14 - 2**-24
+    test__extendhfsf2(0x83ff, 0xb87fc000); // denormal (max), -2**-14 + 2**-24
 
-    test__extendhfsf2(0x0400, 0x38800000);  // normal (min), 2**-14
-    test__extendhfsf2(0x8400, 0xb8800000);  // normal (min), -2**-14
+    test__extendhfsf2(0x0400, 0x38800000); // normal (min), 2**-14
+    test__extendhfsf2(0x8400, 0xb8800000); // normal (min), -2**-14
 
-    test__extendhfsf2(0x7bff, 0x477fe000);  // normal (max), 65504
-    test__extendhfsf2(0xfbff, 0xc77fe000);  // normal (max), -65504
+    test__extendhfsf2(0x7bff, 0x477fe000); // normal (max), 65504
+    test__extendhfsf2(0xfbff, 0xc77fe000); // normal (max), -65504
 
-    test__extendhfsf2(0x3c01, 0x3f802000);  // normal, 1 + 2**-10
-    test__extendhfsf2(0xbc01, 0xbf802000);  // normal, -1 - 2**-10
+    test__extendhfsf2(0x3c01, 0x3f802000); // normal, 1 + 2**-10
+    test__extendhfsf2(0xbc01, 0xbf802000); // normal, -1 - 2**-10
 
-    test__extendhfsf2(0x3555, 0x3eaaa000);  // normal, approx. 1/3
-    test__extendhfsf2(0xb555, 0xbeaaa000);  // normal, approx. -1/3
+    test__extendhfsf2(0x3555, 0x3eaaa000); // normal, approx. 1/3
+    test__extendhfsf2(0xb555, 0xbeaaa000); // normal, approx. -1/3
 }
 
 test "extendsftf2" {