| author | |
| committer | |
| log | 8ca294c430ecc4e878d9e5cfb178c20c07b83514 |
| tree | b9d4e1616de6417c172bfadfb39e36b922c70d1e |
| parent | 8eaf1387c712c62e96fa165ac3390c8f8f924daa |
| signature |
2 files changed, 5 insertions(+), 4 deletions(-)
std/dynamic_library.zig+2-1| ... | @@ -108,11 +108,12 @@ pub const LinuxDynLib = struct { | ... | @@ -108,11 +108,12 @@ pub const LinuxDynLib = struct { |
| 108 | const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC); | 108 | const fd = try os.open(path, 0, os.O_RDONLY | os.O_CLOEXEC); |
| 109 | errdefer os.close(fd); | 109 | errdefer os.close(fd); |
| 110 | 110 | ||
| 111 | // TODO remove this @intCast | ||
| 111 | const size = @intCast(usize, (try os.fstat(fd)).size); | 112 | const size = @intCast(usize, (try os.fstat(fd)).size); |
| 112 | 113 | ||
| 113 | const bytes = try os.mmap( | 114 | const bytes = try os.mmap( |
| 114 | null, | 115 | null, |
| 115 | size, | 116 | mem.alignForward(size, mem.page_size), |
| 116 | os.PROT_READ | os.PROT_EXEC, | 117 | os.PROT_READ | os.PROT_EXEC, |
| 117 | os.MAP_PRIVATE, | 118 | os.MAP_PRIVATE, |
| 118 | fd, | 119 | fd, |
test/standalone/load_dynamic_library/main.zig+3-3| ... | @@ -1,12 +1,12 @@ | ... | @@ -1,12 +1,12 @@ |
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | 2 | ||
| 3 | pub fn main() !void { | 3 | pub fn main() !void { |
| 4 | const args = try std.os.argsAlloc(std.debug.global_allocator); | 4 | const args = try std.process.argsAlloc(std.debug.global_allocator); |
| 5 | defer std.os.argsFree(std.debug.global_allocator, args); | 5 | defer std.process.argsFree(std.debug.global_allocator, args); |
| 6 | 6 | ||
| 7 | const dynlib_name = args[1]; | 7 | const dynlib_name = args[1]; |
| 8 | 8 | ||
| 9 | var lib = try std.DynLib.open(std.debug.global_allocator, dynlib_name); | 9 | var lib = try std.DynLib.open(dynlib_name); |
| 10 | defer lib.close(); | 10 | defer lib.close(); |
| 11 | 11 | ||
| 12 | const addr = lib.lookup("add") orelse return error.SymbolNotFound; | 12 | const addr = lib.lookup("add") orelse return error.SymbolNotFound; |