Author: Ronan Lamy <[email protected]>
Branch:
Changeset: r89649:4cbdd68326aa
Date: 2017-01-18 01:36 +0000
http://bitbucket.org/pypy/pypy/changeset/4cbdd68326aa/
Log: Fix/hack around issues with clang and MSVC
diff --git a/pypy/module/cpyext/cparser.py b/pypy/module/cpyext/cparser.py
--- a/pypy/module/cpyext/cparser.py
+++ b/pypy/module/cpyext/cparser.py
@@ -1,3 +1,4 @@
+import sys
from collections import OrderedDict
from cffi import api, model
from cffi.commontypes import COMMON_TYPES, resolve_common_type
@@ -665,6 +666,8 @@
add_inttypes()
CNAME_TO_LLTYPE['int'] = rffi.INT_real
CNAME_TO_LLTYPE['wchar_t'] = lltype.UniChar
+if 'ssize_t' not in CNAME_TO_LLTYPE: # on Windows
+ CNAME_TO_LLTYPE['ssize_t'] = CNAME_TO_LLTYPE['long']
def cname_to_lltype(name):
return CNAME_TO_LLTYPE[name]
@@ -773,8 +776,13 @@
for hdr in x.headers:
if hdr not in all_headers:
all_headers.append(hdr)
+ if sys.platform == 'win32':
+ compile_extra = ['-Dssize_t=long']
+ else:
+ compile_extra = []
return ExternalCompilationInfo(
- post_include_bits=all_sources, includes=all_headers)
+ post_include_bits=all_sources, includes=all_headers,
+ compile_extra=compile_extra)
def configure_types(self):
for name, (obj, quals) in self.ctx._declarations.iteritems():
diff --git a/pypy/module/cpyext/include/Python.h
b/pypy/module/cpyext/include/Python.h
--- a/pypy/module/cpyext/include/Python.h
+++ b/pypy/module/cpyext/include/Python.h
@@ -57,13 +57,6 @@
#endif
#include <stdlib.h>
-#ifndef _WIN32
-typedef intptr_t Py_ssize_t;
-#else
-typedef long Py_ssize_t;
-#endif
-#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
-#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
#define Py_SAFE_DOWNCAST(VALUE, WIDE, NARROW) (NARROW)(VALUE)
#define Py_USING_UNICODE
diff --git a/pypy/module/cpyext/include/object.h
b/pypy/module/cpyext/include/object.h
--- a/pypy/module/cpyext/include/object.h
+++ b/pypy/module/cpyext/include/object.h
@@ -7,12 +7,20 @@
extern "C" {
#endif
+/* Hack: MSVC doesn't support ssize_t */
+#ifdef _WIN32
+#define ssize_t long
+#endif
+#include <cpyext_object.h>
+#ifdef _WIN32
+#undef ssize_t
+#endif
-#include <cpyext_object.h>
+#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1))
+#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1)
#define Py_RETURN_NONE return Py_INCREF(Py_None), Py_None
-
/*
CPython has this for backwards compatibility with really old extensions, and
now
we have it for compatibility with CPython.
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit