Fixed fread issues under Windows.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
diff --git a/ocl.c b/ocl.c
index cb95182..4b64815 100644
--- a/ocl.c
+++ b/ocl.c
@@ -14,7 +14,7 @@
#else
#include <sys/socket.h>
#include <netinet/in.h>
- #include <netdb.h>
+ #include <netdb.h>
#endif
#include <time.h>
@@ -31,7 +31,7 @@ extern int opt_worksize;
char *file_contents(const char *filename, int *length)
{
- FILE *f = fopen(filename, "r");
+ FILE *f = fopen(filename, "rb");
void *buffer;
if (!f) {
@@ -88,7 +88,7 @@ int clDevicesNum() {
if (!strcmp(pbuff, "Advanced Micro Devices, Inc."))
{
break;
- }
+ }
}
free(platforms);
}
@@ -384,7 +384,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
strcat(binaryfilename, numbuf);
strcat(binaryfilename, ".bin");
- binaryfile = fopen(binaryfilename, "r");
+ binaryfile = fopen(binaryfilename, "rb");
if (!binaryfile) {
if (opt_debug)
applog(LOG_DEBUG, "No binary found, generating from source");
@@ -420,7 +420,7 @@ _clState *initCl(unsigned int gpu, char *name, size_t nameSize)
}
if (opt_debug)
applog(LOG_DEBUG, "Loaded binary image %s", binaryfilename);
-
+
free(binaries[gpu]);
goto built;
}
@@ -479,7 +479,7 @@ build:
applog(LOG_DEBUG, "cl_amd_media_ops not found, will not BFI_INT patch");
clState->program = clCreateProgramWithSource(clState->context, 1, (const char **)&source, sourceSize, &status);
- if (status != CL_SUCCESS)
+ if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Loading Binary into cl_program (clCreateProgramWithSource)");
return NULL;
@@ -487,7 +487,7 @@ build:
/* create a cl program executable for all the devices specified */
status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
- if (status != CL_SUCCESS)
+ if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Building Program (clBuildProgram)");
size_t logSize;
@@ -496,7 +496,7 @@ build:
char *log = malloc(logSize);
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
applog(LOG_INFO, "%s", log);
- return NULL;
+ return NULL;
}
status = clGetProgramInfo( clState->program, CL_PROGRAM_BINARY_SIZES, sizeof(size_t)*nDevices, binary_sizes, NULL );
@@ -559,7 +559,7 @@ build:
}
clState->program = clCreateProgramWithBinary(clState->context, 1, &devices[gpu], &binary_sizes[gpu], (const unsigned char **)&binaries[gpu], &status, NULL);
- if (status != CL_SUCCESS)
+ if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Loading Binary into cl_program (clCreateProgramWithBinary)");
return NULL;
@@ -570,7 +570,7 @@ build:
free(rawsource);
/* Save the binary to be loaded next time */
- binaryfile = fopen(binaryfilename, "w");
+ binaryfile = fopen(binaryfilename, "wb");
if (!binaryfile) {
/* Not a fatal problem, just means we build it again next time */
if (opt_debug)
@@ -593,7 +593,7 @@ built:
/* create a cl program executable for all the devices specified */
status = clBuildProgram(clState->program, 1, &devices[gpu], NULL, NULL, NULL);
- if (status != CL_SUCCESS)
+ if (status != CL_SUCCESS)
{
applog(LOG_ERR, "Error: Building Program (clBuildProgram)");
size_t logSize;
@@ -602,7 +602,7 @@ built:
char *log = malloc(logSize);
status = clGetProgramBuildInfo(clState->program, devices[gpu], CL_PROGRAM_BUILD_LOG, logSize, log, NULL);
applog(LOG_INFO, "%s", log);
- return NULL;
+ return NULL;
}
/* get a kernel object handle for a kernel with the given name */