authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-07 15:28:26+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-08 08:02:44+00:00
log229800482d28c9d55abf116cb315c78adddabe11
tree9bd1854a4886ee6b16001bf32a3d07492efdf697
parent14ab9fb1541dd7e273504eec1417c4645f39a317
signaturelock-open Commit is signed but in an unrecognized format.

std.os.linux: do not use `usingnamespace` to define getauxval

This usage of `usingnamespace` was removed fairly trivially - the resulting code is, IMO, more clear. Eliminates one more usage of `usingnamespace` from the standard library.

1 files changed, 10 insertions(+), 9 deletions(-)

lib/std/os/linux.zig+10-9
......@@ -388,20 +388,21 @@ pub usingnamespace @import("linux/io_uring.zig");
388388/// Set by startup code, used by `getauxval`.
389389pub var elf_aux_maybe: ?[*]std.elf.Auxv = null;
390390
391pub usingnamespace if (switch (builtin.zig_backend) {
391const extern_getauxval = switch (builtin.zig_backend) {
392392 // Calling extern functions is not yet supported with these backends
393393 .stage2_aarch64, .stage2_arm, .stage2_riscv64, .stage2_sparc64 => false,
394394 else => !builtin.link_libc,
395}) struct {
396 /// See `std.elf` for the constants.
397 /// This matches the libc getauxval function.
398 pub extern fn getauxval(index: usize) usize;
399 comptime {
395};
396
397comptime {
398 if (extern_getauxval) {
400399 @export(getauxvalImpl, .{ .name = "getauxval", .linkage = .Weak });
401400 }
402} else struct {
403 pub const getauxval = getauxvalImpl;
404};
401}
402
403pub const getauxval = if (extern_getauxval) struct {
404 extern fn getauxval(index: usize) usize;
405}.getauxval else getauxvalImpl;
405406
406407fn getauxvalImpl(index: usize) callconv(.C) usize {
407408 const auxv = elf_aux_maybe orelse return 0;