Skip to content

Commit 28c51a7

Browse files
authored
Merge pull request #415 from notoraptor/fix-win-compilation-error
Try to fix compilation errors on Windows/Python 2.7/64 bits.
2 parents d2a0d8a + 0e361e7 commit 28c51a7

6 files changed

Lines changed: 22 additions & 14 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ lib
66
.*.sw[po]
77
*~
88
*.pyc
9+
*.pyd
910
*.pyo
1011
*.egg-info
1112
MANIFEST

src/cache/disk.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static int find_entry(disk_cache *c, const cache_key_t key,
335335
b.l = vl;
336336
*_v = c->vread(&b);
337337
if (*_v == NULL)
338-
goto error;
338+
goto error_find_entry;
339339
}
340340
if (_k)
341341
*_k = k;
@@ -345,7 +345,7 @@ static int find_entry(disk_cache *c, const cache_key_t key,
345345
strb_clear(&b);
346346
return 1;
347347
}
348-
error:
348+
error_find_entry:
349349
if (k)
350350
c->c.kfree(k);
351351
b.s = ts;

src/gpuarray_elemwise.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -387,11 +387,11 @@ static int call_basic(GpuElemwise *ge, void **args, size_t n, unsigned int nd,
387387
}
388388

389389
err = GpuKernel_setarg(k, p++, &n);
390-
if (err != GA_NO_ERROR) goto error;
390+
if (err != GA_NO_ERROR) goto error_call_basic;
391391

392392
for (i = 0; i < nd; i++) {
393393
err = GpuKernel_setarg(k, p++, &dims[i]);
394-
if (err != GA_NO_ERROR) goto error;
394+
if (err != GA_NO_ERROR) goto error_call_basic;
395395
}
396396

397397
/* l is the number of arrays to date */
@@ -400,25 +400,25 @@ static int call_basic(GpuElemwise *ge, void **args, size_t n, unsigned int nd,
400400
if (is_array(ge->args[j])) {
401401
GpuArray *v = (GpuArray *)args[j];
402402
err = GpuKernel_setarg(k, p++, v->data);
403-
if (err != GA_NO_ERROR) goto error;
403+
if (err != GA_NO_ERROR) goto error_call_basic;
404404
err = GpuKernel_setarg(k, p++, &v->offset);
405-
if (err != GA_NO_ERROR) goto error;
405+
if (err != GA_NO_ERROR) goto error_call_basic;
406406
for (i = 0; i < nd; i++) {
407407
err = GpuKernel_setarg(k, p++, &strs[l][i]);
408-
if (err != GA_NO_ERROR) goto error;
408+
if (err != GA_NO_ERROR) goto error_call_basic;
409409
}
410410
l++;
411411
} else {
412412
err = GpuKernel_setarg(k, p++, args[j]);
413-
if (err != GA_NO_ERROR) goto error;
413+
if (err != GA_NO_ERROR) goto error_call_basic;
414414
}
415415
}
416416

417417
err = GpuKernel_sched(k, n, &gs, &ls);
418-
if (err != GA_NO_ERROR) goto error;
418+
if (err != GA_NO_ERROR) goto error_call_basic;
419419

420420
err = GpuKernel_call(k, 1, &gs, &ls, 0, NULL);
421-
error:
421+
error_call_basic:
422422
return err;
423423
}
424424

src/loaders/dyn_load.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void *ga_func_ptr(void *h, const char *name, error *e) {
2828
/* Should be windows */
2929
#include <windows.h>
3030

31-
static inline void error_win(error *e) {
31+
static inline void error_win(const char* name, error *e) {
3232
char msgbuf[512];
3333
DWORD err = GetLastError();
3434
DWORD len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|
@@ -43,14 +43,14 @@ static inline void error_win(error *e) {
4343
void *ga_load_library(const char *name, error *e) {
4444
void *res = LoadLibrary(name);
4545
if (res == NULL)
46-
error_win(e);
46+
error_win(name, e);
4747
return res;
4848
}
4949

5050
void *ga_func_ptr(void *h, const char *name, error *e) {
5151
void *res = (void *)GetProcAddress(h, name);
5252
if (res == NULL)
53-
error_win(e);
53+
error_win(name, e);
5454
return res;
5555
}
5656

src/util/error.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "private_config.h"
66
#include "util/error.h"
77

8-
static error _global_err = {};
8+
static error _global_err = {{0}, 0};
99
error *global_err = &_global_err;
1010

1111
int error_alloc(error **_e) {

src/util/error.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
#include <gpuarray/error.h>
88

9+
/* MSVC 2008 does not support "inline". */
10+
#ifdef _MSC_VER
11+
#ifndef inline
12+
#define inline __inline
13+
#endif
14+
#endif
15+
916
/* 1024 - 4 for the int that goes after */
1017
#define ERROR_MSGBUF_LEN 1020
1118

0 commit comments

Comments
 (0)