| ... | @@ -154,8 +154,22 @@ pub usingnamespace @import("linux/io_uring.zig"); | ... | @@ -154,8 +154,22 @@ pub usingnamespace @import("linux/io_uring.zig"); |
| 154 | /// Set by startup code, used by `getauxval`. | 154 | /// Set by startup code, used by `getauxval`. |
| 155 | pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; | 155 | pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; |
| 156 | | 156 | |
| 157 | /// See `std.elf` for the constants. | 157 | pub usingnamespace if (switch (builtin.zig_backend) { |
| 158 | pub fn getauxval(index: usize) usize { | 158 | // Calling extern functions is not yet supported with these backends |
| | 159 | .stage2_x86_64, .stage2_aarch64, .stage2_arm, .stage2_riscv64, .stage2_sparc64 => false, |
| | 160 | else => !builtin.link_libc, |
| | 161 | }) struct { |
| | 162 | /// See `std.elf` for the constants. |
| | 163 | /// This matches the libc getauxval function. |
| | 164 | pub extern fn getauxval(index: usize) usize; |
| | 165 | comptime { |
| | 166 | @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak }); |
| | 167 | } |
| | 168 | } else struct { |
| | 169 | pub const getauxval = getauxvalImpl; |
| | 170 | }; |
| | 171 | |
| | 172 | fn getauxvalImpl(index: usize) callconv(.C) usize { |
| 159 | const auxv = elf_aux_maybe orelse return 0; | 173 | const auxv = elf_aux_maybe orelse return 0; |
| 160 | var i: usize = 0; | 174 | var i: usize = 0; |
| 161 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { | 175 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { |