Commit ac12f0df71

Andrew Kelley <superjoe30@gmail.com>
2018-08-08 04:23:26
fix linux regressions
1 parent 60955fe
Changed files (2)
std
std/event/fs.zig
@@ -170,7 +170,10 @@ pub async fn preadv(loop: *event.Loop, fd: os.FileHandle, data: []const []u8, of
 }
 
 pub async fn open(
-    loop: *event.Loop, path: []const u8, flags: u32, mode: os.File.Mode,
+    loop: *event.Loop,
+    path: []const u8,
+    flags: u32,
+    mode: os.File.Mode,
 ) os.File.OpenError!os.FileHandle {
     // workaround for https://github.com/ziglang/zig/issues/1194
     suspend {
@@ -375,7 +378,7 @@ pub fn Watch(comptime V: type) type {
         os_data: OsData,
 
         const OsData = switch (builtin.os) {
-            builtin.Os.macosx => struct{
+            builtin.Os.macosx => struct {
                 file_table: FileTable,
                 table_lock: event.Lock,
 
@@ -477,11 +480,11 @@ pub fn Watch(comptime V: type) type {
             var close_op_consumed = false;
             defer if (!close_op_consumed) close_op.finish();
 
-            const flags = posix.O_SYMLINK|posix.O_EVTONLY;
+            const flags = posix.O_SYMLINK | posix.O_EVTONLY;
             const mode = 0;
             const fd = try await (async open(self.channel.loop, resolved_path, flags, mode) catch unreachable);
             close_op.setHandle(fd);
-            
+
             var put_data: *OsData.Put = undefined;
             const putter = try async self.kqPutEvents(close_op, value, &put_data);
             close_op_consumed = true;
@@ -549,7 +552,10 @@ pub fn Watch(comptime V: type) type {
                     error.ProcessNotFound => unreachable,
                     error.AccessDenied, error.SystemResources => {
                         // TODO https://github.com/ziglang/zig/issues/769
-                        const casted_err = @errSetCast(error{AccessDenied,SystemResources}, err);
+                        const casted_err = @errSetCast(error{
+                            AccessDenied,
+                            SystemResources,
+                        }, err);
                         await (async self.channel.put(casted_err) catch unreachable);
                     },
                 }
@@ -667,7 +673,10 @@ pub fn Watch(comptime V: type) type {
                                     }
                                 };
                                 if (user_value) |v| {
-                                    await (async channel.put(Self.Event{ .CloseWrite = v }) catch unreachable);
+                                    await (async channel.put(Event{
+                                        .id = WatchEventId.CloseWrite,
+                                        .data = v,
+                                    }) catch unreachable);
                                 }
                             }
                         }
@@ -691,7 +700,7 @@ pub fn Watch(comptime V: type) type {
                                 error.FileDescriptorIncompatibleWithEpoll => unreachable,
                                 error.Unexpected => unreachable,
                             };
-                            await (async channel.put(Self.Event{ .Err = transformed_err }) catch unreachable);
+                            await (async channel.put(transformed_err) catch unreachable);
                         };
                     },
                     else => unreachable,
std/event/loop.zig
@@ -54,10 +54,7 @@ pub const Loop = struct {
         };
 
         pub const Basic = switch (builtin.os) {
-            builtin.Os.macosx => struct {
-                base: ResumeNode,
-                kev: posix.Kevent,
-            },
+            builtin.Os.macosx => MacOsBasic,
             builtin.Os.linux => struct {
                 base: ResumeNode,
             },
@@ -66,6 +63,11 @@ pub const Loop = struct {
             },
             else => @compileError("unsupported OS"),
         };
+
+        const MacOsBasic = struct {
+            base: ResumeNode,
+            kev: posix.Kevent,
+        };
     };
 
     /// After initialization, call run().
@@ -261,7 +263,7 @@ pub const Loop = struct {
                 self.os_data.fs_kevent_wake = posix.Kevent{
                     .ident = 0,
                     .filter = posix.EVFILT_USER,
-                    .flags = posix.EV_ADD|posix.EV_ENABLE,
+                    .flags = posix.EV_ADD | posix.EV_ENABLE,
                     .fflags = posix.NOTE_TRIGGER,
                     .data = 0,
                     .udata = undefined,
@@ -270,7 +272,7 @@ pub const Loop = struct {
                 self.os_data.fs_kevent_wait = posix.Kevent{
                     .ident = 0,
                     .filter = posix.EVFILT_USER,
-                    .flags = posix.EV_ADD|posix.EV_CLEAR,
+                    .flags = posix.EV_ADD | posix.EV_CLEAR,
                     .fflags = 0,
                     .data = 0,
                     .udata = undefined,
@@ -429,7 +431,7 @@ pub const Loop = struct {
         var kev = posix.Kevent{
             .ident = ident,
             .filter = filter,
-            .flags = posix.EV_ADD|posix.EV_ENABLE|posix.EV_CLEAR,
+            .flags = posix.EV_ADD | posix.EV_ENABLE | posix.EV_CLEAR,
             .fflags = fflags,
             .data = 0,
             .udata = @ptrToInt(&resume_node.base),