mirror of
https://github.com/ziglang/zig.git
synced 2025-01-26 11:51:34 +00:00
update load dynamic library test for std lib changes
This commit is contained in:
parent
8eaf1387c7
commit
8ca294c430
@ -108,11 +108,12 @@ pub const LinuxDynLib = struct {
|
||||
const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);
|
||||
errdefer os.close(fd);
|
||||
|
||||
// TODO remove this @intCast
|
||||
const size = @intCast(usize, (try os.fstat(fd)).size);
|
||||
|
||||
const bytes = try os.mmap(
|
||||
null,
|
||||
size,
|
||||
mem.alignForward(size, mem.page_size),
|
||||
os.PROT_READ | os.PROT_EXEC,
|
||||
os.MAP_PRIVATE,
|
||||
fd,
|
||||
|
@ -1,12 +1,12 @@
|
||||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
const args = try std.os.argsAlloc(std.debug.global_allocator);
|
||||
defer std.os.argsFree(std.debug.global_allocator, args);
|
||||
const args = try std.process.argsAlloc(std.debug.global_allocator);
|
||||
defer std.process.argsFree(std.debug.global_allocator, args);
|
||||
|
||||
const dynlib_name = args[1];
|
||||
|
||||
var lib = try std.DynLib.open(std.debug.global_allocator, dynlib_name);
|
||||
var lib = try std.DynLib.open(dynlib_name);
|
||||
defer lib.close();
|
||||
|
||||
const addr = lib.lookup("add") orelse return error.SymbolNotFound;
|
||||
|
Loading…
Reference in New Issue
Block a user