authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-09 01:23:47-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-07-09 01:23:47-04:00
loga0c564d7621c1bf3f83be59d6f91056b0cfe1e16
treeab747d42e207bef97d76015dcfa45559fa6c9325
parent3ba451778fde48a5463180deea6d6539f91e1303

zig fmt


4 files changed, 237 insertions(+), 106 deletions(-)

std/c/darwin.zig+18-6
......@@ -7,11 +7,24 @@ pub extern "c" fn mach_absolute_time() u64;
77pub extern "c" fn mach_timebase_info(tinfo: ?*mach_timebase_info_data) void;
88
99pub extern "c" fn kqueue() c_int;
10pub extern "c" fn kevent(kq: c_int, changelist: [*]const Kevent, nchanges: c_int,
11 eventlist: [*]Kevent, nevents: c_int, timeout: ?*const timespec) c_int;
12
13pub extern "c" fn kevent64(kq: c_int, changelist: [*]const kevent64_s, nchanges: c_int,
14 eventlist: [*]kevent64_s, nevents: c_int, flags: c_uint, timeout: ?*const timespec) c_int;
10pub extern "c" fn kevent(
11 kq: c_int,
12 changelist: [*]const Kevent,
13 nchanges: c_int,
14 eventlist: [*]Kevent,
15 nevents: c_int,
16 timeout: ?*const timespec,
17) c_int;
18
19pub extern "c" fn kevent64(
20 kq: c_int,
21 changelist: [*]const kevent64_s,
22 nchanges: c_int,
23 eventlist: [*]kevent64_s,
24 nevents: c_int,
25 flags: c_uint,
26 timeout: ?*const timespec,
27) c_int;
1528
1629pub extern "c" fn sysctl(name: [*]c_int, namelen: c_uint, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
1730pub extern "c" fn sysctlbyname(name: [*]const u8, oldp: ?*c_void, oldlenp: ?*usize, newp: ?*c_void, newlen: usize) c_int;
......@@ -145,4 +158,3 @@ comptime {
145158 assert(@offsetOf(kevent64_s, "udata") == 24);
146159 assert(@offsetOf(kevent64_s, "ext") == 32);
147160}
148
std/os/darwin.zig+191-75
......@@ -264,17 +264,32 @@ pub const SIGUSR1 = 30;
264264/// user defined signal 2
265265pub const SIGUSR2 = 31;
266266
267pub const KEVENT_FLAG_NONE = 0x000; /// no flag value
268pub const KEVENT_FLAG_IMMEDIATE = 0x001; /// immediate timeout
269pub const KEVENT_FLAG_ERROR_EVENTS = 0x002; /// output events only include change
267/// no flag value
268pub const KEVENT_FLAG_NONE = 0x000;
270269
271pub const EV_ADD = 0x0001; /// add event to kq (implies enable)
272pub const EV_DELETE = 0x0002; /// delete event from kq
273pub const EV_ENABLE = 0x0004; /// enable event
274pub const EV_DISABLE = 0x0008; /// disable event (not reported)
270/// immediate timeout
271pub const KEVENT_FLAG_IMMEDIATE = 0x001;
275272
276pub const EV_ONESHOT = 0x0010; /// only report one occurrence
277pub const EV_CLEAR = 0x0020; /// clear event state after reporting
273/// output events only include change
274pub const KEVENT_FLAG_ERROR_EVENTS = 0x002;
275
276/// add event to kq (implies enable)
277pub const EV_ADD = 0x0001;
278
279/// delete event from kq
280pub const EV_DELETE = 0x0002;
281
282/// enable event
283pub const EV_ENABLE = 0x0004;
284
285/// disable event (not reported)
286pub const EV_DISABLE = 0x0008;
287
288/// only report one occurrence
289pub const EV_ONESHOT = 0x0010;
290
291/// clear event state after reporting
292pub const EV_CLEAR = 0x0020;
278293
279294/// force immediate event output
280295/// ... with or without EV_ERROR
......@@ -282,8 +297,11 @@ pub const EV_CLEAR = 0x0020; /// clear event state after reporting
282297/// on syscalls supporting flags
283298pub const EV_RECEIPT = 0x0040;
284299
285pub const EV_DISPATCH = 0x0080; /// disable event after reporting
286pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value
300/// disable event after reporting
301pub const EV_DISPATCH = 0x0080;
302
303/// unique kevent per udata value
304pub const EV_UDATA_SPECIFIC = 0x0100;
287305
288306/// ... in combination with EV_DELETE
289307/// will defer delete until udata-specific
......@@ -291,91 +309,178 @@ pub const EV_UDATA_SPECIFIC = 0x0100; /// unique kevent per udata value
291309/// returned to indicate the deferral
292310pub const EV_DISPATCH2 = EV_DISPATCH | EV_UDATA_SPECIFIC;
293311
294/// report that source has vanished
312/// report that source has vanished
295313/// ... only valid with EV_DISPATCH2
296314pub const EV_VANISHED = 0x0200;
297315
298pub const EV_SYSFLAGS = 0xF000; /// reserved by system
299pub const EV_FLAG0 = 0x1000; /// filter-specific flag
300pub const EV_FLAG1 = 0x2000; /// filter-specific flag
301pub const EV_EOF = 0x8000; /// EOF detected
302pub const EV_ERROR = 0x4000; /// error, data contains errno
316/// reserved by system
317pub const EV_SYSFLAGS = 0xF000;
318
319/// filter-specific flag
320pub const EV_FLAG0 = 0x1000;
321
322/// filter-specific flag
323pub const EV_FLAG1 = 0x2000;
324
325/// EOF detected
326pub const EV_EOF = 0x8000;
327
328/// error, data contains errno
329pub const EV_ERROR = 0x4000;
303330
304331pub const EV_POLL = EV_FLAG0;
305332pub const EV_OOBAND = EV_FLAG1;
306333
307334pub const EVFILT_READ = -1;
308335pub const EVFILT_WRITE = -2;
309pub const EVFILT_AIO = -3; /// attached to aio requests
310pub const EVFILT_VNODE = -4; /// attached to vnodes
311pub const EVFILT_PROC = -5; /// attached to struct proc
312pub const EVFILT_SIGNAL = -6; /// attached to struct proc
313pub const EVFILT_TIMER = -7; /// timers
314pub const EVFILT_MACHPORT = -8; /// Mach portsets
315pub const EVFILT_FS = -9; /// Filesystem events
316pub const EVFILT_USER = -10; /// User events
317pub const EVFILT_VM = -12; /// Virtual memory events
318
319pub const EVFILT_EXCEPT = -15; /// Exception events
336
337/// attached to aio requests
338pub const EVFILT_AIO = -3;
339
340/// attached to vnodes
341pub const EVFILT_VNODE = -4;
342
343/// attached to struct proc
344pub const EVFILT_PROC = -5;
345
346/// attached to struct proc
347pub const EVFILT_SIGNAL = -6;
348
349/// timers
350pub const EVFILT_TIMER = -7;
351
352/// Mach portsets
353pub const EVFILT_MACHPORT = -8;
354
355/// Filesystem events
356pub const EVFILT_FS = -9;
357
358/// User events
359pub const EVFILT_USER = -10;
360
361/// Virtual memory events
362pub const EVFILT_VM = -12;
363
364/// Exception events
365pub const EVFILT_EXCEPT = -15;
320366
321367pub const EVFILT_SYSCOUNT = 17;
322368
323369/// On input, NOTE_TRIGGER causes the event to be triggered for output.
324370pub const NOTE_TRIGGER = 0x01000000;
325371
326pub const NOTE_FFNOP = 0x00000000; /// ignore input fflags
327pub const NOTE_FFAND = 0x40000000; /// and fflags
328pub const NOTE_FFOR = 0x80000000; /// or fflags
329pub const NOTE_FFCOPY = 0xc0000000; /// copy fflags
330pub const NOTE_FFCTRLMASK = 0xc0000000; /// mask for operations
372/// ignore input fflags
373pub const NOTE_FFNOP = 0x00000000;
374
375/// and fflags
376pub const NOTE_FFAND = 0x40000000;
377
378/// or fflags
379pub const NOTE_FFOR = 0x80000000;
380
381/// copy fflags
382pub const NOTE_FFCOPY = 0xc0000000;
383
384/// mask for operations
385pub const NOTE_FFCTRLMASK = 0xc0000000;
331386pub const NOTE_FFLAGSMASK = 0x00ffffff;
332387
333pub const NOTE_LOWAT = 0x00000001; /// low water mark
388/// low water mark
389pub const NOTE_LOWAT = 0x00000001;
390
391/// OOB data
392pub const NOTE_OOB = 0x00000002;
393
394/// vnode was removed
395pub const NOTE_DELETE = 0x00000001;
396
397/// data contents changed
398pub const NOTE_WRITE = 0x00000002;
399
400/// size increased
401pub const NOTE_EXTEND = 0x00000004;
402
403/// attributes changed
404pub const NOTE_ATTRIB = 0x00000008;
405
406/// link count changed
407pub const NOTE_LINK = 0x00000010;
408
409/// vnode was renamed
410pub const NOTE_RENAME = 0x00000020;
411
412/// vnode access was revoked
413pub const NOTE_REVOKE = 0x00000040;
414
415/// No specific vnode event: to test for EVFILT_READ activation
416pub const NOTE_NONE = 0x00000080;
417
418/// vnode was unlocked by flock(2)
419pub const NOTE_FUNLOCK = 0x00000100;
420
421/// process exited
422pub const NOTE_EXIT = 0x80000000;
334423
335pub const NOTE_OOB = 0x00000002; /// OOB data
424/// process forked
425pub const NOTE_FORK = 0x40000000;
336426
337pub const NOTE_DELETE = 0x00000001; /// vnode was removed
338pub const NOTE_WRITE = 0x00000002; /// data contents changed
339pub const NOTE_EXTEND = 0x00000004; /// size increased
340pub const NOTE_ATTRIB = 0x00000008; /// attributes changed
341pub const NOTE_LINK = 0x00000010; /// link count changed
342pub const NOTE_RENAME = 0x00000020; /// vnode was renamed
343pub const NOTE_REVOKE = 0x00000040; /// vnode access was revoked
344pub const NOTE_NONE = 0x00000080; /// No specific vnode event: to test for EVFILT_READ activation
345pub const NOTE_FUNLOCK = 0x00000100; /// vnode was unlocked by flock(2)
427/// process exec'd
428pub const NOTE_EXEC = 0x20000000;
346429
347pub const NOTE_EXIT = 0x80000000; /// process exited
348pub const NOTE_FORK = 0x40000000; /// process forked
349pub const NOTE_EXEC = 0x20000000; /// process exec'd
350pub const NOTE_SIGNAL = 0x08000000; /// shared with EVFILT_SIGNAL
351pub const NOTE_EXITSTATUS = 0x04000000; /// exit status to be returned, valid for child process only
352pub const NOTE_EXIT_DETAIL = 0x02000000; /// provide details on reasons for exit
430/// shared with EVFILT_SIGNAL
431pub const NOTE_SIGNAL = 0x08000000;
353432
354pub const NOTE_PDATAMASK = 0x000fffff; /// mask for signal & exit status
355pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
433/// exit status to be returned, valid for child process only
434pub const NOTE_EXITSTATUS = 0x04000000;
356435
357pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
358pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
359pub const NOTE_EXIT_MEMORY = 0x00020000;
360pub const NOTE_EXIT_CSERROR = 0x00040000;
436/// provide details on reasons for exit
437pub const NOTE_EXIT_DETAIL = 0x02000000;
361438
439/// mask for signal & exit status
440pub const NOTE_PDATAMASK = 0x000fffff;
441pub const NOTE_PCTRLMASK = (~NOTE_PDATAMASK);
362442
363pub const NOTE_VM_PRESSURE = 0x80000000; /// will react on memory pressure
364pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000; /// will quit on memory pressure, possibly after cleaning up dirty state
365pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000; /// will quit immediately on memory pressure
366pub const NOTE_VM_ERROR = 0x10000000; /// there was an error
443pub const NOTE_EXIT_DETAIL_MASK = 0x00070000;
444pub const NOTE_EXIT_DECRYPTFAIL = 0x00010000;
445pub const NOTE_EXIT_MEMORY = 0x00020000;
446pub const NOTE_EXIT_CSERROR = 0x00040000;
367447
368pub const NOTE_SECONDS = 0x00000001; /// data is seconds
369pub const NOTE_USECONDS = 0x00000002; /// data is microseconds
370pub const NOTE_NSECONDS = 0x00000004; /// data is nanoseconds
371pub const NOTE_ABSOLUTE = 0x00000008; /// absolute timeout
448/// will react on memory pressure
449pub const NOTE_VM_PRESSURE = 0x80000000;
372450
373pub const NOTE_LEEWAY = 0x00000010; /// ext[1] holds leeway for power aware timers
374pub const NOTE_CRITICAL = 0x00000020; /// system does minimal timer coalescing
375pub const NOTE_BACKGROUND = 0x00000040; /// system does maximum timer coalescing
376pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
377pub const NOTE_MACHTIME = 0x00000100; /// data is mach absolute time units
451/// will quit on memory pressure, possibly after cleaning up dirty state
452pub const NOTE_VM_PRESSURE_TERMINATE = 0x40000000;
378453
454/// will quit immediately on memory pressure
455pub const NOTE_VM_PRESSURE_SUDDEN_TERMINATE = 0x20000000;
456
457/// there was an error
458pub const NOTE_VM_ERROR = 0x10000000;
459
460/// data is seconds
461pub const NOTE_SECONDS = 0x00000001;
462
463/// data is microseconds
464pub const NOTE_USECONDS = 0x00000002;
465
466/// data is nanoseconds
467pub const NOTE_NSECONDS = 0x00000004;
468
469/// absolute timeout
470pub const NOTE_ABSOLUTE = 0x00000008;
471
472/// ext[1] holds leeway for power aware timers
473pub const NOTE_LEEWAY = 0x00000010;
474
475/// system does minimal timer coalescing
476pub const NOTE_CRITICAL = 0x00000020;
477
478/// system does maximum timer coalescing
479pub const NOTE_BACKGROUND = 0x00000040;
480pub const NOTE_MACH_CONTINUOUS_TIME = 0x00000080;
481
482/// data is mach absolute time units
483pub const NOTE_MACHTIME = 0x00000100;
379484
380485fn wstatus(x: i32) i32 {
381486 return x & 0o177;
......@@ -503,12 +608,23 @@ pub fn kqueue() usize {
503608}
504609
505610pub fn kevent(kq: i32, changelist: []const Kevent, eventlist: []Kevent, timeout: ?*const timespec) usize {
506 return errnoWrap(c.kevent(kq, changelist.ptr, @intCast(c_int, changelist.len), eventlist.ptr, @intCast(c_int, eventlist.len), timeout,));
507}
508
509pub fn kevent64(kq: i32, changelist: []const kevent64_s, eventlist: []kevent64_s, flags: u32,
510 timeout: ?*const timespec) usize
511{
611 return errnoWrap(c.kevent(
612 kq,
613 changelist.ptr,
614 @intCast(c_int, changelist.len),
615 eventlist.ptr,
616 @intCast(c_int, eventlist.len),
617 timeout,
618 ));
619}
620
621pub fn kevent64(
622 kq: i32,
623 changelist: []const kevent64_s,
624 eventlist: []kevent64_s,
625 flags: u32,
626 timeout: ?*const timespec,
627) usize {
512628 return errnoWrap(c.kevent64(kq, changelist.ptr, changelist.len, eventlist.ptr, eventlist.len, flags, timeout));
513629}
514630
std/os/index.zig+8-5
......@@ -2810,7 +2810,7 @@ pub fn cpuCount(fallback_allocator: *mem.Allocator) CpuCountError!usize {
28102810 }
28112811}
28122812
2813pub const BsdKQueueError = error {
2813pub const BsdKQueueError = error{
28142814 /// The per-process limit on the number of open file descriptors has been reached.
28152815 ProcessFdQuotaExceeded,
28162816
......@@ -2831,7 +2831,7 @@ pub fn bsdKQueue() BsdKQueueError!i32 {
28312831 }
28322832}
28332833
2834pub const BsdKEventError = error {
2834pub const BsdKEventError = error{
28352835 /// The process does not have permission to register a filter.
28362836 AccessDenied,
28372837
......@@ -2845,9 +2845,12 @@ pub const BsdKEventError = error {
28452845 ProcessNotFound,
28462846};
28472847
2848pub fn bsdKEvent(kq: i32, changelist: []const posix.Kevent, eventlist: []posix.Kevent,
2849 timeout: ?*const posix.timespec) BsdKEventError!usize
2850{
2848pub fn bsdKEvent(
2849 kq: i32,
2850 changelist: []const posix.Kevent,
2851 eventlist: []posix.Kevent,
2852 timeout: ?*const posix.timespec,
2853) BsdKEventError!usize {
28512854 while (true) {
28522855 const rc = posix.kevent(kq, changelist, eventlist, timeout);
28532856 const err = posix.getErrno(rc);
std/special/compiler_rt/extendXfYf2_test.zig+20-20
......@@ -31,7 +31,7 @@ fn test__extendhfsf2(a: u16, expected: u32) void {
3131
3232 if (rep == expected) {
3333 if (rep & 0x7fffffff > 0x7f800000) {
34 return; // NaN is always unequal.
34 return; // NaN is always unequal.
3535 }
3636 if (x == @bitCast(f32, expected)) {
3737 return;
......@@ -86,33 +86,33 @@ test "extenddftf2" {
8686}
8787
8888test "extendhfsf2" {
89 test__extendhfsf2(0x7e00, 0x7fc00000); // qNaN
90 test__extendhfsf2(0x7f00, 0x7fe00000); // sNaN
91 test__extendhfsf2(0x7c01, 0x7f802000); // sNaN
89 test__extendhfsf2(0x7e00, 0x7fc00000); // qNaN
90 test__extendhfsf2(0x7f00, 0x7fe00000); // sNaN
91 test__extendhfsf2(0x7c01, 0x7f802000); // sNaN
9292
93 test__extendhfsf2(0, 0); // 0
94 test__extendhfsf2(0x8000, 0x80000000); // -0
93 test__extendhfsf2(0, 0); // 0
94 test__extendhfsf2(0x8000, 0x80000000); // -0
9595
96 test__extendhfsf2(0x7c00, 0x7f800000); // inf
97 test__extendhfsf2(0xfc00, 0xff800000); // -inf
96 test__extendhfsf2(0x7c00, 0x7f800000); // inf
97 test__extendhfsf2(0xfc00, 0xff800000); // -inf
9898
99 test__extendhfsf2(0x0001, 0x33800000); // denormal (min), 2**-24
100 test__extendhfsf2(0x8001, 0xb3800000); // denormal (min), -2**-24
99 test__extendhfsf2(0x0001, 0x33800000); // denormal (min), 2**-24
100 test__extendhfsf2(0x8001, 0xb3800000); // denormal (min), -2**-24
101101
102 test__extendhfsf2(0x03ff, 0x387fc000); // denormal (max), 2**-14 - 2**-24
103 test__extendhfsf2(0x83ff, 0xb87fc000); // denormal (max), -2**-14 + 2**-24
102 test__extendhfsf2(0x03ff, 0x387fc000); // denormal (max), 2**-14 - 2**-24
103 test__extendhfsf2(0x83ff, 0xb87fc000); // denormal (max), -2**-14 + 2**-24
104104
105 test__extendhfsf2(0x0400, 0x38800000); // normal (min), 2**-14
106 test__extendhfsf2(0x8400, 0xb8800000); // normal (min), -2**-14
105 test__extendhfsf2(0x0400, 0x38800000); // normal (min), 2**-14
106 test__extendhfsf2(0x8400, 0xb8800000); // normal (min), -2**-14
107107
108 test__extendhfsf2(0x7bff, 0x477fe000); // normal (max), 65504
109 test__extendhfsf2(0xfbff, 0xc77fe000); // normal (max), -65504
108 test__extendhfsf2(0x7bff, 0x477fe000); // normal (max), 65504
109 test__extendhfsf2(0xfbff, 0xc77fe000); // normal (max), -65504
110110
111 test__extendhfsf2(0x3c01, 0x3f802000); // normal, 1 + 2**-10
112 test__extendhfsf2(0xbc01, 0xbf802000); // normal, -1 - 2**-10
111 test__extendhfsf2(0x3c01, 0x3f802000); // normal, 1 + 2**-10
112 test__extendhfsf2(0xbc01, 0xbf802000); // normal, -1 - 2**-10
113113
114 test__extendhfsf2(0x3555, 0x3eaaa000); // normal, approx. 1/3
115 test__extendhfsf2(0xb555, 0xbeaaa000); // normal, approx. -1/3
114 test__extendhfsf2(0x3555, 0x3eaaa000); // normal, approx. 1/3
115 test__extendhfsf2(0xb555, 0xbeaaa000); // normal, approx. -1/3
116116}
117117
118118test "extendsftf2" {