Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions loader/icd_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,17 @@

// cl_gl.h and required files
#ifdef _WIN32
// System headers aren't ISO compliant
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( push )
#pragma warning( disable : 4201 )
#endif
#include <windows.h>
#include <d3d9.h>
#include <d3d10_1.h>
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( pop )
#endif
#include <CL/cl_d3d10.h>
#include <CL/cl_d3d11.h>
#include <CL/cl_dx9_media_sharing.h>
Expand Down
2 changes: 1 addition & 1 deletion loader/windows/OpenCL.rc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ BEGIN
BEGIN
VALUE "FileDescription" ,"OpenCL Client DLL"
VALUE "ProductName" ,"Khronos OpenCL ICD Loader"
VALUE "LegalCopyright" ,"Copyright \251 The Khronos Group Inc 2016-2020"
VALUE "LegalCopyright" ,L"Copyright \251 The Khronos Group Inc 2016-2020"
VALUE "FileVersion" ,OPENCL_ICD_LOADER_VERSION_STRING ".0"
VALUE "CompanyName" ,"Khronos Group"
VALUE "InternalName" ,"OpenCL"
Expand Down
15 changes: 15 additions & 0 deletions loader/windows/adapter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@
* Author: Lenny Komow <[email protected]>
*/

// System types aren't ISO compliant
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( push )
#pragma warning( disable : 4201 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wc11-extensions"
#endif

typedef struct LoaderEnumAdapters2 {
ULONG adapter_count;
struct {
Expand Down Expand Up @@ -78,3 +87,9 @@ typedef struct LoaderQueryRegistryInfo {
BYTE output_binary[1];
};
} LoaderQueryRegistryInfo;

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
17 changes: 16 additions & 1 deletion loader/windows/icd_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ void adapterFree(WinAdapter *pWinAdapter)
// for each vendor encountered
BOOL CALLBACK khrIcdOsVendorsEnumerate(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *lpContext)
{
(void)InitOnce;
(void)Parameter;
(void)lpContext;
LONG result;
BOOL status = FALSE;
const char* platformsName = "SOFTWARE\\Khronos\\OpenCL\\Vendors";
Expand Down Expand Up @@ -267,7 +270,7 @@ void *khrIcdOsLibraryLoad(const char *libraryName)
}
if (!hTemp)
{
KHR_ICD_TRACE("Failed to load driver. Windows error code is %d.\n", GetLastError());
KHR_ICD_TRACE("Failed to load driver. Windows error code is %lu.\n", GetLastError());
Copy link
Contributor

@Kerilk Kerilk May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use %"PRIuDW" here instead of %lu.

Suggested change
KHR_ICD_TRACE("Failed to load driver. Windows error code is %lu.\n", GetLastError());
KHR_ICD_TRACE("Failed to load driver. Windows error code is %"PRIuDW".\n", GetLastError());

}
return (void*)hTemp;
}
Expand All @@ -279,7 +282,19 @@ void *khrIcdOsLibraryGetFunctionAddress(void *library, const char *functionName)
{
return NULL;
}
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( push )
#pragma warning( disable : 4152 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#endif
return GetProcAddress( (HMODULE)library, functionName);
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
Comment on lines +285 to +297
Copy link
Contributor

@Kerilk Kerilk May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would try using:

Suggested change
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( push )
#pragma warning( disable : 4152 )
#elif defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wpedantic"
#endif
return GetProcAddress( (HMODULE)library, functionName);
#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning( pop )
#elif defined(__clang__)
#pragma clang diagnostic pop
#endif
return (void *)(intptr_t)GetProcAddress( (HMODULE)library, functionName);

here. It would be consistent with what we do at other place in the code. You may require an additional include.

}

// unload a library.
Expand Down
26 changes: 13 additions & 13 deletions test/driver_stub/cl.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ clGetPlatformIDs(cl_uint num_entries ,
}

CL_API_ENTRY cl_int CL_API_CALL
clGetPlatformInfo(cl_platform_id platform,
clGetPlatformInfo(cl_platform_id _platform,
cl_platform_info param_name,
size_t param_value_size,
void * param_value,
Expand All @@ -117,22 +117,22 @@ clGetPlatformInfo(cl_platform_id platform,
// select the string to return
switch(param_name) {
case CL_PLATFORM_PROFILE:
returnString = platform->profile;
returnString = _platform->profile;
break;
case CL_PLATFORM_VERSION:
returnString = platform->version;
returnString = _platform->version;
break;
case CL_PLATFORM_NAME:
returnString = platform->name;
returnString = _platform->name;
break;
case CL_PLATFORM_VENDOR:
returnString = platform->vendor;
returnString = _platform->vendor;
break;
case CL_PLATFORM_EXTENSIONS:
returnString = platform->extensions;
returnString = _platform->extensions;
break;
case CL_PLATFORM_ICD_SUFFIX_KHR:
returnString = platform->suffix;
returnString = _platform->suffix;
break;
default:
ret = CL_INVALID_VALUE;
Expand Down Expand Up @@ -163,7 +163,7 @@ clGetPlatformInfo(cl_platform_id platform,

/* Device APIs */
CL_API_ENTRY cl_int CL_API_CALL
clGetDeviceIDs(cl_platform_id platform,
clGetDeviceIDs(cl_platform_id _platform,
cl_device_type device_type,
cl_uint num_entries,
cl_device_id * devices,
Expand All @@ -187,7 +187,7 @@ clGetDeviceIDs(cl_platform_id platform,

done:
test_icd_stub_log("clGetDeviceIDs(%p, %x, %u, %p, %p)\n",
platform,
_platform,
device_type,
num_entries,
devices,
Expand Down Expand Up @@ -950,10 +950,10 @@ clLinkProgram(cl_context context ,


CL_API_ENTRY cl_int CL_API_CALL
clUnloadPlatformCompiler(cl_platform_id platform) CL_API_SUFFIX__VERSION_1_2
clUnloadPlatformCompiler(cl_platform_id _platform) CL_API_SUFFIX__VERSION_1_2
{
cl_int return_value = CL_OUT_OF_RESOURCES;
test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", platform);
test_icd_stub_log("clUnloadPlatformCompiler(%p)\n", _platform);
test_icd_stub_log("Value returned: %d\n", return_value);
return return_value;
}
Expand Down Expand Up @@ -1836,12 +1836,12 @@ clEnqueueNativeKernel(cl_command_queue command_queue ,
}

CL_API_ENTRY void * CL_API_CALL
clGetExtensionFunctionAddressForPlatform(cl_platform_id platform ,
clGetExtensionFunctionAddressForPlatform(cl_platform_id _platform ,
const char * func_name) CL_API_SUFFIX__VERSION_1_2
{
void *return_value = (void *) malloc(sizeof(void *));
test_icd_stub_log("clGetExtensionFunctionAddressForPlatform(%p, %p)\n",
platform,
_platform,
func_name);

test_icd_stub_log("Value returned: %p\n", return_value);
Expand Down
14 changes: 7 additions & 7 deletions test/driver_stub/cl_gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
// themselves via the dispatch table. Include this before cl headers.
#include "rename_api.h"

#define SIZE_T_MAX (size_t) 0xFFFFFFFFFFFFFFFFULL
#include <limits.h> // SIZE_MAX

CL_API_ENTRY cl_mem CL_API_CALL
clCreateFromGLBuffer(cl_context context ,
cl_mem_flags flags ,
cl_GLuint bufret_mem ,
int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0
{
cl_mem ret_mem = (cl_mem)(SIZE_T_MAX);
cl_mem ret_mem = (cl_mem)(SIZE_MAX);
test_icd_stub_log("clCreateFromGLBuffer(%p, %x, %u, %p)\n",
context,
flags,
Expand All @@ -32,7 +32,7 @@ clCreateFromGLTexture(cl_context context ,
cl_GLuint texture ,
cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_2
{
cl_mem ret_mem = (cl_mem)(SIZE_T_MAX);
cl_mem ret_mem = (cl_mem)(SIZE_MAX);
test_icd_stub_log("clCreateFromGLTexture(%p, %x, %d, %d, %u, %p)\n",
context ,
flags ,
Expand All @@ -53,7 +53,7 @@ clCreateFromGLTexture2D(cl_context context,
cl_GLuint texture,
cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0
{
cl_mem ret_mem = (cl_mem)(SIZE_T_MAX);
cl_mem ret_mem = (cl_mem)(SIZE_MAX);
test_icd_stub_log("clCreateFromGLTexture2D(%p, %x, %d, %d, %u, %p)\n",
context,
flags,
Expand All @@ -75,7 +75,7 @@ clCreateFromGLTexture3D(cl_context context,
cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0

{
cl_mem ret_mem = (cl_mem)(SIZE_T_MAX);
cl_mem ret_mem = (cl_mem)(SIZE_MAX);
test_icd_stub_log("clCreateFromGLTexture3D(%p, %x, %d, %d, %u, %p)\n",
context,
flags,
Expand All @@ -94,7 +94,7 @@ clCreateFromGLRenderbuffer(cl_context context,
cl_GLuint renderbuffer,
cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_0
{
cl_mem ret_mem = (cl_mem)(SIZE_T_MAX);
cl_mem ret_mem = (cl_mem)(SIZE_MAX);
test_icd_stub_log("clCreateFromGLRenderbuffer(%p, %x, %d, %p)\n",
context,
flags,
Expand Down Expand Up @@ -209,7 +209,7 @@ clCreateEventFromGLsyncKHR(cl_context context ,
cl_int * errcode_ret ) CL_API_SUFFIX__VERSION_1_1

{
cl_event ret_event = (cl_event)(SIZE_T_MAX);
cl_event ret_event = (cl_event)(SIZE_MAX);
test_icd_stub_log("clCreateEventFromGLsyncKHR(%p, %p, %p)\n",
context,
cl_GLsync,
Expand Down
6 changes: 3 additions & 3 deletions test/loader_test/test_program_objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ int test_clCompileProgram(const struct clCompileProgram_st *data)

int test_clLinkProgram(const struct clLinkProgram_st *data)
{
cl_program program;
cl_program _program;
test_icd_app_log("clLinkProgram(%p, %u, %p, %p, %u, %p, %p, %p, %p)\n",
context,
data->num_devices,
Expand All @@ -135,7 +135,7 @@ int test_clLinkProgram(const struct clLinkProgram_st *data)
data->user_data,
data->errcode_ret);

program=clLinkProgram(context,
_program=clLinkProgram(context,
data->num_devices,
data->device_list,
data->options,
Expand All @@ -145,7 +145,7 @@ int test_clLinkProgram(const struct clLinkProgram_st *data)
data->user_data,
data->errcode_ret);

test_icd_app_log("Value returned: %p\n", program);
test_icd_app_log("Value returned: %p\n", _program);

return 0;

Expand Down