diff options
-rw-r--r-- | src/boringssl.zig | 19 | ||||
-rw-r--r-- | src/bun.js/api/bun.zig | 2 | ||||
-rw-r--r-- | src/sha.zig | 3 |
3 files changed, 16 insertions, 8 deletions
diff --git a/src/boringssl.zig b/src/boringssl.zig index 825b7d036..a6e767428 100644 --- a/src/boringssl.zig +++ b/src/boringssl.zig @@ -15,9 +15,12 @@ pub fn load() void { boring.OpenSSL_add_all_algorithms(); if (!builtin.is_test) { - std.mem.doNotOptimizeAway(&OPENSSL_memory_alloc); + comptime { + @export(bun.Mimalloc.mi_malloc, .{ .name = "OPENSSL_memory_alloc", .linkage = .Strong }); + @export(bun.Mimalloc.mi_usable_size, .{ .name = "OPENSSL_memory_get_size", .linkage = .Strong }); + } + std.mem.doNotOptimizeAway(&OPENSSL_memory_free); - std.mem.doNotOptimizeAway(&OPENSSL_memory_get_size); } } @@ -59,9 +62,9 @@ pub fn initClient() *boring.SSL { // into the process, including pthreads locks. Failing to meet these constraints // may result in deadlocks, crashes, or memory corruption. -export fn OPENSSL_memory_alloc(size: usize) ?*anyopaque { - return bun.Mimalloc.mi_malloc(size); -} +// export fn OPENSSL_memory_alloc(size: usize) ?*anyopaque { +// return +// } // BoringSSL always expects memory to be zero'd export fn OPENSSL_memory_free(ptr: *anyopaque) void { @@ -69,9 +72,9 @@ export fn OPENSSL_memory_free(ptr: *anyopaque) void { bun.Mimalloc.mi_free(ptr); } -export fn OPENSSL_memory_get_size(ptr: ?*const anyopaque) usize { - return bun.Mimalloc.mi_usable_size(ptr); -} +// export fn OPENSSL_memory_get_size(ptr: ?*const anyopaque) usize { +// return bun.Mimalloc.mi_usable_size(ptr); +// } test "load" { load(); diff --git a/src/bun.js/api/bun.zig b/src/bun.js/api/bun.zig index fd91ef897..5e92a470d 100644 --- a/src/bun.js/api/bun.zig +++ b/src/bun.js/api/bun.zig @@ -1497,6 +1497,8 @@ pub const Crypto = struct { pub const Digest = [BoringSSL.EVP_MAX_MD_SIZE]u8; pub fn init(algorithm: Algorithm, md: *const BoringSSL.EVP_MD, engine: *BoringSSL.ENGINE) EVP { + BoringSSL.load(); + var ctx: BoringSSL.EVP_MD_CTX = undefined; BoringSSL.EVP_MD_CTX_init(&ctx); _ = BoringSSL.EVP_DigestInit_ex(&ctx, md, engine); diff --git a/src/sha.zig b/src/sha.zig index cda850d1f..fec9d68bd 100644 --- a/src/sha.zig +++ b/src/sha.zig @@ -9,6 +9,7 @@ fn NewHasher(comptime digest_size: comptime_int, comptime ContextType: type, com pub const digest: comptime_int = digest_size; pub fn init() @This() { + BoringSSL.load(); var this: @This() = .{ .hasher = undefined, }; @@ -45,6 +46,8 @@ fn NewEVP( pub const digest: comptime_int = digest_size; pub fn init() @This() { + BoringSSL.load(); + const md = @call(.auto, @field(BoringSSL, MDName), .{}); var this: @This() = .{ .ctx = undefined, |