From 0132be7bf3fd02cfb8c31ffdeaddae918a76b295 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 6 Apr 2025 17:02:22 +0200 Subject: [PATCH] std.Target: Rename charSignedness() to cCharSignedness(). To be consistent with the other functions that answer C ABI questions. --- lib/compiler/aro/aro/Compilation.zig | 2 +- lib/std/Target.zig | 2 +- src/Type.zig | 6 +++--- src/arch/x86_64/CodeGen.zig | 2 +- src/codegen/c/Type.zig | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/compiler/aro/aro/Compilation.zig b/lib/compiler/aro/aro/Compilation.zig index 68bad1a5ce..798c192516 100644 --- a/lib/compiler/aro/aro/Compilation.zig +++ b/lib/compiler/aro/aro/Compilation.zig @@ -1087,7 +1087,7 @@ pub fn fixedEnumTagSpecifier(comp: *const Compilation) ?Type.Specifier { } pub fn getCharSignedness(comp: *const Compilation) std.builtin.Signedness { - return comp.langopts.char_signedness_override orelse comp.target.charSignedness(); + return comp.langopts.char_signedness_override orelse comp.target.cCharSignedness(); } /// Add built-in aro headers directory to system include paths diff --git a/lib/std/Target.zig b/lib/std/Target.zig index e9a973f2fd..ea7be17697 100644 --- a/lib/std/Target.zig +++ b/lib/std/Target.zig @@ -2695,7 +2695,7 @@ pub fn stackAlignment(target: Target) u16 { /// Default signedness of `char` for the native C compiler for this target /// Note that char signedness is implementation-defined and many compilers provide /// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char -pub fn charSignedness(target: Target) std.builtin.Signedness { +pub fn cCharSignedness(target: Target) std.builtin.Signedness { if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed; return switch (target.cpu.arch) { diff --git a/src/Type.zig b/src/Type.zig index f067ac84b2..dfa77f3383 100644 --- a/src/Type.zig +++ b/src/Type.zig @@ -2331,7 +2331,7 @@ pub fn isInt(self: Type, zcu: *const Zcu) bool { /// Returns true if and only if the type is a fixed-width, signed integer. pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool { return switch (ty.toIntern()) { - .c_char_type => zcu.getTarget().charSignedness() == .signed, + .c_char_type => zcu.getTarget().cCharSignedness() == .signed, .isize_type, .c_short_type, .c_int_type, .c_long_type, .c_longlong_type => true, else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) { .int_type => |int_type| int_type.signedness == .signed, @@ -2343,7 +2343,7 @@ pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool { /// Returns true if and only if the type is a fixed-width, unsigned integer. pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool { return switch (ty.toIntern()) { - .c_char_type => zcu.getTarget().charSignedness() == .unsigned, + .c_char_type => zcu.getTarget().cCharSignedness() == .unsigned, .usize_type, .c_ushort_type, .c_uint_type, .c_ulong_type, .c_ulonglong_type => true, else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) { .int_type => |int_type| int_type.signedness == .unsigned, @@ -2374,7 +2374,7 @@ pub fn intInfo(starting_ty: Type, zcu: *const Zcu) InternPool.Key.IntType { }, .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() }, .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() }, - .c_char_type => return .{ .signedness = zcu.getTarget().charSignedness(), .bits = target.cTypeBitSize(.char) }, + .c_char_type => return .{ .signedness = zcu.getTarget().cCharSignedness(), .bits = target.cTypeBitSize(.char) }, .c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) }, .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) }, .c_int_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.int) }, diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index c0eea14c92..38b56f6d4d 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -109873,7 +109873,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int { .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() }, .isize => .{ .signedness = .signed, .bits = cg.target.ptrBitWidth() }, .usize => .{ .signedness = .unsigned, .bits = cg.target.ptrBitWidth() }, - .c_char => .{ .signedness = cg.target.charSignedness(), .bits = cg.target.cTypeBitSize(.char) }, + .c_char => .{ .signedness = cg.target.cCharSignedness(), .bits = cg.target.cTypeBitSize(.char) }, .c_short => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.short) }, .c_ushort => .{ .signedness = .unsigned, .bits = cg.target.cTypeBitSize(.short) }, .c_int => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.int) }, diff --git a/src/codegen/c/Type.zig b/src/codegen/c/Type.zig index 451bbc7818..db7455ebb0 100644 --- a/src/codegen/c/Type.zig +++ b/src/codegen/c/Type.zig @@ -78,7 +78,7 @@ pub fn isInteger(ctype: CType) bool { pub fn signedness(ctype: CType, mod: *Module) std.builtin.Signedness { return switch (ctype.index) { - .char => mod.resolved_target.result.charSignedness(), + .char => mod.resolved_target.result.cCharSignedness(), .@"signed char", .short, .int,