Skip to content

Commit

Permalink
Merge pull request #415 from notoraptor/fix-win-compilation-error
Browse files Browse the repository at this point in the history
Try to fix compilation errors on Windows/Python 2.7/64 bits.
  • Loading branch information
nouiz authored Apr 20, 2017
2 parents d2a0d8a + 0e361e7 commit 28c51a7
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ lib
.*.sw[po]
*~
*.pyc
*.pyd
*.pyo
*.egg-info
MANIFEST
Expand Down
4 changes: 2 additions & 2 deletions src/cache/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ static int find_entry(disk_cache *c, const cache_key_t key,
b.l = vl;
*_v = c->vread(&b);
if (*_v == NULL)
goto error;
goto error_find_entry;
}
if (_k)
*_k = k;
Expand All @@ -345,7 +345,7 @@ static int find_entry(disk_cache *c, const cache_key_t key,
strb_clear(&b);
return 1;
}
error:
error_find_entry:
if (k)
c->c.kfree(k);
b.s = ts;
Expand Down
16 changes: 8 additions & 8 deletions src/gpuarray_elemwise.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,11 +387,11 @@ static int call_basic(GpuElemwise *ge, void **args, size_t n, unsigned int nd,
}

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

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

/* l is the number of arrays to date */
Expand All @@ -400,25 +400,25 @@ static int call_basic(GpuElemwise *ge, void **args, size_t n, unsigned int nd,
if (is_array(ge->args[j])) {
GpuArray *v = (GpuArray *)args[j];
err = GpuKernel_setarg(k, p++, v->data);
if (err != GA_NO_ERROR) goto error;
if (err != GA_NO_ERROR) goto error_call_basic;
err = GpuKernel_setarg(k, p++, &v->offset);
if (err != GA_NO_ERROR) goto error;
if (err != GA_NO_ERROR) goto error_call_basic;
for (i = 0; i < nd; i++) {
err = GpuKernel_setarg(k, p++, &strs[l][i]);
if (err != GA_NO_ERROR) goto error;
if (err != GA_NO_ERROR) goto error_call_basic;
}
l++;
} else {
err = GpuKernel_setarg(k, p++, args[j]);
if (err != GA_NO_ERROR) goto error;
if (err != GA_NO_ERROR) goto error_call_basic;
}
}

err = GpuKernel_sched(k, n, &gs, &ls);
if (err != GA_NO_ERROR) goto error;
if (err != GA_NO_ERROR) goto error_call_basic;

err = GpuKernel_call(k, 1, &gs, &ls, 0, NULL);
error:
error_call_basic:
return err;
}

Expand Down
6 changes: 3 additions & 3 deletions src/loaders/dyn_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ void *ga_func_ptr(void *h, const char *name, error *e) {
/* Should be windows */
#include <windows.h>

static inline void error_win(error *e) {
static inline void error_win(const char* name, error *e) {
char msgbuf[512];
DWORD err = GetLastError();
DWORD len = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM|
Expand All @@ -43,14 +43,14 @@ static inline void error_win(error *e) {
void *ga_load_library(const char *name, error *e) {
void *res = LoadLibrary(name);
if (res == NULL)
error_win(e);
error_win(name, e);
return res;
}

void *ga_func_ptr(void *h, const char *name, error *e) {
void *res = (void *)GetProcAddress(h, name);
if (res == NULL)
error_win(e);
error_win(name, e);
return res;
}

Expand Down
2 changes: 1 addition & 1 deletion src/util/error.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "private_config.h"
#include "util/error.h"

static error _global_err = {};
static error _global_err = {{0}, 0};
error *global_err = &_global_err;

int error_alloc(error **_e) {
Expand Down
7 changes: 7 additions & 0 deletions src/util/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@

#include <gpuarray/error.h>

/* MSVC 2008 does not support "inline". */
#ifdef _MSC_VER
#ifndef inline
#define inline __inline
#endif
#endif

/* 1024 - 4 for the int that goes after */
#define ERROR_MSGBUF_LEN 1020

Expand Down

0 comments on commit 28c51a7

Please sign in to comment.