authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-19 06:47:08+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-20 10:02:27+02:00
logb0695670e35251a72f55bb51184361a097fe4faa
tree113508a9d50cbddab63da242048a76fb4f6b9b41
parent8a16b59014e81521d77f28fbb8fda2c43223e1d9
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: further simplify cTypeBitSize()

And fix long double size on x86_64-linux-android as a happy accident.

1 files changed, 51 insertions(+), 75 deletions(-)

lib/std/Target.zig+51-75
......@@ -3333,88 +3333,64 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 {
33333333
33343334 .wasi,
33353335 .emscripten,
3336 => switch (target.cpu.arch) {
3337 .mips64,
3338 .mips64el,
3339 => switch (c_type) {
3340 .char => 8,
3341 .short, .ushort => 16,
3342 .int, .uint, .float => 32,
3343 .long, .ulong => switch (target.abi) {
3344 .gnuabin32, .muslabin32, .abin32 => 32,
3345 else => 64,
3346 },
3347 .longlong, .ulonglong, .double => 64,
3348 .longdouble => 128,
3349 },
3350 .x86_64 => switch (c_type) {
3351 .char => 8,
3352 .short, .ushort => 16,
3353 .int, .uint, .float => 32,
3354 .long, .ulong => switch (target.abi) {
3355 .gnux32, .muslx32, .x32 => 32,
3356 else => 64,
3336 => switch (c_type) {
3337 .char => 8,
3338 .short, .ushort => 16,
3339 .int, .uint, .float => 32,
3340 .long, .ulong => target.ptrBitWidth(),
3341 .longlong, .ulonglong, .double => 64,
3342 .longdouble => switch (target.cpu.arch) {
3343 .x86,
3344 .x86_64,
3345 => switch (target.abi) {
3346 .android => 64,
3347 else => 80,
33573348 },
3358 .longlong, .ulonglong, .double => 64,
3359 .longdouble => 80,
3360 },
3361 else => switch (c_type) {
3362 .char => 8,
3363 .short, .ushort => 16,
3364 .int, .uint, .float => 32,
3365 .long, .ulong => target.ptrBitWidth(),
3366 .longlong, .ulonglong, .double => 64,
3367 .longdouble => switch (target.cpu.arch) {
3368 .x86 => switch (target.abi) {
3369 .android => 64,
3370 else => 80,
3371 },
33723349
3373 .powerpc,
3374 .powerpcle,
3375 => switch (target.abi) {
3376 .musleabi, .musleabihf => 64,
3377 else => switch (target.os.tag) {
3378 .netbsd,
3379 .openbsd,
3380 => 64,
3381 else => 128,
3382 },
3350 .powerpc,
3351 .powerpcle,
3352 => switch (target.abi) {
3353 .musleabi, .musleabihf => 64,
3354 else => switch (target.os.tag) {
3355 .netbsd,
3356 .openbsd,
3357 => 64,
3358 else => 128,
33833359 },
3360 },
33843361
3385 .powerpc64,
3386 .powerpc64le,
3387 => switch (target.abi) {
3388 .musl => 64,
3389 else => switch (target.os.tag) {
3390 .freebsd,
3391 .openbsd,
3392 => 64,
3393 else => 128,
3394 },
3362 .powerpc64,
3363 .powerpc64le,
3364 => switch (target.abi) {
3365 .musl => 64,
3366 else => switch (target.os.tag) {
3367 .freebsd,
3368 .openbsd,
3369 => 64,
3370 else => 128,
33953371 },
3372 },
33963373
3397 .alpha,
3398 .riscv32,
3399 .riscv32be,
3400 .riscv64,
3401 .riscv64be,
3402 .aarch64,
3403 .aarch64_be,
3404 .s390x,
3405 .mips64,
3406 .mips64el,
3407 .sparc,
3408 .sparc64,
3409 .wasm32,
3410 .wasm64,
3411 .loongarch32,
3412 .loongarch64,
3413 .ve,
3414 => 128,
3374 .alpha,
3375 .riscv32,
3376 .riscv32be,
3377 .riscv64,
3378 .riscv64be,
3379 .aarch64,
3380 .aarch64_be,
3381 .s390x,
3382 .mips64,
3383 .mips64el,
3384 .sparc,
3385 .sparc64,
3386 .wasm32,
3387 .wasm64,
3388 .loongarch32,
3389 .loongarch64,
3390 .ve,
3391 => 128,
34153392
3416 else => 64,
3417 },
3393 else => 64,
34183394 },
34193395 },
34203396