diff --git a/include/CL/cl.h b/include/CL/cl.h index 792e20cc8a1..d557720194f 100644 --- a/include/CL/cl.h +++ b/include/CL/cl.h @@ -24,6 +24,12 @@ extern "C" { #endif +#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ + /* Disable warning C4201: nonstandard extension used : nameless struct/union */ + #pragma warning( push ) + #pragma warning( disable : 4201 ) +#endif + /******************************************************************************/ typedef struct _cl_platform_id * cl_platform_id; @@ -133,39 +139,14 @@ typedef struct _cl_image_desc { size_t image_slice_pitch; cl_uint num_mip_levels; cl_uint num_samples; -#ifdef CL_VERSION_2_0 -#if defined(__GNUC__) - __extension__ /* Prevents warnings about anonymous union in -pedantic builds */ -#endif -#if defined(_MSC_VER) && !defined(__STDC__) -#pragma warning( push ) -#pragma warning( disable : 4201 ) /* Prevents warning about nameless struct/union in /W4 builds */ -#endif -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc11-extensions" /* Prevents warning about nameless union being C11 extension*/ -#endif -#if defined(_MSC_VER) && defined(__STDC__) - /* Anonymous unions are not supported in /Za builds */ -#else - union { -#endif +#if defined(CL_VERSION_2_0) && __CL_HAS_ANON_STRUCT__ + __CL_ANON_STRUCT__ union { #endif cl_mem buffer; -#ifdef CL_VERSION_2_0 -#if defined(_MSC_VER) && defined(__STDC__) - /* Anonymous unions are not supported in /Za builds */ -#else +#if defined(CL_VERSION_2_0) && __CL_HAS_ANON_STRUCT__ cl_mem mem_object; }; #endif -#if defined(_MSC_VER) && !defined(__STDC__) -#pragma warning( pop ) -#endif -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -#endif } cl_image_desc; #endif @@ -1932,4 +1913,8 @@ clEnqueueTask(cl_command_queue command_queue, } #endif +#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ + #pragma warning( pop ) +#endif + #endif /* __OPENCL_CL_H */ diff --git a/include/CL/cl_icd.h b/include/CL/cl_icd.h index 435ad4832c6..bce60ea25b4 100644 --- a/include/CL/cl_icd.h +++ b/include/CL/cl_icd.h @@ -22,6 +22,7 @@ #include #include #include +#include #if defined(_WIN32) #include @@ -29,6 +30,12 @@ #include #endif +#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ + /* Disable warning C4201: nonstandard extension used : nameless struct/union */ + #pragma warning( push ) + #pragma warning( disable : 4201 ) +#endif + #ifdef __cplusplus extern "C" { #endif @@ -37,7 +44,15 @@ extern "C" { typedef struct _cl_icd_dispatch { /* OpenCL 1.0 */ - clGetPlatformIDs_t *clGetPlatformIDs; +#if __CL_HAS_ANON_STRUCT__ + __CL_ANON_STRUCT__ union { +#endif + clGetPlatformIDs_t *clGetPlatformIDs; +#if __CL_HAS_ANON_STRUCT__ + /* Set to CL_ICD2_TAG_KHR for cl_khr_icd 2.0.0 */ + intptr_t clGetPlatformIDs_icd2_tag; + }; +#endif clGetPlatformInfo_t *clGetPlatformInfo; clGetDeviceIDs_t *clGetDeviceIDs; clGetDeviceInfo_t *clGetDeviceInfo; @@ -68,7 +83,15 @@ typedef struct _cl_icd_dispatch { clRetainProgram_t *clRetainProgram; clReleaseProgram_t *clReleaseProgram; clBuildProgram_t *clBuildProgram; - clUnloadCompiler_t *clUnloadCompiler; +#if __CL_HAS_ANON_STRUCT__ + __CL_ANON_STRUCT__ union { +#endif + clUnloadCompiler_t *clUnloadCompiler; +#if __CL_HAS_ANON_STRUCT__ + /* Set to CL_ICD2_TAG_KHR for cl_khr_icd 2.0.0 */ + intptr_t clUnloadCompiler_icd2_tag; + }; +#endif clGetProgramInfo_t *clGetProgramInfo; clGetProgramBuildInfo_t *clGetProgramBuildInfo; clCreateKernel_t *clCreateKernel; @@ -312,4 +335,8 @@ typedef struct _cl_icd_dispatch { } #endif +#if defined(_WIN32) && defined(_MSC_VER) && __CL_HAS_ANON_STRUCT__ + #pragma warning( pop ) +#endif + #endif /* #ifndef OPENCL_CL_ICD_H */ diff --git a/src/gallium/frontends/rusticl/api/icd.rs b/src/gallium/frontends/rusticl/api/icd.rs index 10623bd4208..1cd8586d712 100644 --- a/src/gallium/frontends/rusticl/api/icd.rs +++ b/src/gallium/frontends/rusticl/api/icd.rs @@ -22,7 +22,9 @@ use std::ptr; use std::sync::Arc; pub static DISPATCH: cl_icd_dispatch = cl_icd_dispatch { - clGetPlatformIDs: Some(clGetPlatformIDs), + anon_1: _cl_icd_dispatch__bindgen_ty_1 { + clGetPlatformIDs: Some(clGetPlatformIDs), + }, clGetPlatformInfo: Some(clGetPlatformInfo), clGetDeviceIDs: Some(clGetDeviceIDs), clGetDeviceInfo: Some(clGetDeviceInfo), @@ -53,7 +55,9 @@ pub static DISPATCH: cl_icd_dispatch = cl_icd_dispatch { clRetainProgram: Some(clRetainProgram), clReleaseProgram: Some(clReleaseProgram), clBuildProgram: Some(clBuildProgram), - clUnloadCompiler: None, + anon_2: _cl_icd_dispatch__bindgen_ty_2 { + clUnloadCompiler: None, + }, clGetProgramInfo: Some(clGetProgramInfo), clGetProgramBuildInfo: Some(clGetProgramBuildInfo), clCreateKernel: Some(clCreateKernel),