authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-21 20:34:55-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-11-21 20:34:55-05:00
logcd5f4de2a684ab0a3383ff328516243a6e850201
treea421b07b96689a975091f941e94f0d3f3bac0740
parentbf1cbebea1fd846c982e568ef4f013dfaf232e3e
signaturelock-open Commit is signed but in an unrecognized format.

std: remove O_LARGEFILE from OS bits when the OS does not define it


5 files changed, 12 insertions(+), 8 deletions(-)

lib/std/event/fs.zig+6-3
...@@ -415,7 +415,8 @@ pub fn openPosix(...@@ -415,7 +415,8 @@ pub fn openPosix(
415pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t {415pub fn openRead(loop: *Loop, path: []const u8) File.OpenError!fd_t {
416 switch (builtin.os) {416 switch (builtin.os) {
417 .macosx, .linux, .freebsd, .netbsd, .dragonfly => {417 .macosx, .linux, .freebsd, .netbsd, .dragonfly => {
418 const flags = os.O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC;418 const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
419 const flags = O_LARGEFILE | os.O_RDONLY | os.O_CLOEXEC;
419 return openPosix(loop, path, flags, File.default_mode);420 return openPosix(loop, path, flags, File.default_mode);
420 },421 },
421422
...@@ -448,7 +449,8 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr...@@ -448,7 +449,8 @@ pub fn openWriteMode(loop: *Loop, path: []const u8, mode: File.Mode) File.OpenEr
448 .netbsd,449 .netbsd,
449 .dragonfly,450 .dragonfly,
450 => {451 => {
451 const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;452 const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
453 const flags = O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;
452 return openPosix(loop, path, flags, File.default_mode);454 return openPosix(loop, path, flags, File.default_mode);
453 },455 },
454 .windows => return windows.CreateFile(456 .windows => return windows.CreateFile(
...@@ -472,7 +474,8 @@ pub fn openReadWrite(...@@ -472,7 +474,8 @@ pub fn openReadWrite(
472) File.OpenError!fd_t {474) File.OpenError!fd_t {
473 switch (builtin.os) {475 switch (builtin.os) {
474 .macosx, .linux, .freebsd, .netbsd, .dragonfly => {476 .macosx, .linux, .freebsd, .netbsd, .dragonfly => {
475 const flags = os.O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC;477 const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
478 const flags = O_LARGEFILE | os.O_RDWR | os.O_CREAT | os.O_CLOEXEC;
476 return openPosix(loop, path, flags, mode);479 return openPosix(loop, path, flags, mode);
477 },480 },
478481
lib/std/event/loop.zig+2-1
...@@ -856,7 +856,8 @@ pub const Loop = struct {...@@ -856,7 +856,8 @@ pub const Loop = struct {
856 },856 },
857 .Close => |*msg| noasync os.close(msg.fd),857 .Close => |*msg| noasync os.close(msg.fd),
858 .WriteFile => |*msg| blk: {858 .WriteFile => |*msg| blk: {
859 const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT |859 const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
860 const flags = O_LARGEFILE | os.O_WRONLY | os.O_CREAT |
860 os.O_CLOEXEC | os.O_TRUNC;861 os.O_CLOEXEC | os.O_TRUNC;
861 const fd = noasync os.openC(msg.path.ptr, flags, msg.mode) catch |err| {862 const fd = noasync os.openC(msg.path.ptr, flags, msg.mode) catch |err| {
862 msg.result = err;863 msg.result = err;
lib/std/fs/file.zig+4-2
...@@ -66,7 +66,8 @@ pub const File = struct {...@@ -66,7 +66,8 @@ pub const File = struct {
66 const path_w = try windows.cStrToPrefixedFileW(path);66 const path_w = try windows.cStrToPrefixedFileW(path);
67 return openWriteModeW(&path_w, file_mode);67 return openWriteModeW(&path_w, file_mode);
68 }68 }
69 const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;69 const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
70 const flags = O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_TRUNC;
70 const fd = try os.openC(path, flags, file_mode);71 const fd = try os.openC(path, flags, file_mode);
71 return openHandle(fd);72 return openHandle(fd);
72 }73 }
...@@ -105,7 +106,8 @@ pub const File = struct {...@@ -105,7 +106,8 @@ pub const File = struct {
105 const path_w = try windows.cStrToPrefixedFileW(path);106 const path_w = try windows.cStrToPrefixedFileW(path);
106 return openWriteNoClobberW(&path_w, file_mode);107 return openWriteNoClobberW(&path_w, file_mode);
107 }108 }
108 const flags = os.O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_EXCL;109 const O_LARGEFILE = if (@hasDecl(os, "O_LARGEFILE")) os.O_LARGEFILE else 0;
110 const flags = O_LARGEFILE | os.O_WRONLY | os.O_CREAT | os.O_CLOEXEC | os.O_EXCL;
109 const fd = try os.openC(path, flags, file_mode);111 const fd = try os.openC(path, flags, file_mode);
110 return openHandle(fd);112 return openHandle(fd);
111 }113 }
lib/std/os/bits/darwin.zig-1
...@@ -267,7 +267,6 @@ pub const SA_USERTRAMP = 0x0100;...@@ -267,7 +267,6 @@ pub const SA_USERTRAMP = 0x0100;
267/// signal handler with SA_SIGINFO args with 64bit regs information267/// signal handler with SA_SIGINFO args with 64bit regs information
268pub const SA_64REGSET = 0x0200;268pub const SA_64REGSET = 0x0200;
269269
270pub const O_LARGEFILE = 0x0000;
271pub const O_PATH = 0x0000;270pub const O_PATH = 0x0000;
272271
273pub const F_OK = 0;272pub const F_OK = 0;
lib/std/os/bits/netbsd.zig-1
...@@ -292,7 +292,6 @@ pub const O_CLOEXEC = 0x00400000;...@@ -292,7 +292,6 @@ pub const O_CLOEXEC = 0x00400000;
292292
293pub const O_ASYNC = 0x0040;293pub const O_ASYNC = 0x0040;
294pub const O_DIRECT = 0x00080000;294pub const O_DIRECT = 0x00080000;
295pub const O_LARGEFILE = 0;
296pub const O_NOATIME = 0;295pub const O_NOATIME = 0;
297pub const O_PATH = 0;296pub const O_PATH = 0;
298pub const O_TMPFILE = 0;297pub const O_TMPFILE = 0;