zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 5e62ba1347ee9b8614d5d72c60e87136a3bd7ab9 (tree)
parent aa9ea612168836e2c2867dcd79c768155d1e3bfb
Author: Robin Voetter <robin@voetter.nl>
Date:   Mon, 10 Apr 2023 18:01:25 +0200

opencl: define size of C types

Define the size of the c types according the OpenCL specification.

Note that OpenCL does not define the size of long double. Clang generates
fp128, even though there is no extension that allows such types. The
llvm-spirv translator simply crashes.

Diffstat:
Mlib/std/target.zig | 12+++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/std/target.zig b/lib/std/target.zig @@ -2220,6 +2220,17 @@ pub const Target = struct { .longdouble => return 128, }, + .opencl => switch (c_type) { + .char => return 8, + .short, .ushort => return 16, + .int, .uint, .float => return 32, + .long, .ulong, .double => return 64, + .longlong, .ulonglong => return 128, + // Note: The OpenCL specification does not guarantee a particular size for long double, + // but clang uses 128 bits. + .longdouble => return 128, + }, + .cloudabi, .kfreebsd, .lv2, @@ -2234,7 +2245,6 @@ pub const Target = struct { .contiki, .hermit, .hurd, - .opencl, .glsl450, .vulkan, .driverkit,