Skip to content

Commit

Permalink
Make compatible with MinGW (patch by Gregor Thalhammer)
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Aug 26, 2015
1 parent 9c38a41 commit 905e6e6
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
@@ -1,3 +1,6 @@
[submodule "pyopencl/compyte"]
path = pyopencl/compyte
url = https://github.com/inducer/compyte
[submodule "src/c_wrapper/mingw-std-threads"]
path = src/c_wrapper/mingw-std-threads
url = https://github.com/meganz/mingw-std-threads.git
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -4,6 +4,7 @@ include pyopencl/cl/*.cl
include src/c_wrapper/*.hpp
include src/c_wrapper/*.h
include src/c_wrapper/*.cpp
include src/c_wrapper/mingw-std-wrappers/mingw.*.h
include *.h
include test/*.py
include test/*.h
Expand Down
6 changes: 4 additions & 2 deletions pyopencl/cffi_cl.py
Expand Up @@ -35,7 +35,8 @@
from pyopencl._cffi import ffi as _ffi
from .compyte.array import f_contiguous_strides, c_contiguous_strides

_lib = _ffi.dlopen(None)

from pyopencl._cffi import lib as _lib


class _CLKernelArg(object):
Expand Down Expand Up @@ -456,7 +457,8 @@ class migrate_mem_object_flags_ext(_NoInit): # noqa
_locals = locals()


@_ffi.callback('void (*)(const char*, const char* name, long value)')
# TODO: constant values are cl_ulong
@_ffi.callback('void (*)(const char*, const char* name, unsigned long value)')
def _constant_callback(type_, name, value):
setattr(_locals[_ffi_pystr(type_)], _ffi_pystr(name), value) # noqa

Expand Down
10 changes: 10 additions & 0 deletions src/c_wrapper/debug.h
@@ -1,8 +1,18 @@
#include "wrap_cl.h"
#include "function.h"
#include <string.h>

#ifdef __MINGW32__

#include "mingw-std-threads/mingw.mutex.h"
#include "mingw-std-threads/mingw.thread.h"

#else

#include <mutex>

#endif

#ifndef __PYOPENCL_DEBUG_H
#define __PYOPENCL_DEBUG_H

Expand Down
1 change: 1 addition & 0 deletions src/c_wrapper/mingw-std-threads
Submodule mingw-std-threads added at 776ce7
2 changes: 1 addition & 1 deletion src/c_wrapper/wrap_cl_core.h
Expand Up @@ -56,7 +56,7 @@ void set_py_funcs(int (*_gc)(), void *(*_ref)(void*), void (*_deref)(void*),
int have_gl();

unsigned bitlog2(unsigned long v);
void populate_constants(void(*add)(const char*, const char*, long value));
void populate_constants(void(*add)(const char*, const char*, unsigned long value));
int get_debug();
void set_debug(int debug);

Expand Down
2 changes: 1 addition & 1 deletion src/c_wrapper/wrap_constants.cpp
Expand Up @@ -2,7 +2,7 @@
#include <iostream>

extern "C"
void populate_constants(void(*add)(const char*, const char*, long value))
void populate_constants(void(*add)(const char*, const char*, unsigned long value))
{
#define _ADD_ATTR(TYPE, PREFIX, NAME, SUFFIX, ...) \
add(TYPE, #NAME, CL_##PREFIX##NAME##SUFFIX)
Expand Down

0 comments on commit 905e6e6

Please sign in to comment.