mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 14:23:09 +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);
|
const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC);
|
||||||
errdefer os.close(fd);
|
errdefer os.close(fd);
|
||||||
|
|
||||||
|
// TODO remove this @intCast
|
||||||
const size = @intCast(usize, (try os.fstat(fd)).size);
|
const size = @intCast(usize, (try os.fstat(fd)).size);
|
||||||
|
|
||||||
const bytes = try os.mmap(
|
const bytes = try os.mmap(
|
||||||
null,
|
null,
|
||||||
size,
|
mem.alignForward(size, mem.page_size),
|
||||||
os.PROT_READ | os.PROT_EXEC,
|
os.PROT_READ | os.PROT_EXEC,
|
||||||
os.MAP_PRIVATE,
|
os.MAP_PRIVATE,
|
||||||
fd,
|
fd,
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
|
|
||||||
pub fn main() !void {
|
pub fn main() !void {
|
||||||
const args = try std.os.argsAlloc(std.debug.global_allocator);
|
const args = try std.process.argsAlloc(std.debug.global_allocator);
|
||||||
defer std.os.argsFree(std.debug.global_allocator, args);
|
defer std.process.argsFree(std.debug.global_allocator, args);
|
||||||
|
|
||||||
const dynlib_name = args[1];
|
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();
|
defer lib.close();
|
||||||
|
|
||||||
const addr = lib.lookup("add") orelse return error.SymbolNotFound;
|
const addr = lib.lookup("add") orelse return error.SymbolNotFound;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user