diff --git a/setup.py b/setup.py index c506c17..7e70807 100644 --- a/setup.py +++ b/setup.py @@ -22,18 +22,11 @@ def get_sources(): return sorted(glob.glob("src/*.c") + ["vendor/hiredis/%s.c" % src for src in hiredis_sources]) -def get_linker_args(): - if 'win32' in sys.platform or 'darwin' in sys.platform: - return [] - else: - return ["-Wl,-Bsymbolic",] - - def get_compiler_args(): if 'win32' in sys.platform: return [] else: - return ["-std=c99",] + return ["-std=c99", "-static-libstdc++", "-O2"] def get_libraries(): @@ -46,7 +39,6 @@ def get_libraries(): ext = Extension("hiredis.hiredis", sources=get_sources(), extra_compile_args=get_compiler_args(), - extra_link_args=get_linker_args(), libraries=get_libraries(), include_dirs=["vendor"]) diff --git a/src/pack.c b/src/pack.c index 0272a26..e92efe7 100644 --- a/src/pack.c +++ b/src/pack.c @@ -1,5 +1,21 @@ #include "pack.h" + +#ifndef _MSC_VER #include +#else +/* Workaround for https://bugs.python.org/issue11717. + * defines ssize_t which can conflict + * with Python's definition. + */ +extern long long redisFormatCommandArgv(char **target, int argc, const char **argv, const size_t *argvlen); +typedef char *sds; +extern void sds_free(void *ptr); +extern sds sdsempty(void); +extern void sdsfreesplitres(sds *tokens, int count); +extern sds sdscpylen(sds s, const char *t, size_t len); +extern sds sdsnewlen(const void *init, size_t initlen); +#endif + #include PyObject * @@ -15,7 +31,7 @@ pack_command(PyObject *cmd) return NULL; } - int tokens_number = PyTuple_Size(cmd); + Py_ssize_t tokens_number = PyTuple_Size(cmd); sds *tokens = s_malloc(sizeof(sds) * tokens_number); if (tokens == NULL) { @@ -32,7 +48,6 @@ pack_command(PyObject *cmd) } Py_ssize_t len = 0; - for (Py_ssize_t i = 0; i < PyTuple_Size(cmd); i++) { PyObject *item = PyTuple_GetItem(cmd, i);