authorgravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-11-17 01:08:04+02:00
committergravatar for alex_naskos@hotmail.comAlexandros Naskos <alex_naskos@hotmail.com> 2020-12-14 21:03:50+02:00
logda007f318b50e908d47fad8769667f5ed1264089
treeb36c3a5bc055ae8762caa0005217656274b468b2
parent5112ab8233449c2061237a178087992cbf74dfea
signaturelock-open Commit is signed but in an unrecognized format.

Implement std.fs.Watch on Windows

Use unmanaged containers in std.fs.Watch

4 files changed, 147 insertions(+), 175 deletions(-)

lib/std/fs/watch.zig+138-168
......@@ -3,7 +3,7 @@
33// This file is part of [zig](https://ziglang.org/), which is MIT licensed.
44// The MIT license requires this copyright notice to be included in all copies
55// and substantial portions of the software.
6const std = @import("../std.zig");
6const std = @import("std");
77const builtin = @import("builtin");
88const event = std.event;
99const assert = std.debug.assert;
......@@ -24,14 +24,6 @@ const WatchEventId = enum {
2424 Delete,
2525};
2626
27fn eqlString(a: []const u16, b: []const u16) bool {
28 return mem.eql(u16, a, b);
29}
30
31fn hashString(s: []const u16) u32 {
32 return @truncate(u32, std.hash.Wyhash.hash(0, mem.sliceAsBytes(s)));
33}
34
3527const WatchEventError = error{
3628 UserResourceLimitReached,
3729 SystemResources,
......@@ -69,21 +61,15 @@ pub fn Watch(comptime V: type) type {
6961 const WindowsOsData = struct {
7062 table_lock: event.Lock,
7163 dir_table: DirTable,
72 all_putters: std.atomic.Queue(Put),
73 ref_count: std.atomic.Int(usize),
74
75 const Put = struct {
76 putter: anyframe,
77 cancelled: bool = false,
78 };
64 cancelled: bool = false,
7965
80 const DirTable = std.StringHashMap(*Dir);
81 const FileTable = std.HashMap([]const u16, V, hashString, eqlString);
66 const DirTable = std.StringHashMapUnmanaged(*Dir);
67 const FileTable = std.StringHashMapUnmanaged(V);
8268
8369 const Dir = struct {
8470 putter_frame: @Frame(windowsDirReader),
8571 file_table: FileTable,
86 table_lock: event.Lock,
72 dir_handle: os.windows.HANDLE,
8773 };
8874 };
8975
......@@ -94,8 +80,8 @@ pub fn Watch(comptime V: type) type {
9480 table_lock: event.Lock,
9581 cancelled: bool = false,
9682
97 const WdTable = std.AutoHashMap(i32, Dir);
98 const FileTable = std.StringHashMap(V);
83 const WdTable = std.AutoHashMapUnmanaged(i32, Dir);
84 const FileTable = std.StringHashMapUnmanaged(V);
9985
10086 const Dir = struct {
10187 dirname: []const u8,
......@@ -148,10 +134,9 @@ pub fn Watch(comptime V: type) type {
148134 .os_data = OsData{
149135 .table_lock = event.Lock{},
150136 .dir_table = OsData.DirTable.init(allocator),
151 .ref_count = std.atomic.Int(usize).init(1),
152 .all_putters = std.atomic.Queue(WindowsOsData.Put).init(),
153137 },
154138 };
139
155140 var buf = try allocator.alloc(Event.Error!Event, event_buf_count);
156141 self.channel.init(buf);
157142 return self;
......@@ -160,12 +145,15 @@ pub fn Watch(comptime V: type) type {
160145 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => {
161146 self.* = Self{
162147 .allocator = allocator,
163 .channel = channel,
148 .channel = undefined,
164149 .os_data = OsData{
165150 .table_lock = event.Lock.init(),
166151 .file_table = OsData.FileTable.init(allocator),
167152 },
168153 };
154
155 var buf = try allocator.alloc(Event.Error!Event, event_buf_count);
156 self.channel.init(buf);
169157 return self;
170158 },
171159 else => @compileError("Unsupported OS"),
......@@ -206,35 +194,38 @@ pub fn Watch(comptime V: type) type {
206194 self.allocator.destroy(self);
207195 },
208196 .windows => {
209 while (self.os_data.all_putters.get()) |putter_node| {
210 putter_node.cancelled = true;
211 await putter_node.frame;
197 self.os_data.cancelled = true;
198 var dir_it = self.os_data.dir_table.iterator();
199 while (dir_it.next()) |dir_entry| {
200 if (windows.kernel32.CancelIoEx(dir_entry.value.dir_handle, null) != 0) {
201 // We canceled the pending ReadDirectoryChangesW operation, but our
202 // frame is still suspending, now waiting indefinitely.
203 // Thus, it is safe to resume it ourslves
204 resume dir_entry.value.putter_frame;
205 } else {
206 std.debug.assert(windows.kernel32.GetLastError() == .NOT_FOUND);
207 // We are at another suspend point, we can await safely for the
208 // function to exit the loop
209 await dir_entry.value.putter_frame;
210 }
211
212 self.allocator.free(dir_entry.key);
213 var file_it = dir_entry.value.file_table.iterator();
214 while (file_it.next()) |file_entry| {
215 self.allocator.free(file_entry.key);
216 }
217 dir_entry.value.file_table.deinit(self.allocator);
218 self.allocator.destroy(dir_entry.value);
212219 }
213 self.deref();
220 self.os_data.dir_table.deinit(self.allocator);
221 self.allocator.free(self.channel.buffer_nodes);
222 self.channel.deinit();
223 self.allocator.destroy(self);
214224 },
215225 else => @compileError("Unsupported OS"),
216226 }
217227 }
218228
219 fn ref(self: *Self) void {
220 _ = self.os_data.ref_count.incr();
221 }
222
223 fn deref(self: *Self) void {
224 if (self.os_data.ref_count.decr() == 1) {
225 self.os_data.table_lock.deinit();
226 var it = self.os_data.dir_table.iterator();
227 while (it.next()) |entry| {
228 self.allocator.free(entry.key);
229 self.allocator.destroy(entry.value);
230 }
231 self.os_data.dir_table.deinit();
232 self.channel.deinit();
233 self.allocator.destroy(self.channel.buffer_nodes);
234 self.allocator.destroy(self);
235 }
236 }
237
238229 pub fn addFile(self: *Self, file_path: []const u8, value: V) !?V {
239230 switch (builtin.os.tag) {
240231 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => return addFileKEvent(self, file_path, value),
......@@ -342,7 +333,7 @@ pub fn Watch(comptime V: type) type {
342333 const held = self.os_data.table_lock.acquire();
343334 defer held.release();
344335
345 const gop = try self.os_data.wd_table.getOrPut(wd);
336 const gop = try self.os_data.wd_table.getOrPut(self.allocator, wd);
346337 if (!gop.found_existing) {
347338 gop.entry.value = OsData.Dir{
348339 .dirname = try self.allocator.dupe(u8, dirname),
......@@ -351,7 +342,7 @@ pub fn Watch(comptime V: type) type {
351342 }
352343
353344 const dir = &gop.entry.value;
354 const file_table_gop = try dir.file_table.getOrPut(basename);
345 const file_table_gop = try dir.file_table.getOrPut(self.allocator, basename);
355346 if (file_table_gop.found_existing) {
356347 const prev_value = file_table_gop.entry.value;
357348 file_table_gop.entry.value = value;
......@@ -365,89 +356,67 @@ pub fn Watch(comptime V: type) type {
365356
366357 fn addFileWindows(self: *Self, file_path: []const u8, value: V) !?V {
367358 // TODO we might need to convert dirname and basename to canonical file paths ("short"?)
368 const dirname = try self.allocator.dupe(u8, std.fs.path.dirname(file_path) orelse ".");
369 var dirname_consumed = false;
370 defer if (!dirname_consumed) self.allocator.free(dirname);
371
372 const dirname_utf16le = try std.unicode.utf8ToUtf16LeWithNull(self.allocator, dirname);
373 defer self.allocator.free(dirname_utf16le);
359 const dirname = std.fs.path.dirname(file_path) orelse ".";
360 var dirname_path_space: windows.PathSpace = undefined;
361 dirname_path_space.len = try std.unicode.utf8ToUtf16Le(&dirname_path_space.data, dirname);
362 dirname_path_space.data[dirname_path_space.len] = 0;
374363
375 // TODO https://github.com/ziglang/zig/issues/265
376364 const basename = std.fs.path.basename(file_path);
377 const basename_utf16le_null = try std.unicode.utf8ToUtf16LeWithNull(self.allocator, basename);
378 var basename_utf16le_null_consumed = false;
379 defer if (!basename_utf16le_null_consumed) self.allocator.free(basename_utf16le_null);
380 const basename_utf16le_no_null = basename_utf16le_null[0 .. basename_utf16le_null.len - 1];
381
382 const dir_handle = try windows.OpenFile(dirname_utf16le, .{
383 .dir = std.fs.cwd().fd,
384 .access_mask = windows.FILE_LIST_DIRECTORY,
385 .creation = windows.FILE_OPEN,
386 .io_mode = .blocking,
387 .open_dir = true,
388 });
389 var dir_handle_consumed = false;
390 defer if (!dir_handle_consumed) windows.CloseHandle(dir_handle);
365 var basename_path_space: windows.PathSpace = undefined;
366 basename_path_space.len = try std.unicode.utf8ToUtf16Le(&basename_path_space.data, basename);
367 basename_path_space.data[basename_path_space.len] = 0;
391368
392369 const held = self.os_data.table_lock.acquire();
393370 defer held.release();
394371
395 const gop = try self.os_data.dir_table.getOrPut(dirname);
372 const gop = try self.os_data.dir_table.getOrPut(self.allocator, dirname);
396373 if (gop.found_existing) {
397 const dir = gop.kv.value;
398 const held_dir_lock = dir.table_lock.acquire();
399 defer held_dir_lock.release();
374 const dir = gop.entry.value;
400375
401 const file_gop = try dir.file_table.getOrPut(basename_utf16le_no_null);
376 const file_gop = try dir.file_table.getOrPut(self.allocator, basename);
402377 if (file_gop.found_existing) {
403 const prev_value = file_gop.kv.value;
404 file_gop.kv.value = value;
378 const prev_value = file_gop.entry.value;
379 file_gop.entry.value = value;
405380 return prev_value;
406381 } else {
407 file_gop.kv.value = value;
408 basename_utf16le_null_consumed = true;
382 file_gop.entry.value = value;
383 file_gop.entry.key = try self.allocator.dupe(u8, basename);
409384 return null;
410385 }
411386 } else {
412387 errdefer _ = self.os_data.dir_table.remove(dirname);
388 const dir_handle = try windows.OpenFile(dirname_path_space.span(), .{
389 .dir = std.fs.cwd().fd,
390 .access_mask = windows.FILE_LIST_DIRECTORY,
391 .creation = windows.FILE_OPEN,
392 .io_mode = .evented,
393 .open_dir = true,
394 });
395 errdefer windows.CloseHandle(dir_handle);
396
413397 const dir = try self.allocator.create(OsData.Dir);
414398 errdefer self.allocator.destroy(dir);
415399
400 gop.entry.key = try self.allocator.dupe(u8, dirname);
401 errdefer self.allocator.free(gop.entry.key);
402
416403 dir.* = OsData.Dir{
417404 .file_table = OsData.FileTable.init(self.allocator),
418 .table_lock = event.Lock.init(),
419405 .putter_frame = undefined,
406 .dir_handle = dir_handle,
420407 };
421 gop.kv.value = dir;
422 assert((try dir.file_table.put(basename_utf16le_no_null, value)) == null);
423 basename_utf16le_null_consumed = true;
424
425 dir.putter_frame = async self.windowsDirReader(dir_handle, dir);
426 dir_handle_consumed = true;
427
428 dirname_consumed = true;
429
408 gop.entry.value = dir;
409 try dir.file_table.put(self.allocator, try self.allocator.dupe(u8, basename), value);
410 dir.putter_frame = async self.windowsDirReader(dir, gop.entry.key);
430411 return null;
431412 }
432413 }
433414
434 fn windowsDirReader(self: *Self, dir_handle: windows.HANDLE, dir: *OsData.Dir) void {
435 self.ref();
436 defer self.deref();
437
438 defer os.close(dir_handle);
439
440 var putter_node = std.atomic.Queue(anyframe).Node{
441 .data = .{ .putter = @frame() },
442 .prev = null,
443 .next = null,
444 };
445 self.os_data.all_putters.put(&putter_node);
446 defer _ = self.os_data.all_putters.remove(&putter_node);
447
415 fn windowsDirReader(self: *Self, dir: *OsData.Dir, dirname: []const u8) void {
416 defer os.close(dir.dir_handle);
448417 var resume_node = Loop.ResumeNode.Basic{
449418 .base = Loop.ResumeNode{
450 .id = Loop.ResumeNode.Id.Basic,
419 .id = .Basic,
451420 .handle = @frame(),
452421 .overlapped = windows.OVERLAPPED{
453422 .Internal = 0,
......@@ -458,81 +427,75 @@ pub fn Watch(comptime V: type) type {
458427 },
459428 },
460429 };
461 var event_buf: [4096]u8 align(@alignOf(windows.FILE_NOTIFY_INFORMATION)) = undefined;
462430
463 // TODO handle this error not in the channel but in the setup
464 _ = windows.CreateIoCompletionPort(
465 dir_handle,
466 global_event_loop.os_data.io_port,
467 undefined,
468 undefined,
469 ) catch |err| {
470 self.channel.put(err);
471 return;
472 };
431 var event_buf: [4096]u8 align(@alignOf(windows.FILE_NOTIFY_INFORMATION)) = undefined;
473432
474 while (!putter_node.data.cancelled) {
475 {
476 // TODO only 1 beginOneEvent for the whole function
477 global_event_loop.beginOneEvent();
478 errdefer global_event_loop.finishOneEvent();
479 errdefer {
480 _ = windows.kernel32.CancelIoEx(dir_handle, &resume_node.base.overlapped);
481 }
482 suspend {
483 _ = windows.kernel32.ReadDirectoryChangesW(
484 dir_handle,
485 &event_buf,
486 @intCast(windows.DWORD, event_buf.len),
487 windows.FALSE, // watch subtree
488 windows.FILE_NOTIFY_CHANGE_FILE_NAME | windows.FILE_NOTIFY_CHANGE_DIR_NAME |
489 windows.FILE_NOTIFY_CHANGE_ATTRIBUTES | windows.FILE_NOTIFY_CHANGE_SIZE |
490 windows.FILE_NOTIFY_CHANGE_LAST_WRITE | windows.FILE_NOTIFY_CHANGE_LAST_ACCESS |
491 windows.FILE_NOTIFY_CHANGE_CREATION | windows.FILE_NOTIFY_CHANGE_SECURITY,
492 null, // number of bytes transferred (unused for async)
493 &resume_node.base.overlapped,
494 null, // completion routine - unused because we use IOCP
495 );
496 }
433 global_event_loop.beginOneEvent();
434 defer global_event_loop.finishOneEvent();
435
436 while (!self.os_data.cancelled) main_loop: {
437 suspend {
438 _ = windows.kernel32.ReadDirectoryChangesW(
439 dir.dir_handle,
440 &event_buf,
441 event_buf.len,
442 windows.FALSE, // watch subtree
443 windows.FILE_NOTIFY_CHANGE_FILE_NAME | windows.FILE_NOTIFY_CHANGE_DIR_NAME |
444 windows.FILE_NOTIFY_CHANGE_ATTRIBUTES | windows.FILE_NOTIFY_CHANGE_SIZE |
445 windows.FILE_NOTIFY_CHANGE_LAST_WRITE | windows.FILE_NOTIFY_CHANGE_LAST_ACCESS |
446 windows.FILE_NOTIFY_CHANGE_CREATION | windows.FILE_NOTIFY_CHANGE_SECURITY,
447 null, // number of bytes transferred (unused for async)
448 &resume_node.base.overlapped,
449 null, // completion routine - unused because we use IOCP
450 );
497451 }
452
498453 var bytes_transferred: windows.DWORD = undefined;
499 if (windows.kernel32.GetOverlappedResult(dir_handle, &resume_node.base.overlapped, &bytes_transferred, windows.FALSE) == 0) {
500 const err = switch (windows.kernel32.GetLastError()) {
454 if (windows.kernel32.GetOverlappedResult(
455 dir.dir_handle,
456 &resume_node.base.overlapped,
457 &bytes_transferred,
458 windows.FALSE,
459 ) == 0) {
460 const potential_error = windows.kernel32.GetLastError();
461 const err = switch (potential_error) {
462 .OPERATION_ABORTED, .IO_INCOMPLETE => err_blk: {
463 if (self.os_data.cancelled)
464 break :main_loop
465 else
466 break :err_blk windows.unexpectedError(potential_error);
467 },
501468 else => |err| windows.unexpectedError(err),
502469 };
503470 self.channel.put(err);
504471 } else {
505 // can't use @bytesToSlice because of the special variable length name field
506 var ptr = event_buf[0..].ptr;
472 var ptr: [*]u8 = &event_buf;
507473 const end_ptr = ptr + bytes_transferred;
508 var ev: *windows.FILE_NOTIFY_INFORMATION = undefined;
509 while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) : (ptr += ev.NextEntryOffset) {
510 ev = @ptrCast(*windows.FILE_NOTIFY_INFORMATION, ptr);
474 while (@ptrToInt(ptr) < @ptrToInt(end_ptr)) {
475 const ev = @ptrCast(*const windows.FILE_NOTIFY_INFORMATION, ptr);
511476 const emit = switch (ev.Action) {
512477 windows.FILE_ACTION_REMOVED => WatchEventId.Delete,
513 windows.FILE_ACTION_MODIFIED => WatchEventId.CloseWrite,
478 windows.FILE_ACTION_MODIFIED => .CloseWrite,
514479 else => null,
515480 };
516481 if (emit) |id| {
517 const basename_utf16le = ([*]u16)(&ev.FileName)[0 .. ev.FileNameLength / 2];
518 const user_value = blk: {
519 const held = dir.table_lock.acquire();
520 defer held.release();
521
522 if (dir.file_table.get(basename_utf16le)) |entry| {
523 break :blk entry.value;
524 } else {
525 break :blk null;
526 }
527 };
528 if (user_value) |v| {
482 const basename_ptr = @ptrCast([*]u16, ptr + @sizeOf(windows.FILE_NOTIFY_INFORMATION));
483 const basename_utf16le = basename_ptr[0 .. ev.FileNameLength / 2];
484 var basename_data: [std.fs.MAX_PATH_BYTES]u8 = undefined;
485 const basename = basename_data[0 .. std.unicode.utf16leToUtf8(&basename_data, basename_utf16le) catch unreachable];
486
487 if (dir.file_table.getEntry(basename)) |entry| {
529488 self.channel.put(Event{
530489 .id = id,
531 .data = v,
490 .data = entry.value,
491 .dirname = dirname,
492 .basename = entry.key,
532493 });
533494 }
534495 }
496
535497 if (ev.NextEntryOffset == 0) break;
498 ptr = @alignCast(@alignOf(windows.FILE_NOTIFY_INFORMATION), ptr + ev.NextEntryOffset);
536499 }
537500 }
538501 }
......@@ -554,8 +517,21 @@ pub fn Watch(comptime V: type) type {
554517 }
555518 return null;
556519 },
520 .windows => {
521 const dirname = std.fs.path.dirname(file_path) orelse ".";
522 const basename = std.fs.path.basename(file_path);
523
524 const held = self.os_data.table_lock.acquire();
525 defer held.release();
526
527 const dir = self.os_data.dir_table.get(dirname) orelse return null;
528 if (dir.file_table.remove(basename)) |file_entry| {
529 self.allocator.free(file_entry.key);
530 return file_entry.value;
531 }
532 return null;
533 },
557534 .macos, .freebsd, .netbsd, .dragonfly, .openbsd => @panic("TODO"),
558 .windows => return @panic("TODO"),
559535 else => @compileError("Unsupported OS"),
560536 }
561537 }
......@@ -565,7 +541,7 @@ pub fn Watch(comptime V: type) type {
565541
566542 defer {
567543 std.debug.assert(self.os_data.wd_table.count() == 0);
568 self.os_data.wd_table.deinit();
544 self.os_data.wd_table.deinit(self.allocator);
569545 os.close(self.os_data.inotify_fd);
570546 self.allocator.free(self.channel.buffer_nodes);
571547 self.channel.deinit();
......@@ -585,9 +561,6 @@ pub fn Watch(comptime V: type) type {
585561 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);
586562 const basename = std.mem.span(@ptrCast([*:0]u8, basename_ptr));
587563
588 const held = self.os_data.table_lock.acquire();
589 defer held.release();
590
591564 const dir = &self.os_data.wd_table.get(ev.wd).?;
592565 if (dir.file_table.getEntry(basename)) |file_value| {
593566 self.channel.put(Event{
......@@ -607,17 +580,14 @@ pub fn Watch(comptime V: type) type {
607580 self.allocator.free(file_entry.key);
608581 }
609582 self.allocator.free(wd_entry.value.dirname);
610 wd_entry.value.file_table.deinit();
583 wd_entry.value.file_table.deinit(self.allocator);
611584 }
612585 } else if (ev.mask & os.linux.IN_DELETE == os.linux.IN_DELETE) {
613586 // File or directory was removed or deleted
614587 const basename_ptr = ptr + @sizeOf(os.linux.inotify_event);
615588 const basename = std.mem.span(@ptrCast([*:0]u8, basename_ptr));
616589
617 const held = self.os_data.table_lock.acquire();
618 defer held.release();
619590 const dir = &self.os_data.wd_table.get(ev.wd).?;
620
621591 if (dir.file_table.getEntry(basename)) |file_value| {
622592 self.channel.put(Event{
623593 .id = .Delete,
lib/std/os/windows.zig+6-5
......@@ -109,7 +109,12 @@ pub fn OpenFile(sub_path_w: []const u16, options: OpenFileOptions) OpenError!HAN
109109 0,
110110 );
111111 switch (rc) {
112 .SUCCESS => return result,
112 .SUCCESS => {
113 if (options.io_mode == .evented) {
114 _ = CreateIoCompletionPort(result, std.event.Loop.instance.?.os_data.io_port, undefined, undefined) catch undefined;
115 }
116 return result;
117 },
113118 .OBJECT_NAME_INVALID => unreachable,
114119 .OBJECT_NAME_NOT_FOUND => return error.FileNotFound,
115120 .OBJECT_PATH_NOT_FOUND => return error.FileNotFound,
......@@ -418,8 +423,6 @@ pub fn ReadFile(in_hFile: HANDLE, buffer: []u8, offset: ?u64, io_mode: std.io.Mo
418423 },
419424 },
420425 };
421 // TODO only call create io completion port once per fd
422 _ = CreateIoCompletionPort(in_hFile, loop.os_data.io_port, undefined, undefined) catch undefined;
423426 loop.beginOneEvent();
424427 suspend {
425428 // TODO handle buffer bigger than DWORD can hold
......@@ -500,8 +503,6 @@ pub fn WriteFile(
500503 },
501504 },
502505 };
503 // TODO only call create io completion port once per fd
504 _ = CreateIoCompletionPort(handle, loop.os_data.io_port, undefined, undefined) catch undefined;
505506 loop.beginOneEvent();
506507 suspend {
507508 const adjusted_len = math.cast(DWORD, bytes.len) catch maxInt(DWORD);
lib/std/os/windows/bits.zig+2-1
......@@ -813,7 +813,8 @@ pub const FILE_NOTIFY_INFORMATION = extern struct {
813813 NextEntryOffset: DWORD,
814814 Action: DWORD,
815815 FileNameLength: DWORD,
816 FileName: [1]WCHAR,
816 // Flexible array member
817 // FileName: [1]WCHAR,
817818};
818819
819820pub const FILE_ACTION_ADDED = 0x00000001;
lib/std/os/windows/kernel32.zig+1-1
......@@ -8,7 +8,7 @@ usingnamespace @import("bits.zig");
88pub extern "kernel32" fn AddVectoredExceptionHandler(First: c_ulong, Handler: ?VECTORED_EXCEPTION_HANDLER) callconv(WINAPI) ?*c_void;
99pub extern "kernel32" fn RemoveVectoredExceptionHandler(Handle: HANDLE) callconv(WINAPI) c_ulong;
1010
11pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: LPOVERLAPPED) callconv(WINAPI) BOOL;
11pub extern "kernel32" fn CancelIoEx(hFile: HANDLE, lpOverlapped: ?LPOVERLAPPED) callconv(WINAPI) BOOL;
1212
1313pub extern "kernel32" fn CloseHandle(hObject: HANDLE) callconv(WINAPI) BOOL;
1414