authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-17 02:52:53+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-17 05:23:00+02:00
log13727041dd4c4e02e671e77053bea8d2859a759e
tree994fcf3e30b0916fd689445622e938e504f6d2fe
parent409adfb434a42a104ab2ac0782edbae9b035e112
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.Target: align cTypeBitSize() for GPU targets with C rather than OpenCL C


1 files changed, 3 insertions(+), 26 deletions(-)

lib/std/Target.zig+3-26
...@@ -3473,37 +3473,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 {...@@ -3473,37 +3473,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 {
3473 },3473 },
3474 },3474 },
34753475
3476 .nvcl, .cuda => switch (c_type) {3476 .cuda, .amdhsa, .amdpal, .mesa3d, .nvcl, .opencl, .vulkan => switch (c_type) {
3477 .char => 8,3477 .char => 8,
3478 .short, .ushort => 16,3478 .short, .ushort => 16,
3479 .int, .uint, .float => 32,3479 .int, .uint, .float => 32,
3480 .long, .ulong => switch (target.cpu.arch) {3480 .long, .ulong => target.ptrBitWidth(),
3481 .nvptx => 32,3481 .longlong, .ulonglong, .double, .longdouble => 64,
3482 .nvptx64 => 64,
3483 else => 64,
3484 },
3485 .longlong, .ulonglong, .double => 64,
3486 .longdouble => 64,
3487 },
3488
3489 .amdhsa, .amdpal, .mesa3d => switch (c_type) {
3490 .char => 8,
3491 .short, .ushort => 16,
3492 .int, .uint, .float => 32,
3493 .long, .ulong, .longlong, .ulonglong, .double => 64,
3494 .longdouble => 128,
3495 },3482 },
34963483
3497 .opencl, .vulkan => switch (c_type) {
3498 .char => 8,
3499 .short, .ushort => 16,
3500 .int, .uint, .float => 32,
3501 .long, .ulong, .double => 64,
3502 .longlong, .ulonglong => 128,
3503 // Note: The OpenCL specification does not guarantee a particular size for long double,
3504 // but clang uses 128 bits.
3505 .longdouble => 128,
3506 },
35073484
3508 .@"3ds" => switch (c_type) {3485 .@"3ds" => switch (c_type) {
3509 .char => 8,3486 .char => 8,