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 04:29:44+02:00
logb75d35631ca813ac0ce1653ec281a85abd419ba0
tree6afaebf997074b3f564a6f8201e1fe9b74eaf44e
parent79413e38e8864af547ce4e6cc9ba9e7005f9d872
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
......@@ -3460,37 +3460,14 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) ?u16 {
34603460 },
34613461 },
34623462
3463 .nvcl, .cuda => switch (c_type) {
3463 .cuda, .amdhsa, .amdpal, .mesa3d, .nvcl, .opencl, .vulkan => switch (c_type) {
34643464 .char => 8,
34653465 .short, .ushort => 16,
34663466 .int, .uint, .float => 32,
3467 .long, .ulong => switch (target.cpu.arch) {
3468 .nvptx => 32,
3469 .nvptx64 => 64,
3470 else => 64,
3471 },
3472 .longlong, .ulonglong, .double => 64,
3473 .longdouble => 64,
3474 },
3475
3476 .amdhsa, .amdpal, .mesa3d => switch (c_type) {
3477 .char => 8,
3478 .short, .ushort => 16,
3479 .int, .uint, .float => 32,
3480 .long, .ulong, .longlong, .ulonglong, .double => 64,
3481 .longdouble => 128,
3467 .long, .ulong => target.ptrBitWidth(),
3468 .longlong, .ulonglong, .double, .longdouble => 64,
34823469 },
34833470
3484 .opencl, .vulkan => switch (c_type) {
3485 .char => 8,
3486 .short, .ushort => 16,
3487 .int, .uint, .float => 32,
3488 .long, .ulong, .double => 64,
3489 .longlong, .ulonglong => 128,
3490 // Note: The OpenCL specification does not guarantee a particular size for long double,
3491 // but clang uses 128 bits.
3492 .longdouble => 128,
3493 },
34943471
34953472 .@"3ds" => switch (c_type) {
34963473 .char => 8,