mirror of
https://github.com/ziglang/zig.git
synced 2025-12-16 11:13:08 +00:00
process.zig: remove unused function getSelfExeSharedLibPaths
This commit is contained in:
parent
699e7f721b
commit
3c3def6ac2
@ -1067,87 +1067,6 @@ pub fn getBaseAddress() usize {
|
||||
}
|
||||
}
|
||||
|
||||
/// Caller owns the result value and each inner slice.
|
||||
/// TODO Remove the `Allocator` requirement from this API, which will remove the `Allocator`
|
||||
/// requirement from `std.zig.system.NativeTargetInfo.detect`. Most likely this will require
|
||||
/// introducing a new, lower-level function which takes a callback function, and then this
|
||||
/// function which takes an allocator can exist on top of it.
|
||||
pub fn getSelfExeSharedLibPaths(allocator: Allocator) error{OutOfMemory}![][:0]u8 {
|
||||
switch (builtin.link_mode) {
|
||||
.Static => return &[_][:0]u8{},
|
||||
.Dynamic => {},
|
||||
}
|
||||
const List = std.ArrayList([:0]u8);
|
||||
switch (builtin.os.tag) {
|
||||
.linux,
|
||||
.freebsd,
|
||||
.netbsd,
|
||||
.dragonfly,
|
||||
.openbsd,
|
||||
.solaris,
|
||||
=> {
|
||||
var paths = List.init(allocator);
|
||||
errdefer {
|
||||
const slice = paths.toOwnedSlice();
|
||||
for (slice) |item| {
|
||||
allocator.free(item);
|
||||
}
|
||||
allocator.free(slice);
|
||||
}
|
||||
try os.dl_iterate_phdr(&paths, error{OutOfMemory}, struct {
|
||||
fn callback(info: *os.dl_phdr_info, size: usize, list: *List) !void {
|
||||
_ = size;
|
||||
const name = info.dlpi_name orelse return;
|
||||
if (name[0] == '/') {
|
||||
const item = try list.allocator.dupeZ(u8, mem.sliceTo(name, 0));
|
||||
errdefer list.allocator.free(item);
|
||||
try list.append(item);
|
||||
}
|
||||
}
|
||||
}.callback);
|
||||
return paths.toOwnedSlice();
|
||||
},
|
||||
.macos, .ios, .watchos, .tvos => {
|
||||
var paths = List.init(allocator);
|
||||
errdefer {
|
||||
const slice = paths.toOwnedSlice();
|
||||
for (slice) |item| {
|
||||
allocator.free(item);
|
||||
}
|
||||
allocator.free(slice);
|
||||
}
|
||||
const img_count = std.c._dyld_image_count();
|
||||
var i: u32 = 0;
|
||||
while (i < img_count) : (i += 1) {
|
||||
const name = std.c._dyld_get_image_name(i);
|
||||
const item = try allocator.dupeZ(u8, mem.sliceTo(name, 0));
|
||||
errdefer allocator.free(item);
|
||||
try paths.append(item);
|
||||
}
|
||||
return paths.toOwnedSlice();
|
||||
},
|
||||
// revisit if Haiku implements dl_iterat_phdr (https://dev.haiku-os.org/ticket/15743)
|
||||
.haiku => {
|
||||
var paths = List.init(allocator);
|
||||
errdefer {
|
||||
const slice = paths.toOwnedSlice();
|
||||
for (slice) |item| {
|
||||
allocator.free(item);
|
||||
}
|
||||
allocator.free(slice);
|
||||
}
|
||||
|
||||
var b = "/boot/system/runtime_loader";
|
||||
const item = try allocator.dupeZ(u8, mem.sliceTo(b, 0));
|
||||
errdefer allocator.free(item);
|
||||
try paths.append(item);
|
||||
|
||||
return paths.toOwnedSlice();
|
||||
},
|
||||
else => @compileError("getSelfExeSharedLibPaths unimplemented for this target"),
|
||||
}
|
||||
}
|
||||
|
||||
/// Tells whether calling the `execv` or `execve` functions will be a compile error.
|
||||
pub const can_execv = switch (builtin.os.tag) {
|
||||
.windows, .haiku, .wasi => false,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user