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 {...@@ -1087,7 +1087,7 @@ pub fn fixedEnumTagSpecifier(comp: *const Compilation) ?Type.Specifier {
1087}1087}
10881088
1089pub fn getCharSignedness(comp: *const Compilation) std.builtin.Signedness {1089pub 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();
1091}1091}
10921092
1093/// Add built-in aro headers directory to system include paths1093/// 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 {...@@ -2695,7 +2695,7 @@ pub fn stackAlignment(target: Target) u16 {
2695/// Default signedness of `char` for the native C compiler for this target2695/// Default signedness of `char` for the native C compiler for this target
2696/// Note that char signedness is implementation-defined and many compilers provide2696/// Note that char signedness is implementation-defined and many compilers provide
2697/// an option to override the default signedness e.g. GCC's -funsigned-char / -fsigned-char2697/// 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 {
2699 if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed;2699 if (target.os.tag.isDarwin() or target.os.tag == .windows or target.os.tag == .uefi) return .signed;
27002700
2701 return switch (target.cpu.arch) {2701 return switch (target.cpu.arch) {
src/Type.zig+3-3
...@@ -2331,7 +2331,7 @@ pub fn isInt(self: Type, zcu: *const Zcu) bool {...@@ -2331,7 +2331,7 @@ pub fn isInt(self: Type, zcu: *const Zcu) bool {
2331/// Returns true if and only if the type is a fixed-width, signed integer.2331/// Returns true if and only if the type is a fixed-width, signed integer.
2332pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool {2332pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool {
2333 return switch (ty.toIntern()) {2333 return switch (ty.toIntern()) {
2334 .c_char_type => zcu.getTarget().charSignedness() == .signed,2334 .c_char_type => zcu.getTarget().cCharSignedness() == .signed,
2335 .isize_type, .c_short_type, .c_int_type, .c_long_type, .c_longlong_type => true,2335 .isize_type, .c_short_type, .c_int_type, .c_long_type, .c_longlong_type => true,
2336 else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) {2336 else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
2337 .int_type => |int_type| int_type.signedness == .signed,2337 .int_type => |int_type| int_type.signedness == .signed,
...@@ -2343,7 +2343,7 @@ pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool {...@@ -2343,7 +2343,7 @@ pub fn isSignedInt(ty: Type, zcu: *const Zcu) bool {
2343/// Returns true if and only if the type is a fixed-width, unsigned integer.2343/// Returns true if and only if the type is a fixed-width, unsigned integer.
2344pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool {2344pub fn isUnsignedInt(ty: Type, zcu: *const Zcu) bool {
2345 return switch (ty.toIntern()) {2345 return switch (ty.toIntern()) {
2346 .c_char_type => zcu.getTarget().charSignedness() == .unsigned,2346 .c_char_type => zcu.getTarget().cCharSignedness() == .unsigned,
2347 .usize_type, .c_ushort_type, .c_uint_type, .c_ulong_type, .c_ulonglong_type => true,2347 .usize_type, .c_ushort_type, .c_uint_type, .c_ulong_type, .c_ulonglong_type => true,
2348 else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) {2348 else => switch (zcu.intern_pool.indexToKey(ty.toIntern())) {
2349 .int_type => |int_type| int_type.signedness == .unsigned,2349 .int_type => |int_type| int_type.signedness == .unsigned,
...@@ -2374,7 +2374,7 @@ pub fn intInfo(starting_ty: Type, zcu: *const Zcu) InternPool.Key.IntType {...@@ -2374,7 +2374,7 @@ pub fn intInfo(starting_ty: Type, zcu: *const Zcu) InternPool.Key.IntType {
2374 },2374 },
2375 .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },2375 .usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
2376 .isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },2376 .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) },
2378 .c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) },2378 .c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) },
2379 .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) },2379 .c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) },
2380 .c_int_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.int) },2380 .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 {...@@ -109873,7 +109873,7 @@ fn intInfo(cg: *CodeGen, ty: Type) ?std.builtin.Type.Int {
109873 .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() },109873 .anyerror => .{ .signedness = .unsigned, .bits = zcu.errorSetBits() },
109874 .isize => .{ .signedness = .signed, .bits = cg.target.ptrBitWidth() },109874 .isize => .{ .signedness = .signed, .bits = cg.target.ptrBitWidth() },
109875 .usize => .{ .signedness = .unsigned, .bits = cg.target.ptrBitWidth() },109875 .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) },
109877 .c_short => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.short) },109877 .c_short => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.short) },
109878 .c_ushort => .{ .signedness = .unsigned, .bits = cg.target.cTypeBitSize(.short) },109878 .c_ushort => .{ .signedness = .unsigned, .bits = cg.target.cTypeBitSize(.short) },
109879 .c_int => .{ .signedness = .signed, .bits = cg.target.cTypeBitSize(.int) },109879 .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 {...@@ -78,7 +78,7 @@ pub fn isInteger(ctype: CType) bool {
7878
79pub fn signedness(ctype: CType, mod: *Module) std.builtin.Signedness {79pub fn signedness(ctype: CType, mod: *Module) std.builtin.Signedness {
80 return switch (ctype.index) {80 return switch (ctype.index) {
81 .char => mod.resolved_target.result.charSignedness(),81 .char => mod.resolved_target.result.cCharSignedness(),
82 .@"signed char",82 .@"signed char",
83 .short,83 .short,
84 .int,84 .int,