diff options
author | 2022-03-22 02:55:14 -0700 | |
---|---|---|
committer | 2022-03-22 02:55:28 -0700 | |
commit | 6e9be9f1cc4cc91dd0ac7b7c4ea1efd9f17b8ea3 (patch) | |
tree | 4137f1bf2e791c438d69c40ef84b20cec379b751 /src | |
parent | b1389f1b021dda7f63912369e990c3a854c1cc02 (diff) | |
download | bun-6e9be9f1cc4cc91dd0ac7b7c4ea1efd9f17b8ea3.tar.gz bun-6e9be9f1cc4cc91dd0ac7b7c4ea1efd9f17b8ea3.tar.zst bun-6e9be9f1cc4cc91dd0ac7b7c4ea1efd9f17b8ea3.zip |
Linux-specific tweaks
Diffstat (limited to 'src')
-rw-r--r-- | src/fallback.version | 2 | ||||
-rw-r--r-- | src/io/io_linux.zig | 46 | ||||
-rw-r--r-- | src/javascript/jsc/api/server.zig | 10 | ||||
-rw-r--r-- | src/javascript/jsc/base.zig | 25 | ||||
-rw-r--r-- | src/runtime.version | 2 |
5 files changed, 44 insertions, 41 deletions
diff --git a/src/fallback.version b/src/fallback.version index cc80fd43a..b07ec851e 100644 --- a/src/fallback.version +++ b/src/fallback.version @@ -1 +1 @@ -3d00849be45e12c2
\ No newline at end of file +3c32b2da4ba87f18
\ No newline at end of file diff --git a/src/io/io_linux.zig b/src/io/io_linux.zig index 89961fe00..559d2289d 100644 --- a/src/io/io_linux.zig +++ b/src/io/io_linux.zig @@ -705,7 +705,7 @@ pub const Completion = struct { .open => |op| { linux.io_uring_prep_openat( sqe, - std.os.AT.FD_CWD, + linux.AT.FDCWD, op.path, op.flags, op.mode, @@ -779,23 +779,27 @@ pub const Completion = struct { }, .open => { const result = if (completion.result < 0) switch (-completion.result) { - .SUCCESS => unreachable, - .ACCES => error.AccessDenied, - .FBIG => error.FileTooBig, - .OVERFLOW => error.FileTooBig, - .ISDIR => error.IsDir, - .LOOP => error.SymLinkLoop, - .MFILE => error.ProcessFdQuotaExceeded, - .NAMETOOLONG => error.NameTooLong, - .NFILE => error.SystemFdQuotaExceeded, - .NODEV => error.NoDevice, - .NOENT => error.FileNotFound, - .NOMEM => error.SystemResources, - .NOSPC => error.NoSpaceLeft, - .NOTDIR => error.NotDir, - .PERM => error.AccessDenied, - .EXIST => error.PathAlreadyExists, - .BUSY => return error.DeviceBusy, + 0 => unreachable, + os.EAGAIN, os.EINPROGRESS, os.EINTR => { + completion.io.enqueue(completion); + return; + }, + os.EACCES => error.AccessDenied, + os.EFBIG => error.FileTooBig, + os.EOVERFLOW => error.FileTooBig, + os.EISDIR => error.IsDir, + os.ELOOP => error.SymLinkLoop, + os.EMFILE => error.ProcessFdQuotaExceeded, + os.ENAMETOOLONG => error.NameTooLong, + os.ENFILE => error.SystemFdQuotaExceeded, + os.ENODEV => error.NoDevice, + os.ENOENT => error.FileNotFound, + os.ENOMEM => error.SystemResources, + os.ENOSPC => error.NoSpaceLeft, + os.ENOTDIR => error.NotDir, + os.EPERM => error.AccessDenied, + os.EEXIST => error.PathAlreadyExists, + os.EBUSY => error.DeviceBusy, else => |errno| asError(errno), } else @intCast(linux.fd_t, completion.result); completion.callback(completion.context, completion, &result); @@ -1451,7 +1455,7 @@ pub fn open( result: OpenError!linux.fd_t, ) void, completion: *Completion, - file_path: [:0]const u8, + path: [:0]const u8, flags: os.mode_t, mode: os.mode_t, ) void { @@ -1469,8 +1473,8 @@ pub fn open( }.wrapper, .operation = .{ .open = .{ - .file_path = file_path, - .flags = flags, + .path = path, + .flags = @intCast(u32, flags), .mode = mode, }, }, diff --git a/src/javascript/jsc/api/server.zig b/src/javascript/jsc/api/server.zig index 125d688a7..cb128284f 100644 --- a/src/javascript/jsc/api/server.zig +++ b/src/javascript/jsc/api/server.zig @@ -280,16 +280,14 @@ pub fn NewServer(comptime ssl_enabled: bool) type { if (Environment.isLinux) { const start = this.sendfile.offset; const val = - std.os.linux.sendfile(this.sendfile.socket_fd, this.sendfile.fd, &this.sendfile.offset, this.sendfile.adjusted_count); + std.os.linux.sendfile(this.sendfile.socket_fd, this.sendfile.fd, &this.sendfile.offset, this.sendfile.remain); - const sent = @intCast(u32, this.sendfile.offset - start); const errcode = std.os.linux.getErrno(val); - this.sendfile.offset += sent; - this.sendfile.remain -= sent; + this.sendfile.remain -= @intCast(u32, this.sendfile.offset - start); - if (errcode != .AGAIN or this.aborted or this.sendfile.remain == 0 or val == 0) { - if (errcode != .AGAIN and errcode != .SUCCESS) { + if (errcode != .SUCCESS or this.aborted or this.sendfile.remain == 0 or val == 0) { + if (errcode != .SUCCESS) { Output.prettyErrorln("Error: {s}", .{@tagName(errcode)}); Output.flush(); } diff --git a/src/javascript/jsc/base.zig b/src/javascript/jsc/base.zig index 9dddba9ee..183a0c908 100644 --- a/src/javascript/jsc/base.zig +++ b/src/javascript/jsc/base.zig @@ -892,7 +892,6 @@ pub fn NewClassWithInstanceType( const function_name_literals = function_names; var function_name_refs: [function_names.len]js.JSStringRef = undefined; var function_name_refs_set = false; - var class_name_str = name[0.. :0].ptr; const property_names = std.meta.fieldNames(@TypeOf(properties)); var property_name_refs: [property_names.len]js.JSStringRef = undefined; @@ -919,7 +918,7 @@ pub fn NewClassWithInstanceType( arguments: [*c]const js.JSValueRef, exception: js.ExceptionRef, ) callconv(.C) js.JSValueRef { - return class_definition_ptr.callAsConstructor.?(ctx, function, argumentCount, arguments, exception); + return &complete_definition.callAsConstructor.?(ctx, function, argumentCount, arguments, exception); } }; @@ -1125,7 +1124,9 @@ pub fn NewClassWithInstanceType( } pub inline fn getDefinition() js.JSClassDefinition { - return class_definition_ptr.*; + var definition = complete_definition; + definition.className = options.name; + return definition; } // This should only be run at comptime @@ -1522,6 +1523,13 @@ pub fn NewClassWithInstanceType( }; var __static_functions: [function_name_literals.len + 1]js.JSStaticFunction = undefined; + for (__static_functions) |_, i| { + __static_functions[i] = js.JSStaticFunction{ + .name = @intToPtr([*c]const u8, 0), + .callAsFunction = null, + .attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone, + }; + } for (function_name_literals) |function_name_literal, i| { const is_read_only = options.read_only; @@ -1633,14 +1641,6 @@ pub fn NewClassWithInstanceType( if (ReturnType == JSC.C.JSClassDefinition) { return def; } else { - while (count < __static_functions.len) : (count += 1) { - __static_functions[count] = js.JSStaticFunction{ - .name = "", - .callAsFunction = null, - .attributes = js.JSPropertyAttributes.kJSPropertyAttributeNone, - }; - } - return __static_functions; } } @@ -1649,6 +1649,7 @@ pub fn NewClassWithInstanceType( const static_functions__ = generateDef([function_name_literals.len + 1]js.JSStaticFunction); const static_functions_ptr = &static_functions__; const static_values_ptr = &static_properties; + const class_name_str: stringZ = options.name; const complete_definition = brk: { var def = base_def_; @@ -1660,7 +1661,7 @@ pub fn NewClassWithInstanceType( def.staticValues = static_values_ptr; } - def.className = options.name; + def.className = class_name_str; // def.getProperty = getPropertyCallback; if (def.callAsConstructor == null) { diff --git a/src/runtime.version b/src/runtime.version index 0bbf538da..fd95ea0a3 100644 --- a/src/runtime.version +++ b/src/runtime.version @@ -1 +1 @@ -139d399765744be7
\ No newline at end of file +118e8e9b568841b0
\ No newline at end of file |