Skip to content

Commit 4ef956e

Browse files
committed
std.Target: Rename c_type_* functions to camel case
From https://ziglang.org/documentation/master/#Names: > If `x` is otherwise callable, then `x` should be `camelCase`.
1 parent fd434fc commit 4ef956e

File tree

11 files changed

+109
-109
lines changed

11 files changed

+109
-109
lines changed

lib/compiler/aro/aro/Parser.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5631,15 +5631,15 @@ pub const Result = struct {
56315631
};
56325632
const a_spec = a.ty.canonicalize(.standard).specifier;
56335633
const b_spec = b.ty.canonicalize(.standard).specifier;
5634-
if (p.comp.target.c_type_bit_size(.longdouble) == 128) {
5634+
if (p.comp.target.cTypeBitSize(.longdouble) == 128) {
56355635
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
56365636
}
56375637
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[1])) return;
5638-
if (p.comp.target.c_type_bit_size(.longdouble) == 80) {
5638+
if (p.comp.target.cTypeBitSize(.longdouble) == 80) {
56395639
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
56405640
}
56415641
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[2])) return;
5642-
if (p.comp.target.c_type_bit_size(.longdouble) == 64) {
5642+
if (p.comp.target.cTypeBitSize(.longdouble) == 64) {
56435643
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[0])) return;
56445644
}
56455645
if (try a.floatConversion(b, a_spec, b_spec, p, float_types[3])) return;

lib/compiler/aro/aro/Type.zig

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -991,19 +991,19 @@ pub fn sizeof(ty: Type, comp: *const Compilation) ?u64 {
991991
.incomplete_array => return if (comp.langopts.emulate == .msvc) @as(?u64, 0) else null,
992992
.func, .var_args_func, .old_style_func, .void, .bool => 1,
993993
.char, .schar, .uchar => 1,
994-
.short => comp.target.c_type_byte_size(.short),
995-
.ushort => comp.target.c_type_byte_size(.ushort),
996-
.int => comp.target.c_type_byte_size(.int),
997-
.uint => comp.target.c_type_byte_size(.uint),
998-
.long => comp.target.c_type_byte_size(.long),
999-
.ulong => comp.target.c_type_byte_size(.ulong),
1000-
.long_long => comp.target.c_type_byte_size(.longlong),
1001-
.ulong_long => comp.target.c_type_byte_size(.ulonglong),
1002-
.long_double => comp.target.c_type_byte_size(.longdouble),
994+
.short => comp.target.cTypeByteSize(.short),
995+
.ushort => comp.target.cTypeByteSize(.ushort),
996+
.int => comp.target.cTypeByteSize(.int),
997+
.uint => comp.target.cTypeByteSize(.uint),
998+
.long => comp.target.cTypeByteSize(.long),
999+
.ulong => comp.target.cTypeByteSize(.ulong),
1000+
.long_long => comp.target.cTypeByteSize(.longlong),
1001+
.ulong_long => comp.target.cTypeByteSize(.ulonglong),
1002+
.long_double => comp.target.cTypeByteSize(.longdouble),
10031003
.int128, .uint128 => 16,
10041004
.fp16, .float16 => 2,
1005-
.float => comp.target.c_type_byte_size(.float),
1006-
.double => comp.target.c_type_byte_size(.double),
1005+
.float => comp.target.cTypeByteSize(.float),
1006+
.double => comp.target.cTypeByteSize(.double),
10071007
.float80 => 16,
10081008
.float128 => 16,
10091009
.bit_int => {
@@ -1049,7 +1049,7 @@ pub fn bitSizeof(ty: Type, comp: *const Compilation) ?u64 {
10491049
.typeof_expr => ty.data.expr.ty.bitSizeof(comp),
10501050
.attributed => ty.data.attributed.base.bitSizeof(comp),
10511051
.bit_int => return ty.data.int.bits,
1052-
.long_double => comp.target.c_type_bit_size(.longdouble),
1052+
.long_double => comp.target.cTypeBitSize(.longdouble),
10531053
.float80 => return 80,
10541054
else => 8 * (ty.sizeof(comp) orelse return null),
10551055
};
@@ -1104,24 +1104,24 @@ pub fn alignof(ty: Type, comp: *const Compilation) u29 {
11041104
=> return ty.makeReal().alignof(comp),
11051105
// zig fmt: on
11061106

1107-
.short => comp.target.c_type_alignment(.short),
1108-
.ushort => comp.target.c_type_alignment(.ushort),
1109-
.int => comp.target.c_type_alignment(.int),
1110-
.uint => comp.target.c_type_alignment(.uint),
1107+
.short => comp.target.cTypeAlignment(.short),
1108+
.ushort => comp.target.cTypeAlignment(.ushort),
1109+
.int => comp.target.cTypeAlignment(.int),
1110+
.uint => comp.target.cTypeAlignment(.uint),
11111111

1112-
.long => comp.target.c_type_alignment(.long),
1113-
.ulong => comp.target.c_type_alignment(.ulong),
1114-
.long_long => comp.target.c_type_alignment(.longlong),
1115-
.ulong_long => comp.target.c_type_alignment(.ulonglong),
1112+
.long => comp.target.cTypeAlignment(.long),
1113+
.ulong => comp.target.cTypeAlignment(.ulong),
1114+
.long_long => comp.target.cTypeAlignment(.longlong),
1115+
.ulong_long => comp.target.cTypeAlignment(.ulonglong),
11161116

11171117
.bit_int => @min(
11181118
std.math.ceilPowerOfTwoPromote(u16, (ty.data.int.bits + 7) / 8),
11191119
16, // comp.target.maxIntAlignment(), please use your own logic for this value as it is implementation-defined
11201120
),
11211121

1122-
.float => comp.target.c_type_alignment(.float),
1123-
.double => comp.target.c_type_alignment(.double),
1124-
.long_double => comp.target.c_type_alignment(.longdouble),
1122+
.float => comp.target.cTypeAlignment(.float),
1123+
.double => comp.target.cTypeAlignment(.double),
1124+
.long_double => comp.target.cTypeAlignment(.longdouble),
11251125

11261126
.int128, .uint128 => if (comp.target.cpu.arch == .s390x and comp.target.os.tag == .linux and comp.target.isGnu()) 8 else 16,
11271127
.fp16, .float16 => 2,

lib/compiler/aro/aro/target.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ pub const FPSemantics = enum {
306306
/// Only intended for generating float.h macros for the preprocessor
307307
pub fn forType(ty: std.Target.CType, target: std.Target) FPSemantics {
308308
std.debug.assert(ty == .float or ty == .double or ty == .longdouble);
309-
return switch (target.c_type_bit_size(ty)) {
309+
return switch (target.cTypeBitSize(ty)) {
310310
32 => .IEEESingle,
311311
64 => .IEEEDouble,
312312
80 => .x87ExtendedDouble,
@@ -350,7 +350,7 @@ pub const FPSemantics = enum {
350350
};
351351

352352
pub fn isLP64(target: std.Target) bool {
353-
return target.c_type_bit_size(.int) == 32 and target.ptrBitWidth() == 64;
353+
return target.cTypeBitSize(.int) == 32 and target.ptrBitWidth() == 64;
354354
}
355355

356356
pub fn isKnownWindowsMSVCEnvironment(target: std.Target) bool {

lib/std/Target.zig

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,7 +2009,7 @@ pub const CType = enum {
20092009
longdouble,
20102010
};
20112011

2012-
pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
2012+
pub fn cTypeByteSize(t: Target, c_type: CType) u16 {
20132013
return switch (c_type) {
20142014
.char,
20152015
.short,
@@ -2022,20 +2022,20 @@ pub fn c_type_byte_size(t: Target, c_type: CType) u16 {
20222022
.ulonglong,
20232023
.float,
20242024
.double,
2025-
=> @divExact(c_type_bit_size(t, c_type), 8),
2025+
=> @divExact(cTypeBitSize(t, c_type), 8),
20262026

2027-
.longdouble => switch (c_type_bit_size(t, c_type)) {
2027+
.longdouble => switch (cTypeBitSize(t, c_type)) {
20282028
16 => 2,
20292029
32 => 4,
20302030
64 => 8,
2031-
80 => @intCast(std.mem.alignForward(usize, 10, c_type_alignment(t, .longdouble))),
2031+
80 => @intCast(std.mem.alignForward(usize, 10, cTypeAlignment(t, .longdouble))),
20322032
128 => 16,
20332033
else => unreachable,
20342034
},
20352035
};
20362036
}
20372037

2038-
pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
2038+
pub fn cTypeBitSize(target: Target, c_type: CType) u16 {
20392039
switch (target.os.tag) {
20402040
.freestanding, .other => switch (target.cpu.arch) {
20412041
.msp430 => switch (c_type) {
@@ -2331,7 +2331,7 @@ pub fn c_type_bit_size(target: Target, c_type: CType) u16 {
23312331
}
23322332
}
23332333

2334-
pub fn c_type_alignment(target: Target, c_type: CType) u16 {
2334+
pub fn cTypeAlignment(target: Target, c_type: CType) u16 {
23352335
// Overrides for unusual alignments
23362336
switch (target.cpu.arch) {
23372337
.avr => return 1,
@@ -2351,7 +2351,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
23512351

23522352
// Next-power-of-two-aligned, up to a maximum.
23532353
return @min(
2354-
std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8),
2354+
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
23552355
@as(u16, switch (target.cpu.arch) {
23562356
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
23572357
.netbsd => switch (target.abi) {
@@ -2423,7 +2423,7 @@ pub fn c_type_alignment(target: Target, c_type: CType) u16 {
24232423
);
24242424
}
24252425

2426-
pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
2426+
pub fn cTypePreferredAlignment(target: Target, c_type: CType) u16 {
24272427
// Overrides for unusual alignments
24282428
switch (target.cpu.arch) {
24292429
.arm, .armeb, .thumb, .thumbeb => switch (target.os.tag) {
@@ -2476,7 +2476,7 @@ pub fn c_type_preferred_alignment(target: Target, c_type: CType) u16 {
24762476

24772477
// Next-power-of-two-aligned, up to a maximum.
24782478
return @min(
2479-
std.math.ceilPowerOfTwoAssert(u16, (c_type_bit_size(target, c_type) + 7) / 8),
2479+
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
24802480
@as(u16, switch (target.cpu.arch) {
24812481
.msp430 => 2,
24822482

src/Sema.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30943,7 +30943,7 @@ fn coerceVarArgParam(
3094330943
.Array => return sema.fail(block, inst_src, "arrays must be passed by reference to variadic function", .{}),
3094430944
.Float => float: {
3094530945
const target = zcu.getTarget();
30946-
const double_bits = target.c_type_bit_size(.double);
30946+
const double_bits = target.cTypeBitSize(.double);
3094730947
const inst_bits = uncasted_ty.floatBits(target);
3094830948
if (inst_bits >= double_bits) break :float inst;
3094930949
switch (double_bits) {
@@ -30956,21 +30956,21 @@ fn coerceVarArgParam(
3095630956
if (!try sema.validateExternType(uncasted_ty, .param_ty)) break :int inst;
3095730957
const target = zcu.getTarget();
3095830958
const uncasted_info = uncasted_ty.intInfo(zcu);
30959-
if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) {
30959+
if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
3096030960
.signed => .int,
3096130961
.unsigned => .uint,
3096230962
})) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
3096330963
.signed => Type.c_int,
3096430964
.unsigned => Type.c_uint,
3096530965
}, inst, inst_src);
30966-
if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) {
30966+
if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
3096730967
.signed => .long,
3096830968
.unsigned => .ulong,
3096930969
})) break :int try sema.coerce(block, switch (uncasted_info.signedness) {
3097030970
.signed => Type.c_long,
3097130971
.unsigned => Type.c_ulong,
3097230972
}, inst, inst_src);
30973-
if (uncasted_info.bits <= target.c_type_bit_size(switch (uncasted_info.signedness) {
30973+
if (uncasted_info.bits <= target.cTypeBitSize(switch (uncasted_info.signedness) {
3097430974
.signed => .longlong,
3097530975
.unsigned => .ulonglong,
3097630976
})) break :int try sema.coerce(block, switch (uncasted_info.signedness) {

src/Type.zig

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1005,15 +1005,15 @@ pub fn abiAlignmentAdvanced(
10051005

10061006
.f16 => return .{ .scalar = .@"2" },
10071007
.f32 => return .{ .scalar = cTypeAlign(target, .float) },
1008-
.f64 => switch (target.c_type_bit_size(.double)) {
1008+
.f64 => switch (target.cTypeBitSize(.double)) {
10091009
64 => return .{ .scalar = cTypeAlign(target, .double) },
10101010
else => return .{ .scalar = .@"8" },
10111011
},
1012-
.f80 => switch (target.c_type_bit_size(.longdouble)) {
1012+
.f80 => switch (target.cTypeBitSize(.longdouble)) {
10131013
80 => return .{ .scalar = cTypeAlign(target, .longdouble) },
10141014
else => return .{ .scalar = Type.u80.abiAlignment(pt) },
10151015
},
1016-
.f128 => switch (target.c_type_bit_size(.longdouble)) {
1016+
.f128 => switch (target.cTypeBitSize(.longdouble)) {
10171017
128 => return .{ .scalar = cTypeAlign(target, .longdouble) },
10181018
else => return .{ .scalar = .@"16" },
10191019
},
@@ -1366,25 +1366,25 @@ pub fn abiSizeAdvanced(
13661366
.f32 => return .{ .scalar = 4 },
13671367
.f64 => return .{ .scalar = 8 },
13681368
.f128 => return .{ .scalar = 16 },
1369-
.f80 => switch (target.c_type_bit_size(.longdouble)) {
1370-
80 => return .{ .scalar = target.c_type_byte_size(.longdouble) },
1369+
.f80 => switch (target.cTypeBitSize(.longdouble)) {
1370+
80 => return .{ .scalar = target.cTypeByteSize(.longdouble) },
13711371
else => return .{ .scalar = Type.u80.abiSize(pt) },
13721372
},
13731373

13741374
.usize,
13751375
.isize,
13761376
=> return .{ .scalar = @divExact(target.ptrBitWidth(), 8) },
13771377

1378-
.c_char => return .{ .scalar = target.c_type_byte_size(.char) },
1379-
.c_short => return .{ .scalar = target.c_type_byte_size(.short) },
1380-
.c_ushort => return .{ .scalar = target.c_type_byte_size(.ushort) },
1381-
.c_int => return .{ .scalar = target.c_type_byte_size(.int) },
1382-
.c_uint => return .{ .scalar = target.c_type_byte_size(.uint) },
1383-
.c_long => return .{ .scalar = target.c_type_byte_size(.long) },
1384-
.c_ulong => return .{ .scalar = target.c_type_byte_size(.ulong) },
1385-
.c_longlong => return .{ .scalar = target.c_type_byte_size(.longlong) },
1386-
.c_ulonglong => return .{ .scalar = target.c_type_byte_size(.ulonglong) },
1387-
.c_longdouble => return .{ .scalar = target.c_type_byte_size(.longdouble) },
1378+
.c_char => return .{ .scalar = target.cTypeByteSize(.char) },
1379+
.c_short => return .{ .scalar = target.cTypeByteSize(.short) },
1380+
.c_ushort => return .{ .scalar = target.cTypeByteSize(.ushort) },
1381+
.c_int => return .{ .scalar = target.cTypeByteSize(.int) },
1382+
.c_uint => return .{ .scalar = target.cTypeByteSize(.uint) },
1383+
.c_long => return .{ .scalar = target.cTypeByteSize(.long) },
1384+
.c_ulong => return .{ .scalar = target.cTypeByteSize(.ulong) },
1385+
.c_longlong => return .{ .scalar = target.cTypeByteSize(.longlong) },
1386+
.c_ulonglong => return .{ .scalar = target.cTypeByteSize(.ulonglong) },
1387+
.c_longdouble => return .{ .scalar = target.cTypeByteSize(.longdouble) },
13881388

13891389
.anyopaque,
13901390
.void,
@@ -1724,16 +1724,16 @@ pub fn bitSizeAdvanced(
17241724
.isize,
17251725
=> return target.ptrBitWidth(),
17261726

1727-
.c_char => return target.c_type_bit_size(.char),
1728-
.c_short => return target.c_type_bit_size(.short),
1729-
.c_ushort => return target.c_type_bit_size(.ushort),
1730-
.c_int => return target.c_type_bit_size(.int),
1731-
.c_uint => return target.c_type_bit_size(.uint),
1732-
.c_long => return target.c_type_bit_size(.long),
1733-
.c_ulong => return target.c_type_bit_size(.ulong),
1734-
.c_longlong => return target.c_type_bit_size(.longlong),
1735-
.c_ulonglong => return target.c_type_bit_size(.ulonglong),
1736-
.c_longdouble => return target.c_type_bit_size(.longdouble),
1727+
.c_char => return target.cTypeBitSize(.char),
1728+
.c_short => return target.cTypeBitSize(.short),
1729+
.c_ushort => return target.cTypeBitSize(.ushort),
1730+
.c_int => return target.cTypeBitSize(.int),
1731+
.c_uint => return target.cTypeBitSize(.uint),
1732+
.c_long => return target.cTypeBitSize(.long),
1733+
.c_ulong => return target.cTypeBitSize(.ulong),
1734+
.c_longlong => return target.cTypeBitSize(.longlong),
1735+
.c_ulonglong => return target.cTypeBitSize(.ulonglong),
1736+
.c_longdouble => return target.cTypeBitSize(.longdouble),
17371737

17381738
.bool => return 1,
17391739
.void => return 0,
@@ -2310,15 +2310,15 @@ pub fn intInfo(starting_ty: Type, mod: *Module) InternPool.Key.IntType {
23102310
},
23112311
.usize_type => return .{ .signedness = .unsigned, .bits = target.ptrBitWidth() },
23122312
.isize_type => return .{ .signedness = .signed, .bits = target.ptrBitWidth() },
2313-
.c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.c_type_bit_size(.char) },
2314-
.c_short_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.short) },
2315-
.c_ushort_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ushort) },
2316-
.c_int_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.int) },
2317-
.c_uint_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.uint) },
2318-
.c_long_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.long) },
2319-
.c_ulong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulong) },
2320-
.c_longlong_type => return .{ .signedness = .signed, .bits = target.c_type_bit_size(.longlong) },
2321-
.c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.c_type_bit_size(.ulonglong) },
2313+
.c_char_type => return .{ .signedness = mod.getTarget().charSignedness(), .bits = target.cTypeBitSize(.char) },
2314+
.c_short_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.short) },
2315+
.c_ushort_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ushort) },
2316+
.c_int_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.int) },
2317+
.c_uint_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.uint) },
2318+
.c_long_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.long) },
2319+
.c_ulong_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ulong) },
2320+
.c_longlong_type => return .{ .signedness = .signed, .bits = target.cTypeBitSize(.longlong) },
2321+
.c_ulonglong_type => return .{ .signedness = .unsigned, .bits = target.cTypeBitSize(.ulonglong) },
23222322
else => switch (ip.indexToKey(ty.toIntern())) {
23232323
.int_type => |int_type| return int_type,
23242324
.struct_type => ty = Type.fromInterned(ip.loadStructType(ty.toIntern()).backingIntTypeUnordered(ip)),
@@ -2427,7 +2427,7 @@ pub fn floatBits(ty: Type, target: Target) u16 {
24272427
.f64_type => 64,
24282428
.f80_type => 80,
24292429
.f128_type, .comptime_float_type => 128,
2430-
.c_longdouble_type => target.c_type_bit_size(.longdouble),
2430+
.c_longdouble_type => target.cTypeBitSize(.longdouble),
24312431

24322432
else => unreachable,
24332433
};
@@ -4025,5 +4025,5 @@ pub fn smallestUnsignedBits(max: u64) u16 {
40254025
pub const packed_struct_layout_version = 2;
40264026

40274027
fn cTypeAlign(target: Target, c_type: Target.CType) Alignment {
4028-
return Alignment.fromByteUnits(target.c_type_alignment(c_type));
4028+
return Alignment.fromByteUnits(target.cTypeAlignment(c_type));
40294029
}

src/arch/riscv64/CodeGen.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8304,7 +8304,7 @@ fn promoteVarArg(func: *Func, ty: Type) Type {
83048304
switch (ty.floatBits(func.target.*)) {
83058305
32, 64 => return Type.f64,
83068306
else => |float_bits| {
8307-
assert(float_bits == func.target.c_type_bit_size(.longdouble));
8307+
assert(float_bits == func.target.cTypeBitSize(.longdouble));
83088308
return Type.c_longdouble;
83098309
},
83108310
}

src/arch/x86_64/CodeGen.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19374,7 +19374,7 @@ fn promoteVarArg(self: *Self, ty: Type) Type {
1937419374
switch (ty.floatBits(self.target.*)) {
1937519375
32, 64 => return Type.f64,
1937619376
else => |float_bits| {
19377-
assert(float_bits == self.target.c_type_bit_size(.longdouble));
19377+
assert(float_bits == self.target.cTypeBitSize(.longdouble));
1937819378
return Type.c_longdouble;
1937919379
},
1938019380
}

0 commit comments

Comments
 (0)