* Replace usage of `d_type` of `struct dirent` by `stat()`.
* Remove unsigned comparison warning.
* Remove warning conversion for function pointers.
* Fix missing initializers.
* Remove unused variable warnings.
* Update loader/linux/icd_linux.c
Co-authored-by: Ronan Keryell <ronan@keryell.fr>
Co-authored-by: Ronan Keryell <ronan@keryell.fr>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
+#include <sys/stat.h>
#include <dirent.h>
#include <pthread.h>
// attempt to load all files in the directory
for (dirEntry = readdir(dir); dirEntry; dirEntry = readdir(dir) )
{
- switch(dirEntry->d_type)
+ struct stat statBuff;
+ stat(dirEntry->d_name, &statBuff);
+ if (S_ISREG(statBuff.st_mode) || S_ISLNK(statBuff.st_mode))
{
- case DT_UNKNOWN:
- case DT_REG:
- case DT_LNK:
+ const char* extension = ".icd";
+ FILE *fin = NULL;
+ char* fileName = NULL;
+ char* buffer = NULL;
+ long bufferSize = 0;
+
+ // make sure the file name ends in .icd
+ if (strlen(extension) > strlen(dirEntry->d_name) )
{
- const char* extension = ".icd";
- FILE *fin = NULL;
- char* fileName = NULL;
- char* buffer = NULL;
- long bufferSize = 0;
-
- // make sure the file name ends in .icd
- if (strlen(extension) > strlen(dirEntry->d_name) )
- {
- break;
- }
- if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) )
- {
- break;
- }
-
- // allocate space for the full path of the vendor library name
- fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 2);
- if (!fileName)
- {
- KHR_ICD_TRACE("Failed allocate space for ICD file path\n");
- break;
- }
- sprintf(fileName, "%s/%s", vendorPath, dirEntry->d_name);
-
- // open the file and read its contents
- fin = fopen(fileName, "r");
- if (!fin)
- {
- free(fileName);
- break;
- }
- fseek(fin, 0, SEEK_END);
- bufferSize = ftell(fin);
-
- buffer = malloc(bufferSize+1);
- if (!buffer)
- {
- free(fileName);
- fclose(fin);
- break;
- }
- memset(buffer, 0, bufferSize+1);
- fseek(fin, 0, SEEK_SET);
- if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) )
- {
- free(fileName);
- free(buffer);
- fclose(fin);
- break;
- }
- // ignore a newline at the end of the file
- if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0';
-
- // load the string read from the file
- khrIcdVendorAdd(buffer);
+ continue;
+ }
+ if (strcmp(dirEntry->d_name + strlen(dirEntry->d_name) - strlen(extension), extension) )
+ {
+ continue;
+ }
+
+ // allocate space for the full path of the vendor library name
+ fileName = malloc(strlen(dirEntry->d_name) + strlen(vendorPath) + 2);
+ if (!fileName)
+ {
+ KHR_ICD_TRACE("Failed allocate space for ICD file path\n");
+ continue;
+ }
+ sprintf(fileName, "%s/%s", vendorPath, dirEntry->d_name);
+ // open the file and read its contents
+ fin = fopen(fileName, "r");
+ if (!fin)
+ {
+ free(fileName);
+ continue;
+ }
+ fseek(fin, 0, SEEK_END);
+ bufferSize = ftell(fin);
+
+ buffer = malloc(bufferSize+1);
+ if (!buffer)
+ {
+ free(fileName);
+ fclose(fin);
+ continue;
+ }
+ memset(buffer, 0, bufferSize+1);
+ fseek(fin, 0, SEEK_SET);
+ if (bufferSize != (long)fread(buffer, 1, bufferSize, fin) )
+ {
free(fileName);
free(buffer);
fclose(fin);
+ continue;
}
- break;
- default:
- break;
+ // ignore a newline at the end of the file
+ if (buffer[bufferSize-1] == '\n') buffer[bufferSize-1] = '\0';
+
+ // load the string read from the file
+ khrIcdVendorAdd(buffer);
+
+ free(fileName);
+ free(buffer);
+ fclose(fin);
+ }
+ else
+ {
+ continue;
}
}
{
cl_int ret = CL_SUCCESS;
- if ((num_entries > 1 || num_entries < 0) && devices != NULL) {
+ if ((num_entries > 1) && devices != NULL) {
ret = CL_INVALID_VALUE;
goto done;
}
void (CL_CALLBACK * pfn_notify)(cl_program program , void * user_data),
void * user_data) CL_API_SUFFIX__VERSION_1_2
{
+ (void)input_headers;
cl_int return_value = CL_OUT_OF_RESOURCES;
test_icd_stub_log("clCompileProgram(%p, %u, %p, %p, %u, %p, %p, %p)\n",
program,
void *func;
};
-#define EXT_FUNC(name) { #name, (void*)(name) }
+#define EXT_FUNC(name) { #name, (void*)(intptr_t)(name) }
static struct driverStubextFunc_st clExtensions[] =
{
#define ICD_DISPATCH_TABLE_ENTRY(fn) \
assert(dispatchTable->entryCount < 256); \
- dispatchTable->entries[dispatchTable->entryCount++] = (void*)(fn)
+ dispatchTable->entries[dispatchTable->entryCount++] = (void*)(intptr_t)(fn)
cl_int cliIcdDispatchTableCreate(CLIicdDispatchTable **outDispatchTable)
{
int main(int argc, char **argv)
{
+ (void)argc;
+ (void)argv;
test_icd_initialize_app_log();
test_icd_initialize_stub_log();
struct clEnqueueNDRangeKernel_st
{
cl_command_queue command_queue;
- cl_kernel kernel; cl_uint work_dim;
+ cl_kernel kernel;
+ cl_uint work_dim;
const size_t *global_work_offset;
const size_t *global_work_size;
const size_t *local_work_size;
int test_clRetainMemObject(const struct clRetainMemObject_st *data)
{
+ (void)data;
test_icd_app_log("clRetainMemObject(%p)\n", buffer);
ret_val=clRetainMemObject(buffer);
int test_clRetainCommandQueue(const struct clRetainCommandQueue_st *data)
{
+ (void)data;
cl_int ret_val;
test_icd_app_log("clRetainCommandQueue(%p)\n", command_queue);
data->sync,
data->errcode_ret);
- pfn_clCreateEventFromGLsyncKHR = clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR");
+ pfn_clCreateEventFromGLsyncKHR = (PFN_clCreateEventFromGLsyncKHR)
+ (intptr_t)clGetExtensionFunctionAddress("clCreateEventFromGLsyncKHR");
if (!pfn_clCreateEventFromGLsyncKHR) {
test_icd_app_log("clGetExtensionFunctionAddress failed!\n");
return 1;
data->param_value,
data->param_value_size_ret);
- pfn_clGetGLContextInfoKHR = clGetExtensionFunctionAddress("clGetGLContextInfoKHR");
+ pfn_clGetGLContextInfoKHR = (PFN_clGetGLContextInfoKHR)
+ (intptr_t)clGetExtensionFunctionAddress("clGetGLContextInfoKHR");
if (!pfn_clGetGLContextInfoKHR) {
test_icd_app_log("clGetExtensionFunctionAddress failed!\n");
return 1;
data->num_entries,
&platforms,
&num_platforms);
+#else
+ (void)data;
#endif
ret_val = clGetPlatformIDs(0,
int test_clReleaseSampler(const struct clReleaseSampler_st *data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseSampler(%p)\n", sampler);
int test_clReleaseEvent(const struct clReleaseEvent_st* data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseEvent(%p)\n", event);
int test_clReleaseKernel(const struct clReleaseKernel_st* data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseKernel(%p)\n", kernel);
int test_clReleaseProgram(const struct clReleaseProgram_st *data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseProgram(%p)\n", program);
int test_clReleaseCommandQueue(const struct clReleaseCommandQueue_st *data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseCommandQueue(%p)\n", command_queue);
int test_clReleaseContext(const struct clReleaseContext_st* data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseContext(%p)\n", context);
int test_clReleaseDevice(const struct clReleaseDevice_st* data)
{
+ (void)data;
int ret_val = CL_OUT_OF_RESOURCES;
test_icd_app_log("clReleaseDevice(%p)\n", devices);
const struct clEnqueueMapImage_st clEnqueueMapImageData[NUM_ITEMS_clEnqueueMapImage] =
{
- { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL,0, NULL, NULL}
+ { NULL, NULL, 0, 0x0, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL}
};
const struct clEnqueueReadImage_st clEnqueueReadImageData[NUM_ITEMS_clEnqueueReadImage] =
int test_clRetainKernel(const struct clRetainKernel_st* data)
{
+ (void)data;
test_icd_app_log("clRetainKernel(%p)\n", kernel);
ret_val=clRetainKernel(kernel);
struct clEnqueueNDRangeKernel_st clEnqueueNDRangeKernelData[NUM_ITEMS_clEnqueueNDRangeKernel] =
{
- {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL}
+ {NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, NULL}
};
int test_clEnqueueNDRangeKernel(const struct clEnqueueNDRangeKernel_st* data)
int test_clRetainEvent(const struct clRetainEvent_st* data)
{
+ (void)data;
test_icd_app_log("clRetainEvent(%p)\n", event);
ret_val=clRetainEvent(event);
int test_clEnqueueMarker(const struct clEnqueueMarker_st* data)
{
+ (void)data;
test_icd_app_log("clEnqueueMarker(%p, %p)\n", command_queue, &event);
ret_val = clEnqueueMarker(command_queue, &event);
int test_clEnqueueBarrier(const struct clEnqueueBarrier_st* data)
{
+ (void)data;
test_icd_app_log("clEnqueueBarrier(%p)\n", command_queue);
ret_val = clEnqueueBarrier(command_queue);
int test_clFlush(const struct clFlush_st* data)
{
+ (void)data;
test_icd_app_log("clFlush(%p)\n", command_queue);
ret_val=clFlush(command_queue);
int test_clFinish(const struct clFinish_st* data)
{
+ (void)data;
test_icd_app_log("clFinish(%p)\n", command_queue);
ret_val=clFinish(command_queue);
int test_clRetainContext(const struct clRetainContext_st* data)
{
+ (void)data;
cl_int ret_val;
test_icd_app_log("clRetainContext(%p)\n", context);
int test_clRetainDevice(const struct clRetainDevice_st* data)
{
+ (void)data;
cl_int ret_val;
test_icd_app_log("clRetainDevice(%p)\n", devices);
int test_clRetainProgram(const struct clRetainProgram_st *data)
{
+ (void)data;
cl_int ret_val;
test_icd_app_log("clRetainProgram(%p)\n",
int test_clUnloadPlatformCompiler(const struct clUnloadPlatformCompiler_st *data)
{
+ (void)data;
cl_int ret_val;
test_icd_app_log("clUnloadPlatformCompiler(%p)\n", platform);
int test_clRetainSampler(const struct clRetainSampler_st *data)
{
+ (void)data;
cl_int ret_val;
test_icd_app_log("clRetainSampler(%p)\n", sampler);