| ... | ... | @@ -154,9 +154,21 @@ pub usingnamespace @import("linux/io_uring.zig"); |
| 154 | 154 | /// Set by startup code, used by `getauxval`. |
| 155 | 155 | pub var elf_aux_maybe: ?[*]std.elf.Auxv = null; |
| 156 | 156 | |
| 157 | | /// See `std.elf` for the constants. |
| 158 | | /// This matches the libc getauxval function. |
| 159 | | pub extern fn getauxval(index: usize) usize; |
| 157 | pub usingnamespace if (switch (builtin.zig_backend) { |
| 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 | |
| 160 | 172 | fn getauxvalImpl(index: usize) callconv(.C) usize { |
| 161 | 173 | const auxv = elf_aux_maybe orelse return 0; |
| 162 | 174 | var i: usize = 0; |
| ... | ... | @@ -166,11 +178,6 @@ fn getauxvalImpl(index: usize) callconv(.C) usize { |
| 166 | 178 | } |
| 167 | 179 | return 0; |
| 168 | 180 | } |
| 169 | | comptime { |
| 170 | | if (!builtin.link_libc) { |
| 171 | | @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak }); |
| 172 | | } |
| 173 | | } |
| 174 | 181 | |
| 175 | 182 | // Some architectures (and some syscalls) require 64bit parameters to be passed |
| 176 | 183 | // in a even-aligned register pair. |