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