diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-11-21 20:34:55 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-11-21 20:34:55 -0500 |
| commit | cd5f4de2a684ab0a3383ff328516243a6e850201 (patch) | |
| tree | a421b07b96689a975091f941e94f0d3f3bac0740 /lib/std/event | |
| parent | bf1cbebea1fd846c982e568ef4f013dfaf232e3e (diff) | |
| download | zig-cd5f4de2a684ab0a3383ff328516243a6e850201.tar.gz zig-cd5f4de2a684ab0a3383ff328516243a6e850201.zip | |
std: remove O_LARGEFILE from OS bits when the OS does not define it
Diffstat (limited to 'lib/std/event')
| -rw-r--r-- | lib/std/event/fs.zig | 9 | ||||
| -rw-r--r-- | lib/std/event/loop.zig | 3 |
2 files changed, 8 insertions, 4 deletions
diff --git a/lib/std/event/fs.zig b/lib/std/event/fs.zig index 1035a51b81..eef5cfae7d 100644 --- a/lib/std/event/fs.zig +++ b/lib/std/event/fs.zig @@ -415,7 +415,8 @@ pub fn openPosix( pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t { switch (builtin.os) { .macosx, .linux, .freebsd, .netbsd, .dragonfly => { - const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC; + const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0; + const flags = O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC; return openPosix(loop, path, flags, File.default_mode); }, @@ -448,7 +449,8 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr .netbsd, .dragonfly, => { - const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; + const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0; + const flags = O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; return openPosix(loop, path, flags, File.default_mode); }, .windows => return windows.CreateFile( @@ -472,7 +474,8 @@ pub fn openReadWrite( ) File.OpenError!fd_t { switch (builtin.os) { .macosx, .linux, .freebsd, .netbsd, .dragonfly => { - const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC; + const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0; + const flags = O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC; return openPosix(loop, path, flags, mode); }, diff --git a/lib/std/event/loop.zig b/lib/std/event/loop.zig index 8f01c19746..44174c862c 100644 --- a/lib/std/event/loop.zig +++ b/lib/std/event/loop.zig @@ -856,7 +856,8 @@ pub const Loop = struct { }, .Close => |*msg| noasync os.close(msg.fd), .WriteFile => |*msg| blk: { - const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | + const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0; + const flags = O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC; const fd = noasync os.openC(msg.path.ptr, flags, msg.mode) catch |err| { msg.result = err; |
