authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-04-06 17:02:22+02:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-04-11 05:22:00-04:00
log0132be7bf3fd02cfb8c31ffdeaddae918a76b295
tree91b154b7d461f5ae6be6f2ed04858f3243d9517c
parentc82e1fe880629beea5660c675cfc698807205601

std.Target: Rename charSignedness() to cCharSignedness().

To be consistent with the other functions that answer C ABI questions.

5 files changed, 7 insertions(+), 7 deletions(-)

lib/compiler/aro/aro/Compilation.zig+1-1
......@@ -1087,7 +1087,7 @@ pub fn fixedEnumTagSpecifier(comp: *const Compilation) ?Type.Specifier {
10871087}
10881088
10891089pub fn getCharSignedness(comp: *const Compilation) std.builtin.Signedness {
1090 return comp.langopts.char_signedness_override orelse comp.target.charSignedness();
1090 return comp.langopts.char_signedness_override orelse comp.target.cCharSignedness();
10911091}
10921092
10931093/// Add built-in aro headers directory to system include paths
lib/std/Target.zig+1-1
......@@ -2695,7 +2695,7 @@ pub fn stackAlignment(target: Target) u16 {
26952695/// Default signedness of `char` for the native C compiler for this target
26962696/// Note that char signedness is implementation-defined and many compilers provide
26972697/// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char
2698pub fn charSignedness(target: Target) std.builtin.Signedness {
2698pub fn cCharSignedness(target: Target) std.builtin.Signedness {
26992699 if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed;
27002700
27012701 return switch (target.cpu.arch) {
src/Type.zig+3-3
......@@ -2331,7 +2331,7 @@ pub fn isInt(self: Type, zcu: *const Zcu) bool {
23312331/// Returns true if and only if the type is a fixed-width, signed integer.
23322332pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool {
23332333 return switch (ty.toIntern()) {
2334 .c_char_type => zcu.getTarget().charSignedness() == .signed,
2334 .c_char_type => zcu.getTarget().cCharSignedness() == .signed,
23352335 .isize_type, .c_short_type, .c_int_type, .c_long_type, .c_longlong_type => true,
23362336 else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
23372337 .int_type => |int_type| int_type.signedness == .signed,
......@@ -2343,7 +2343,7 @@ pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool {
23432343/// Returns true if and only if the type is a fixed-width, unsigned integer.
23442344pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool {
23452345 return switch (ty.toIntern()) {
2346 .c_char_type => zcu.getTarget().charSignedness() == .unsigned,
2346 .c_char_type => zcu.getTarget().cCharSignedness() == .unsigned,
23472347 .usize_type, .c_ushort_type, .c_uint_type, .c_ulong_type, .c_ulonglong_type => true,
23482348 else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
23492349 .int_type => |int_type| int_type.signedness == .unsigned,
......@@ -2374,7 +2374,7 @@ pub fn intInfo(starting_ty: Type, zcu: *const Zcu) InternPool.Key.IntType {
23742374 },
23752375 .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
23762376 .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
2377 .c_char_type => return .{ .signedness = zcu.getTarget().charSignedness(), .bits = target.cTypeBitSize(.char) },
2377 .c_char_type => return .{ .signedness = zcu.getTarget().cCharSignedness(), .bits = target.cTypeBitSize(.char) },
23782378 .c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) },
23792379 .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) },
23802380 .c_int_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.int) },
src/arch/x86_64/CodeGen.zig+1-1
......@@ -109873,7 +109873,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int {
109873109873 .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() },
109874109874 .isize => .{ .signedness = .signed, .bits = cg.target.ptrBitWidth() },
109875109875 .usize => .{ .signedness = .unsigned, .bits = cg.target.ptrBitWidth() },
109876 .c_char => .{ .signedness = cg.target.charSignedness(), .bits = cg.target.cTypeBitSize(.char) },
109876 .c_char => .{ .signedness = cg.target.cCharSignedness(), .bits = cg.target.cTypeBitSize(.char) },
109877109877 .c_short => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.short) },
109878109878 .c_ushort => .{ .signedness = .unsigned, .bits = cg.target.cTypeBitSize(.short) },
109879109879 .c_int => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.int) },
src/codegen/c/Type.zig+1-1
......@@ -78,7 +78,7 @@ pub fn isInteger(ctype: CType) bool {
7878
7979pub fn signedness(ctype: CType, mod: *Module) std.builtin.Signedness {
8080 return switch (ctype.index) {
81 .char => mod.resolved_target.result.charSignedness(),
81 .char => mod.resolved_target.result.cCharSignedness(),
8282 .@"signed char",
8383 .short,
8484 .int,