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-19 06:47:50+02:00
log7b38151ec2440e895d6adee670619337ae89b8a3
treecb38e549bd1fae9702418b4478a5eb7aa38bfd48
parent5c1bbdc433cec03cd8ae79601f52cb332015aaf9
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
......@@ -3311,88 +3311,64 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 {
33113311
33123312 .wasi,
33133313 .emscripten,
3314 => switch (target.cpu.arch) {
3315 .mips64,
3316 .mips64el,
3317 => switch (c_type) {
3318 .char => 8,
3319 .short, .ushort => 16,
3320 .int, .uint, .float => 32,
3321 .long, .ulong => switch (target.abi) {
3322 .gnuabin32, .muslabin32, .abin32 => 32,
3323 else => 64,
3324 },
3325 .longlong, .ulonglong, .double => 64,
3326 .longdouble => 128,
3327 },
3328 .x86_64 => switch (c_type) {
3329 .char => 8,
3330 .short, .ushort => 16,
3331 .int, .uint, .float => 32,
3332 .long, .ulong => switch (target.abi) {
3333 .gnux32, .muslx32, .x32 => 32,
3334 else => 64,
3314 => switch (c_type) {
3315 .char => 8,
3316 .short, .ushort => 16,
3317 .int, .uint, .float => 32,
3318 .long, .ulong => target.ptrBitWidth(),
3319 .longlong, .ulonglong, .double => 64,
3320 .longdouble => switch (target.cpu.arch) {
3321 .x86,
3322 .x86_64,
3323 => switch (target.abi) {
3324 .android => 64,
3325 else => 80,
33353326 },
3336 .longlong, .ulonglong, .double => 64,
3337 .longdouble => 80,
3338 },
3339 else => switch (c_type) {
3340 .char => 8,
3341 .short, .ushort => 16,
3342 .int, .uint, .float => 32,
3343 .long, .ulong => target.ptrBitWidth(),
3344 .longlong, .ulonglong, .double => 64,
3345 .longdouble => switch (target.cpu.arch) {
3346 .x86 => switch (target.abi) {
3347 .android => 64,
3348 else => 80,
3349 },
33503327
3351 .powerpc,
3352 .powerpcle,
3353 => switch (target.abi) {
3354 .musleabi, .musleabihf => 64,
3355 else => switch (target.os.tag) {
3356 .netbsd,
3357 .openbsd,
3358 => 64,
3359 else => 128,
3360 },
3328 .powerpc,
3329 .powerpcle,
3330 => switch (target.abi) {
3331 .musleabi, .musleabihf => 64,
3332 else => switch (target.os.tag) {
3333 .netbsd,
3334 .openbsd,
3335 => 64,
3336 else => 128,
33613337 },
3338 },
33623339
3363 .powerpc64,
3364 .powerpc64le,
3365 => switch (target.abi) {
3366 .musl => 64,
3367 else => switch (target.os.tag) {
3368 .freebsd,
3369 .openbsd,
3370 => 64,
3371 else => 128,
3372 },
3340 .powerpc64,
3341 .powerpc64le,
3342 => switch (target.abi) {
3343 .musl => 64,
3344 else => switch (target.os.tag) {
3345 .freebsd,
3346 .openbsd,
3347 => 64,
3348 else => 128,
33733349 },
3350 },
33743351
3375 .alpha,
3376 .riscv32,
3377 .riscv32be,
3378 .riscv64,
3379 .riscv64be,
3380 .aarch64,
3381 .aarch64_be,
3382 .s390x,
3383 .mips64,
3384 .mips64el,
3385 .sparc,
3386 .sparc64,
3387 .wasm32,
3388 .wasm64,
3389 .loongarch32,
3390 .loongarch64,
3391 .ve,
3392 => 128,
3352 .alpha,
3353 .riscv32,
3354 .riscv32be,
3355 .riscv64,
3356 .riscv64be,
3357 .aarch64,
3358 .aarch64_be,
3359 .s390x,
3360 .mips64,
3361 .mips64el,
3362 .sparc,
3363 .sparc64,
3364 .wasm32,
3365 .wasm64,
3366 .loongarch32,
3367 .loongarch64,
3368 .ve,
3369 => 128,
33933370
3394 else => 64,
3395 },
3371 else => 64,
33963372 },
33973373 },
33983374