diff options
author | 2021-09-08 16:57:10 -0700 | |
---|---|---|
committer | 2021-09-08 16:57:10 -0700 | |
commit | c30ec608b1484628cc28b4811b9d62e1c142b281 (patch) | |
tree | 83fb59c6edb8e81d452e0f000c17ce3cd98e0aae | |
parent | d18e73aa5798b70f6fd635e3e325e470d9d06e7b (diff) | |
download | bun-c30ec608b1484628cc28b4811b9d62e1c142b281.tar.gz bun-c30ec608b1484628cc28b4811b9d62e1c142b281.tar.zst bun-c30ec608b1484628cc28b4811b9d62e1c142b281.zip |
upgrade
-rw-r--r-- | src/darwin_c.zig | 22 | ||||
-rw-r--r-- | src/defines.zig | 4 | ||||
-rw-r--r-- | src/deps/zig-clap/clap.zig | 2 | ||||
-rw-r--r-- | src/fallback.version | 2 | ||||
-rw-r--r-- | src/http.zig | 20 | ||||
m--------- | src/javascript/jsc/WebKit | 0 | ||||
-rw-r--r-- | src/javascript/jsc/bindings/bindings.zig | 400 | ||||
-rw-r--r-- | src/options.zig | 6 | ||||
-rw-r--r-- | src/resolver/tsconfig_json.zig | 2 | ||||
-rw-r--r-- | src/router.zig | 2 | ||||
-rw-r--r-- | src/runtime.version | 2 | ||||
-rw-r--r-- | src/sync.zig | 36 |
12 files changed, 46 insertions, 452 deletions
diff --git a/src/darwin_c.zig b/src/darwin_c.zig index ddc678a39..3a949d24a 100644 --- a/src/darwin_c.zig +++ b/src/darwin_c.zig @@ -48,11 +48,11 @@ pub fn lstat_absolute(path: [:0]const u8) StatError!Stat { var st = zeroes(libc_stat); switch (errno(lstat64(path.ptr, &st))) { - 0 => {}, - EINVAL => unreachable, - EBADF => unreachable, // Always a race condition. - ENOMEM => return error.SystemResources, - EACCES => return error.AccessDenied, + .SUCCESS => {}, + // .EINVAL => unreachable, + .BADF => unreachable, // Always a race condition. + .NOMEM => return error.SystemResources, + .ACCES => return error.AccessDenied, else => |err| return os.unexpectedErrno(err), } @@ -116,10 +116,10 @@ pub fn stat_absolute(path: [:0]const u8) StatError!Stat { var st = zeroes(libc_stat); switch (errno(stat(path.ptr, &st))) { 0 => {}, - EINVAL => unreachable, - EBADF => unreachable, // Always a race condition. - ENOMEM => return error.SystemResources, - EACCES => return error.AccessDenied, + // .EINVAL => unreachable, + .EBADF => unreachable, // Always a race condition. + .ENOMEM => return error.SystemResources, + .EACCES => return error.AccessDenied, else => |err| return os.unexpectedErrno(err), } @@ -179,13 +179,13 @@ pub fn preallocate_file(fd: os.fd_t, offset: off_t, len: off_t) !void { fstore.fst_length = len + offset; // Based on https://api.kde.org/frameworks/kcoreaddons/html/posix__fallocate__mac_8h_source.html - var rc = os.system.fcntl(fd, F_PREALLOCATE, &fstore); + var rc = os.system.fcntl(fd, os.F_PREALLOCATE, &fstore); switch (rc) { 0 => return, else => { fstore.fst_flags = F_ALLOCATEALL; - rc = os.system.fcntl(fd, F_PREALLOCATE, &fstore); + rc = os.system.fcntl(fd, os.F_PREALLOCATE, &fstore); }, } diff --git a/src/defines.zig b/src/defines.zig index 7c970a71d..8bb96d41e 100644 --- a/src/defines.zig +++ b/src/defines.zig @@ -63,7 +63,7 @@ pub const DefineData = struct { try user_defines.ensureUnusedCapacity(@truncate(u32, defines.count())); var iter = defines.iterator(); while (iter.next()) |entry| { - var splitter = std.mem.split(entry.key_ptr.*, "."); + var splitter = std.mem.split(u8, entry.key_ptr.*, "."); while (splitter.next()) |part| { if (!js_lexer.isIdentifier(part)) { if (strings.eql(part, entry.key_ptr)) { @@ -281,7 +281,7 @@ pub const Define = struct { const remainder = user_define_key[0..last_dot]; const count = std.mem.count(u8, remainder, ".") + 1; var parts = try allocator.alloc(string, count + 1); - var splitter = std.mem.split(remainder, "."); + var splitter = std.mem.split(u8, remainder, "."); var i: usize = 0; while (splitter.next()) |split| : (i += 1) { parts[i] = split; diff --git a/src/deps/zig-clap/clap.zig b/src/deps/zig-clap/clap.zig index 6600d94fe..e6bf56f08 100644 --- a/src/deps/zig-clap/clap.zig +++ b/src/deps/zig-clap/clap.zig @@ -64,7 +64,7 @@ pub fn Param(comptime Id: type) type { /// This is the reverse of 'help' but for at single parameter only. pub fn parseParam(line: []const u8) !Param(Help) { var found_comma = false; - var it = mem.tokenize(line, " \t"); + var it = mem.tokenize(u8, line, " \t"); var param_str = it.next() orelse return error.NoParamFound; const short_name = if (!mem.startsWith(u8, param_str, "--") and diff --git a/src/fallback.version b/src/fallback.version index fb76dcb20..75f3323de 100644 --- a/src/fallback.version +++ b/src/fallback.version @@ -1 +1 @@ -c098be5f3e938123
\ No newline at end of file +a5559a0075104616
\ No newline at end of file diff --git a/src/http.zig b/src/http.zig index 37f6795bd..0f31de206 100644 --- a/src/http.zig +++ b/src/http.zig @@ -1235,19 +1235,14 @@ pub const RequestContext = struct { clone.* = JavaScriptHandler{ .ctx = ctx.*, .conn = ctx.conn.*, - .params = if (params.len > 0) - try params.clone(ctx.allocator) - else - Router.Param.List{} - , + .params = if (params.len > 0) + try params.clone(ctx.allocator) + else + Router.Param.List{}, }; - clone.ctx.conn = &clone.conn; - - - clone.ctx.matched_route.?.params = &clone.params; clone.ctx.matched_route.?.file_path = filepath_buf[0..ctx.matched_route.?.file_path.len]; @@ -1259,7 +1254,6 @@ pub const RequestContext = struct { clone.ctx.matched_route.?.name = Router.Match.nameWithBasename(clone.ctx.matched_route.?.file_path, ctx.bundler.router.?.config.dir); } - if (!has_loaded_channel) { var handler_thread = try server.allocator.create(HandlerThread); @@ -1291,7 +1285,7 @@ pub const RequestContext = struct { .client_bundler = undefined, }; } -try server.bundler.clone(server.allocator, &handler_thread.client_bundler); + try server.bundler.clone(server.allocator, &handler_thread.client_bundler); handler_thread.log = try server.allocator.create(logger.Log); handler_thread.log.* = logger.Log.init(server.allocator); @@ -1652,7 +1646,7 @@ try server.bundler.clone(server.allocator, &handler_thread.client_bundler); // Some proxies/load balancers will mess with the connection header // and browsers also send multiple values here const connection_header = request.header("Connection") orelse return error.BadRequest; - var it = std.mem.split(connection_header.value, ","); + var it = std.mem.split(u8, connection_header.value, ","); while (it.next()) |part| { const conn = std.mem.trim(u8, part, " "); if (std.ascii.eqlIgnoreCase(conn, "upgrade")) { @@ -2781,7 +2775,7 @@ pub const Server = struct { }; global_start_time = server.timer; server.bundler = try allocator.create(Bundler); - server.bundler.* = try Bundler.init(allocator, &server.log, options, null, null); + server.bundler.* = try Bundler.init(allocator, &server.log, options, null, null); server.bundler.configureLinker(); try server.bundler.configureRouter(true); diff --git a/src/javascript/jsc/WebKit b/src/javascript/jsc/WebKit -Subproject e7d31961d4bf98b3e8b1df3ea0398ea1517a61d +Subproject 1d5ca69e3eedd5b4d1197bbb90860b254a8a8ee diff --git a/src/javascript/jsc/bindings/bindings.zig b/src/javascript/jsc/bindings/bindings.zig index 42d549ff7..3ff10a285 100644 --- a/src/javascript/jsc/bindings/bindings.zig +++ b/src/javascript/jsc/bindings/bindings.zig @@ -2042,406 +2042,6 @@ pub const StringView = extern struct { }; }; -pub const Cpp = struct { - pub const Function = fn ( - globalObject: *JSGlobalObject, - callframe: CallFrame, - ) callconv(.C) JSValue; - pub const Getter = fn ( - ctx: ?*c_void, - globalObject: *JSGlobalObject, - this: EncodedJSValue, - propertyName: PropertyName, - ) callconv(.C) JSValue; - pub const Setter = fn ( - ctx: ?*c_void, - globalObject: *JSGlobalObject, - this: JSValue, - value: JSValue, - propertyName: PropertyName, - ) callconv(.C) bool; - - pub const Tag = enum { - Callback, - Constructor, - Attribute, - Static, - }; - - pub const Attribute = struct { - getter: ?StaticExport = null, - setter: ?StaticExport = null, - read_only: bool = false, - enumerable: bool = false, - }; - - pub const Static = union { - String: []const u8, - Number: u16, - }; - - pub const Callback = StaticExport; - - pub const LUTType = enum { - Function, - Accessor, - CellProperty, - ClassStructure, - PropertyCallback, - }; - - pub const LUTFlag = enum { - Enum, - DontEnum, - ReadOnly, - }; - - pub const Property = struct { - name: []const u8, - read_only: bool = false, - enumerable: bool = false, - value: Value, - pub const Value = union(Tag) { - Callback: StaticExport, - Constructor: StaticExport, - Attribute: Attribute, - Static: Static, - }; - }; - - pub const Subclass = enum { - JSNonFinalObject, - JSObject, - }; - - pub const InitCallback = fn (*c_void, *VM, *JSGlobalObject) void; - pub const ClassDefinition = struct { - name: []const u8, - subclass: Subclass, - statics: []Property, - init: StaticExport, - free: StaticExport, - Ctx: type, - - pub fn printer(h: std.fs.File.Writer, cpp: std.fs.File.Writer, comptime Type: type, comptime ZigType: type, comptime Prototype_: ?type, comptime Properties: []Property, comptime use_lut: bool) !void { - var instanceName = comptime Type.name; - instanceName[0] = comptime std.ascii.toLower(instanceName[0]); - const fields = comptime .{ - .TypeName = Type.name, - .instanceName = instanceName, - }; - try h.print( - \\#pragma once - \\ - \\#include "root.h" - \\#include "headers.h" - \\ - \\namespace Zig {{ - \\ - \\ class {[TypeName][s]} : public JSC::JSNonFinalObject {{ - \\ using Base = JSC::JSNonFinalObject; - \\ static {s}* create(JSC::Structure* structure, JSC::JSGlobalThis* globalObject) - \\ {{ - \\ {[TypeName][s]}* ptr = new (NotNull, JSC::allocateCell<{s}>(globalObject->vm().heap)) {[TypeName][s]}(structure, *globalObject); - \\ ptr->finishCreation(globalObject->vm()); - \\ return ptr; - \\ }} - \\ - \\ static {s}* create(JSC::Structure* structure, JSC::JSGlobalThis* globalObject, void* zigBase) - \\ {{ - \\ {[TypeName][s]}* ptr = new (NotNull, JSC::allocateCell<{s}>(globalObject->vm().heap)) {[TypeName][s]}(structure, *globalObject); - \\ ptr->finishCreation(globalObject->vm(), zigBase); - \\ return ptr; - \\ }} - , - fields, - ); - - try cpp.print( - \\#pragma once - \\ - \\#include "root.h" - \\#include "headers.h" - \\#include {[TypeName][s]}.h - \\ - , fields); - - inline for (Properties) |property| { - switch (comptime property.value) { - .Callback => |Callback| { - try cpp.print("static JSC_DECLARE_HOST_FUNCTION({s});\n", .{Callback.wrappedName()}); - }, - .Constructor => |Constructor| { - try cpp.print("static JSC_DECLARE_HOST_FUNCTION({s});\n", .{Callback.wrappedName()}); - }, - .Attribute => |Attribute| { - try cpp.print(" "); - if (Attribute.getter) |getter| { - try cpp.print("static JSC_DECLARE_CUSTOM_GETTER({s});\n", .{Callback.wrappedName()}); - } - - if (comptime Attribute.setter) |setter| { - try cpp.print("static JSC_DECLARE_CUSTOM_SETTER({s});\n", .{Callback.wrappedName()}); - } - try cpp.writeAll(" "); - }, - .Static => |Static| {}, - } - } - - if (comptime use_lut) { - try cpp.print( - \\namespace Zig { - \\ #include {[TypeName][s]}.lut.h - \\} - \\ - \\ /* Source for {[TypeName][s]}.lut.h */ - \\ @begin {[instanceName][s]}Table - , - fields, - ); - - inline for (Properties) |property| { - try cpp.writeAll(" "); - try cpp.writeAll(comptime property.name); - try cpp.writeAll(" "); - switch (comptime property.value) { - .Callback => |Callback| { - try cpp.writeAll(" "); - try cpp.writeAll(comptime Callback.wrappedName()); - try cpp.writeAll(" "); - }, - .Constructor => |Constructor| { - try cpp.writeAll(" "); - try cpp.writeAll(comptime Constructor.wrappedName()); - try cpp.writeAll(" "); - }, - .Attribute => |Attribute| { - try cpp.writeAll(" "); - if (Attribute.getter) |getter| { - try cpp.writeAll(comptime getter.wrappedName()); - try cpp.writeAll(" "); - } - - if (comptime Attribute.setter) |setter| { - @compileError("Unsupported setter on " ++ Type.name); - } - try cpp.writeAll(" "); - }, - .Static => |Static| {}, - } - var needs_or = false; - if (!property.enumerable) { - try cpp.writeAll("DontEnum"); - needs_or = true; - } - - if (needs_or) { - try cpp.writeAll("|"); - } - - switch (comptime property.value) { - .Callback => |Callback| { - const Fn: std.builtin.TypeInfo.Fn = comptime @typeInfo(Callback.Type).Fn; - try cpp.writeAll("Function {d}", .{Fn.args.len}); - }, - .Constructor => |Constructor| { - const Fn: std.builtin.TypeInfo.Fn = comptime @typeInfo(Callback.Type).Fn; - try cpp.writeAll("Function {d}", .{Fn.args.len}); - }, - .Attribute => |Attribute| { - try cpp.writeAll(" "); - if (Attribute.getter) |_| { - try cpp.writeAll("Accessor"); - try cpp.writeAll(" "); - } - - if (comptime Attribute.setter) |_| { - @compileError("Unsupported setter on " ++ Type.name); - } - try cpp.writeAll(" "); - }, - .Static => |Static| {}, - } - try cpp.writeAll("\n"); - } - - try cpp.writeAll(" @end\n"); - try cpp.print( - \\namespace Zig {{ - \\ - \\ const ClassInfo {s}::s_info = {{ "{[TypeName][s]}", &Base::s_info, &{[instanceName][s]}Table, nullptr, CREATE_METHOD_TABLE({[TypeName][s]}) }}; - \\ - \\}} - \\ - , - fields, - ); - } else { - try cpp.print( - \\namespace Zig {{ - \\ - \\ const ClassInfo {[TypeName][s]}::s_info = {{ "{[TypeName][s]}", &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE({[TypeName][s]}) }}; - \\ - \\}} - \\ - , fields); - } - - cpp.print( - \\ - \\namespace Zig {{ - \\ - \\ - \\ - \\ class {[TypeName][s]} final : public JSC::JSNonFinalObject {{ - \\ using Base = JSC::JSNonFinalObject; - \\ - \\ void {[TypeName][s]}::finishCreation(JSGlobalObject* globalObject, VM& vm) {{ - \\ Base::finishCreation(vm); - \\ m_zigBase = {[InitFunctionSymbol]}(globalObject, vm); - \\ reifyStaticProperties(vm, {[TypeName][s]}::info(), &{[instanceName][s]}Table, *this); - \\ JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); - \\ }} - \\ - \\ void {[TypeName][s]}::finishCreation(JSGlobalObject* globalObject, VM& vm, void* zigBase) {{ - \\ Base::finishCreation(vm); - \\ m_zigBase = zigBase; - \\ reifyStaticProperties(vm, {[TypeName][s]}::info(), &{[instanceName][s]}Table, *this); - \\ JSC_TO_STRING_TAG_WITHOUT_TRANSITION(); - \\ }} - \\ - \\ - , - fields, - ); - - inline for (Properties) |property| { - switch (comptime property.value) { - .Callback => |Callback| { - try cpp.writeAll( - \\JSC_DEFINE_HOST_FUNCTION({[Wrapped][s]}, (JSGlobalObject* globalObject, CallFrame* callFrame)) - \\{{ - \\ VM& vm = globalObject->vm(); - \\ auto scope = DECLARE_THROW_SCOPE(vm); - \\ auto* thisValue = JSC::jsDynamic<{[TypeName][s]}*>(callFrame->thisValue()); - \\ if (UNLIKELY(!thisValue || !thisValue.m_zigBase)) {{ - \\ return JSC::throwVMTypeError(globalObject, scope); - \\ }} - \\ - \\ RELEASE_AND_RETURN(scope, {[Fn][s]}(thisValue.m__zigType, vm, this, globalObject, callFrame, scope)); - \\}} - \\ - , .{ - .Wrapped = Callback.wrappedName(), - .Fn = Callback.symbol_name, - .TypeName = Type.name, - }); - }, - .Constructor => |Constructor| { - try cpp.writeAll( - \\JSC_DEFINE_HOST_FUNCTION({[Wrapped][s]}, (JSGlobalObject* globalObject, CallFrame* callFrame)) - \\{{ - \\ VM& vm = globalObject->vm(); - \\ auto scope = DECLARE_THROW_SCOPE(vm); - \\ RELEASE_AND_RETURN(scope, {[Fn][s]}(globalObject, vm, callFrame, scope)); - \\}} - \\ - , .{ - .Wrapped = Constructor.wrappedName(), - .Fn = Constructor.symbol_name, - .TypeName = Type.name, - }); - }, - .Attribute => |Attribute| { - try cpp.writeAll(" "); - if (Attribute.getter) |getter| { - try cpp.print( - \\JSC_DEFINE_CUSTOM_GETTER({s}, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, EncodedJSValue encodedValue, PropertyName attributeName) - \\{{ - \\ auto& vm = JSC::getVM(&lexicalGlobalObject); - \\ auto throwScope = DECLARE_THROW_SCOPE(vm); - \\}} - , .{Callback.wrappedName()}); - } - - if (comptime Attribute.setter) |setter| { - try cpp.print( - \\JSC_DEFINE_CUSTOM_SETTER({s}, (JSGlobalObject* lexicalGlobalObject, EncodedJSValue thisValue, PropertyName attributeName) - \\{{ - \\ - \\}} - , .{Callback.wrappedName()}); - } - try cpp.writeAll(" "); - }, - .Static => |Static| {}, - } - } - - if (Prototype_) |Prototype| { - h.print( - \\ - \\ - \\ - \\ - , - fields, - ); - } else {} - - h.print( - \\ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype) {{ - \\ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info()); - \\ }} - \\ - \\ EXPORT_DECLARE_INFO; - \\ - \\ template<typename, JSC::SubspaceAccess mode> static JSC::IsoSubspace* subspaceFor(JSC::VM& vm) - \\ {{ - \\ if constexpr (mode == JSC::SubspaceAccess::Concurrently) - \\ return nullptr; - \\ return &vm.plainObjectSpace; - \\ }} - \\ private: - \\ {[TypeName][s]}(JSC::VM& vm, JSC::Structure* structure) : Base(vm, structure) {{ - \\ m_zigBase = nullptr; - \\ }} - \\ void finishCreation(VM&); - \\ void* m_zigBase; - \\ - \\}} - \\ - \\ - \\ - , - fields, - ); - } - - // pub fn generateShimType(comptime Parent: type, comptime _name: []const u8, comptime static_properties: anytype) type { - // const Base = struct { - // const BaseType = @This(); - - // bytes: shim.Bytes, - // const cppFn = shim.cppFn; - - // pub const include = "Zig__" ++ _name; - // pub const name = "Zig::" ++ _name; - // pub const namespace = "Zig"; - - // pub const shim = comptime Shimmer(namespace, name, BaseType); - - // pub fn create(global: *JSGlobalObject, parent: *Parent) JSValue {} - - // pub fn getZigType(this: *BaseType, global: *JSGlobalObject) JSValue {} - - // pub fn finalize(this: *BaseType, global: *JSGlobalObject) JSValue {} - // }; - // } - }; -}; - pub usingnamespace @import("exports.zig"); pub const Callback = struct { diff --git a/src/options.zig b/src/options.zig index 0251c8416..30f8dc018 100644 --- a/src/options.zig +++ b/src/options.zig @@ -567,7 +567,7 @@ pub const JSX = struct { // ...unless new is "React.createElement" and original is ["React", "createElement"] // saves an allocation for the majority case pub fn memberListToComponentsIfDifferent(allocator: *std.mem.Allocator, original: []const string, new: string) ![]const string { - var splitter = std.mem.split(new, "."); + var splitter = std.mem.split(u8, new, "."); var needs_alloc = false; var count: usize = 0; @@ -591,7 +591,7 @@ pub const JSX = struct { var out = try allocator.alloc(string, count + 1); - splitter = std.mem.split(new, "."); + splitter = std.mem.split(u8, new, "."); var i: usize = 0; while (splitter.next()) |str| { out[i] = str; @@ -1347,7 +1347,7 @@ pub const OutputFile = struct { if (comptime std.Target.current.isDarwin()) { const rc = os.system.fcopyfile(fd_in, fd_out, null, os.system.COPYFILE_DATA); - if (os.errno(rc) == 0) { + if (rc == 0) { return; } } diff --git a/src/resolver/tsconfig_json.zig b/src/resolver/tsconfig_json.zig index 20ebd3990..d1e5054b7 100644 --- a/src/resolver/tsconfig_json.zig +++ b/src/resolver/tsconfig_json.zig @@ -273,7 +273,7 @@ pub const TSConfigJSON = struct { } const parts_count = std.mem.count(u8, text, "."); const parts = allocator.alloc(string, parts_count) catch unreachable; - var iter = std.mem.tokenize(text, "."); + var iter = std.mem.tokenize(u8, text, "."); var i: usize = 0; while (iter.next()) |part| { if (!js_lexer.isIdentifier(part)) { diff --git a/src/router.zig b/src/router.zig index 6b05a498b..148c1ed32 100644 --- a/src/router.zig +++ b/src/router.zig @@ -572,7 +572,7 @@ pub const RouteMap = struct { var segments: []string = segments_buf[0..]; var hashes: []u32 = segments_hash[0..]; var segment_i: usize = 0; - var splitter = std.mem.tokenize(path, "/"); + var splitter = std.mem.tokenize(u8, path, "/"); while (splitter.next()) |part| { if (part.len == 0 or (part.len == 1 and part[0] == '.')) continue; segments[segment_i] = part; diff --git a/src/runtime.version b/src/runtime.version index 288d942c4..b309f488e 100644 --- a/src/runtime.version +++ b/src/runtime.version @@ -1 +1 @@ -99c14959174b83f
\ No newline at end of file +a36793f60275e5e9
\ No newline at end of file diff --git a/src/sync.zig b/src/sync.zig index 8b608757c..a64e6f49e 100644 --- a/src/sync.zig +++ b/src/sync.zig @@ -535,7 +535,7 @@ pub const RwLock = if (std.builtin.os.tag != .windows and std.builtin.link_libc) }; const rc = std.c.pthread_rwlock_destroy(&self.rwlock); - std.debug.assert(rc == 0 or rc == safe_rc); + std.debug.assert(rc == .SUCCESS or rc == safe_rc); self.* = undefined; } @@ -546,12 +546,12 @@ pub const RwLock = if (std.builtin.os.tag != .windows and std.builtin.link_libc) pub fn lock(self: *RwLock) void { const rc = pthread_rwlock_wrlock(&self.rwlock); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } pub fn unlock(self: *RwLock) void { const rc = pthread_rwlock_unlock(&self.rwlock); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } pub fn tryLockShared(self: *RwLock) bool { @@ -560,12 +560,12 @@ pub const RwLock = if (std.builtin.os.tag != .windows and std.builtin.link_libc) pub fn lockShared(self: *RwLock) void { const rc = pthread_rwlock_rdlock(&self.rwlock); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } pub fn unlockShared(self: *RwLock) void { const rc = pthread_rwlock_unlock(&self.rwlock); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } const PTHREAD_RWLOCK_INITIALIZER = pthread_rwlock_t{}; @@ -639,12 +639,12 @@ pub const RwLock = if (std.builtin.os.tag != .windows and std.builtin.link_libc) else => @compileError("pthread_rwlock_t not implemented for this platform"), }; - extern "c" fn pthread_rwlock_destroy(p: *pthread_rwlock_t) callconv(.C) c_int; - extern "c" fn pthread_rwlock_rdlock(p: *pthread_rwlock_t) callconv(.C) c_int; - extern "c" fn pthread_rwlock_wrlock(p: *pthread_rwlock_t) callconv(.C) c_int; - extern "c" fn pthread_rwlock_tryrdlock(p: *pthread_rwlock_t) callconv(.C) c_int; - extern "c" fn pthread_rwlock_trywrlock(p: *pthread_rwlock_t) callconv(.C) c_int; - extern "c" fn pthread_rwlock_unlock(p: *pthread_rwlock_t) callconv(.C) c_int; + extern "c" fn pthread_rwlock_destroy(p: *pthread_rwlock_t) callconv(.C) std.os.E; + extern "c" fn pthread_rwlock_rdlock(p: *pthread_rwlock_t) callconv(.C) std.os.E; + extern "c" fn pthread_rwlock_wrlock(p: *pthread_rwlock_t) callconv(.C) std.os.E; + extern "c" fn pthread_rwlock_tryrdlock(p: *pthread_rwlock_t) callconv(.C) std.os.E; + extern "c" fn pthread_rwlock_trywrlock(p: *pthread_rwlock_t) callconv(.C) std.os.E; + extern "c" fn pthread_rwlock_unlock(p: *pthread_rwlock_t) callconv(.C) std.os.E; } else struct { @@ -880,7 +880,7 @@ else if (std.builtin.link_libc) }; const rc = std.c.pthread_mutex_destroy(&self.mutex); - std.debug.assert(rc == 0 or rc == safe_rc); + std.debug.assert(rc == .SUCCESS or rc == safe_rc); self.* = undefined; } @@ -891,12 +891,12 @@ else if (std.builtin.link_libc) pub fn lock(self: *Mutex) void { const rc = std.c.pthread_mutex_lock(&self.mutex); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } pub fn unlock(self: *Mutex) void { const rc = std.c.pthread_mutex_unlock(&self.mutex); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } extern "c" fn pthread_mutex_trylock(m: *std.c.pthread_mutex_t) callconv(.C) c_int; @@ -1076,24 +1076,24 @@ else if (std.builtin.link_libc) }; const rc = std.c.pthread_cond_destroy(&self.cond); - std.debug.assert(rc == 0 or rc == safe_rc); + std.debug.assert(rc == .SUCCESS or rc == safe_rc); self.* = undefined; } pub fn wait(self: *Condvar, mutex: *Mutex) void { const rc = std.c.pthread_cond_wait(&self.cond, &mutex.mutex); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } pub fn signal(self: *Condvar) void { const rc = std.c.pthread_cond_signal(&self.cond); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } pub fn broadcast(self: *Condvar) void { const rc = std.c.pthread_cond_broadcast(&self.cond); - std.debug.assert(rc == 0); + std.debug.assert(rc == .SUCCESS); } } else |