Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Darwin: FSWatch API #1333

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
85b85ac
std/event/loop.zig: remove this very naughty break;
kristate Aug 7, 2018
6784e23
std/event/loop.zig: add event loop constants for working with the loop;
kristate Aug 7, 2018
23ef0cd
std/event/loop.zig: prepare loop for platform independence;
kristate Aug 7, 2018
4268c12
std/event/fs.zig: use platform independent loop API;
kristate Aug 7, 2018
e3bc2cc
event.loop: seperate loop implementations into three files;
kristate Aug 7, 2018
bf673c6
std/event.zig: gate loop.zig and fs.zig so that only platforms that w…
kristate Aug 7, 2018
abf5ae3
event.loop: update API for platform independence;
kristate Aug 7, 2018
69ebf20
event.loop: fd -> handle;
kristate Aug 7, 2018
3423067
event.loop: API: linuxModFd shouldn't be public;
kristate Aug 7, 2018
d6c5ac7
event.loop: API: posixFsRequest should be public;
kristate Aug 7, 2018
1cacfff
std/event/loop.zig: add simple event.loop API formality test;
kristate Aug 7, 2018
ea88e7a
CMakeLists.txt: update index for new files;
kristate Aug 7, 2018
93771eb
std/event/loop.zig: IRC exchange explaining commit; WIP;
kristate Aug 7, 2018
8fb5c22
std/event/loop/darwin.zig: remove all non darwin code;
kristate Aug 7, 2018
de7ec2d
event.loop: fd -> handle;
kristate Aug 7, 2018
788cbd0
std/event/loop/linux.zig: remove all non linux code;
kristate Aug 7, 2018
a084851
std/event/loop/darwin.zig: initial CFRunLoop -- WIP;
kristate Aug 7, 2018
0b801fe
std/event/loop/darwin.zig: moved code to callback;
kristate Aug 7, 2018
30865ef
std/c/darwin.zig: forgot to commit this guy -- CoreFoundation/CFRunLo…
kristate Aug 7, 2018
276472f
src/link.cpp: link against CoreFoundation on Darwin;
kristate Aug 7, 2018
5cc6b14
std/event/loop/darwin.zig: more gental use of CFLoop API;
kristate Aug 7, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ set(ZIG_STD_FILES
"event/lock.zig"
"event/locked.zig"
"event/loop.zig"
"event/loop/darwin.zig"
"event/loop/linux.zig"
"event/loop/windows.zig"
"event/rwlock.zig"
"event/rwlocked.zig"
"event/tcp.zig"
Expand Down
6 changes: 6 additions & 0 deletions src/link.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,12 @@ static void construct_linker_job_macho(LinkJob *lj) {
zig_panic("TODO");
}

// Always include CoreFoundation
// Is There a Better Way?
// https://github.com/ziglang/zig/issues/1349
lj->args.append("-framework");
lj->args.append("CoreFoundation");

for (size_t i = 0; i < g->darwin_frameworks.length; i += 1) {
lj->args.append("-framework");
lj->args.append(buf_ptr(g->darwin_frameworks.at(i)));
Expand Down
4 changes: 4 additions & 0 deletions std/c/darwin.zig
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
pub const CFRunLoop = @cImport({
@cInclude("CoreFoundation/CFRunLoop.h");
});

extern "c" fn __error() *c_int;
pub extern "c" fn _NSGetExecutablePath(buf: [*]u8, bufsize: *u32) c_int;

Expand Down
14 changes: 12 additions & 2 deletions std/event.zig
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
const builtin = @import("builtin");
pub const Channel = @import("event/channel.zig").Channel;
pub const Future = @import("event/future.zig").Future;
pub const Group = @import("event/group.zig").Group;
pub const Lock = @import("event/lock.zig").Lock;
pub const Locked = @import("event/locked.zig").Locked;
pub const RwLock = @import("event/rwlock.zig").RwLock;
pub const RwLocked = @import("event/rwlocked.zig").RwLocked;
pub const Loop = @import("event/loop.zig").Loop;
pub const fs = @import("event/fs.zig");
pub const Loop = switch (builtin.os) {
builtin.Os.linux,
builtin.Os.macosx,
builtin.Os.windows => @import("event/loop.zig").Loop,
else => @import("empty.zig"),
};
pub const fs = switch (builtin.os) {
builtin.Os.linux,
builtin.Os.macosx => @import("event/fs.zig"),
else => @import("empty.zig"),
};
pub const tcp = @import("event/tcp.zig");

test "import event tests" {
Expand Down
4 changes: 2 additions & 2 deletions std/event/fs.zig
Original file line number Diff line number Diff line change
Expand Up @@ -531,9 +531,9 @@ pub fn Watch(comptime V: type) type {
os.linux.EINVAL => unreachable,
os.linux.EFAULT => unreachable,
os.linux.EAGAIN => {
(await (async loop.linuxWaitFd(
(await (async loop.waitEvHandle(
inotify_fd,
os.linux.EPOLLET | os.linux.EPOLLIN,
event.Loop.EventFlags.READ,
) catch unreachable)) catch |err| {
const transformed_err = switch (err) {
error.InvalidFileDescriptor => unreachable,
Expand Down
Loading