diff options
author | 2023-01-07 07:09:48 -0800 | |
---|---|---|
committer | 2023-01-07 07:09:48 -0800 | |
commit | 87983464d8a331c1ddd09eced9920269a759f0a9 (patch) | |
tree | b08a5aef5c2d18f25a5ee46c88bec84d5b8ee907 /src/c.zig | |
parent | d5565ab2cdd7099a5852ba5ba6d180ef291af084 (diff) | |
download | bun-87983464d8a331c1ddd09eced9920269a759f0a9.tar.gz bun-87983464d8a331c1ddd09eced9920269a759f0a9.tar.zst bun-87983464d8a331c1ddd09eced9920269a759f0a9.zip |
Implement DNS module (#1691)
* Boilerplate for DNS stuff
* Add c-ares
* lookup
* make
* Implement dns.lookup
* Create c-ares
* wip
* normalize
* repro
* Revert "repro"
This reverts commit 8b93e0c295b335b8882a9601da47720348549beb.
* Implement macOS `getaddrinfo_async_start`
* embiggen
* Update string_immutable.zig
* Update Makefile
* alright
* Update .gitignore
* Add types
* more ccache
* Update Dockerfile
* Update Dockerfile
* Update Dockerfile
* Update bun.d.ts
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Diffstat (limited to 'src/c.zig')
-rw-r--r-- | src/c.zig | 23 |
1 files changed, 17 insertions, 6 deletions
@@ -393,7 +393,7 @@ const LazyStatus = enum { failed, }; -pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?Type { +pub fn dlsymWithHandle(comptime Type: type, comptime name: [:0]const u8, comptime handle_getter: fn () ?*anyopaque) ?Type { if (comptime @typeInfo(Type) != .Pointer) { @compileError("dlsym must be a pointer type (e.g. ?const *fn()). Received " ++ @typeName(Type) ++ "."); } @@ -404,11 +404,7 @@ pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?Type { }; if (Wrapper.loaded == .pending) { - const RTLD_DEFAULT = if (bun.Environment.isMac) - @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -2))) - else - @intToPtr(?*anyopaque, @as(usize, 0)); - const result = std.c.dlsym(RTLD_DEFAULT, name); + const result = std.c.dlsym(@call(.always_inline, handle_getter, .{}), name); if (result) |ptr| { Wrapper.function = bun.cast(Type, ptr); @@ -427,6 +423,21 @@ pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?Type { return null; } +pub fn dlsym(comptime Type: type, comptime name: [:0]const u8) ?Type { + const handle_getter = struct { + const RTLD_DEFAULT = if (bun.Environment.isMac) + @intToPtr(?*anyopaque, @bitCast(usize, @as(isize, -2))) + else + @intToPtr(?*anyopaque, @as(usize, 0)); + + pub fn getter() ?*anyopaque { + return RTLD_DEFAULT; + } + }.getter; + + return dlsymWithHandle(Type, name, handle_getter); +} + // set in c-bindings.cpp pub extern fn get_process_priority(pid: c_uint) i32; pub extern fn set_process_priority(pid: c_uint, priority: c_int) i32; |