| ... | @@ -153,13 +153,11 @@ pub usingnamespace @import("linux/io_uring.zig"); | ... | @@ -153,13 +153,11 @@ pub usingnamespace @import("linux/io_uring.zig"); |
| 153 | | 153 | |
| 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 | pub extern var _elf_aux_maybe: ?[*]std.elf.Auxv; | | |
| 157 | comptime { | | |
| 158 | @export(elf_aux_maybe, .{ .name = "_elf_aux_maybe", .linkage = .Weak }); | | |
| 159 | } | | |
| 160 | | 156 | |
| 161 | /// See `std.elf` for the constants. | 157 | /// See `std.elf` for the constants. |
| 162 | pub fn getauxval(index: usize) usize { | 158 | /// This matches the libc getauxval function. |
| | 159 | pub extern fn getauxval(index: usize) usize; |
| | 160 | fn getauxvalImpl(index: usize) callconv(.C) usize { |
| 163 | const auxv = elf_aux_maybe orelse return 0; | 161 | const auxv = elf_aux_maybe orelse return 0; |
| 164 | var i: usize = 0; | 162 | var i: usize = 0; |
| 165 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { | 163 | while (auxv[i].a_type != std.elf.AT_NULL) : (i += 1) { |
| ... | @@ -168,6 +166,9 @@ pub fn getauxval(index: usize) usize { | ... | @@ -168,6 +166,9 @@ pub fn getauxval(index: usize) usize { |
| 168 | } | 166 | } |
| 169 | return 0; | 167 | return 0; |
| 170 | } | 168 | } |
| | 169 | comptime { |
| | 170 | @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak }); |
| | 171 | } |
| 171 | | 172 | |
| 172 | // Some architectures (and some syscalls) require 64bit parameters to be passed | 173 | // Some architectures (and some syscalls) require 64bit parameters to be passed |
| 173 | // in a even-aligned register pair. | 174 | // in a even-aligned register pair. |