Author: Armin Rigo <[email protected]>
Branch: 
Changeset: r75127:937033492549
Date: 2014-12-26 17:52 +0100
http://bitbucket.org/pypy/pypy/changeset/937033492549/

Log:    Windows support

diff --git a/pypy/module/_cffi_backend/newtype.py 
b/pypy/module/_cffi_backend/newtype.py
--- a/pypy/module/_cffi_backend/newtype.py
+++ b/pypy/module/_cffi_backend/newtype.py
@@ -62,29 +62,53 @@
 
 eptype("intptr_t",  rffi.INTPTR_T,  ctypeprim.W_CTypePrimitiveSigned)
 eptype("uintptr_t", rffi.UINTPTR_T, ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("ptrdiff_t", rffi.PTRDIFF_T, ctypeprim.W_CTypePrimitiveSigned)
 eptype("size_t",    rffi.SIZE_T,    ctypeprim.W_CTypePrimitiveUnsigned)
 eptype("ssize_t",   rffi.SSIZE_T,   ctypeprim.W_CTypePrimitiveSigned)
-eptype("intmax_t",  rffi.INTMAX_T,  ctypeprim.W_CTypePrimitiveSigned)
-eptype("uintmax_t", rffi.UINTMAX_T, ctypeprim.W_CTypePrimitiveUnsigned)
 
-eptype("int_least8_t",  rffi.INT_LEAST8_T,  ctypeprim.W_CTypePrimitiveSigned)
-eptype("int_least16_t", rffi.INT_LEAST16_T, ctypeprim.W_CTypePrimitiveSigned)
-eptype("int_least32_t", rffi.INT_LEAST32_T, ctypeprim.W_CTypePrimitiveSigned)
-eptype("int_least64_t", rffi.INT_LEAST64_T, ctypeprim.W_CTypePrimitiveSigned)
-eptype("uint_least8_t", rffi.UINT_LEAST8_T,  
ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("uint_least16_t",rffi.UINT_LEAST16_T, 
ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("uint_least32_t",rffi.UINT_LEAST32_T, 
ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("uint_least64_t",rffi.UINT_LEAST64_T, 
ctypeprim.W_CTypePrimitiveUnsigned)
+_WCTSigned = ctypeprim.W_CTypePrimitiveSigned
+_WCTUnsign = ctypeprim.W_CTypePrimitiveUnsigned
 
-eptype("int_fast8_t",  rffi.INT_FAST8_T,  ctypeprim.W_CTypePrimitiveSigned)
-eptype("int_fast16_t", rffi.INT_FAST16_T, ctypeprim.W_CTypePrimitiveSigned)
-eptype("int_fast32_t", rffi.INT_FAST32_T, ctypeprim.W_CTypePrimitiveSigned)
-eptype("int_fast64_t", rffi.INT_FAST64_T, ctypeprim.W_CTypePrimitiveSigned)
-eptype("uint_fast8_t", rffi.UINT_FAST8_T,  ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("uint_fast16_t",rffi.UINT_FAST16_T, ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("uint_fast32_t",rffi.UINT_FAST32_T, ctypeprim.W_CTypePrimitiveUnsigned)
-eptype("uint_fast64_t",rffi.UINT_FAST64_T, ctypeprim.W_CTypePrimitiveUnsigned)
+eptype("ptrdiff_t", getattr(rffi, 'PTRDIFF_T', rffi.INTPTR_T), _WCTSigned)
+eptype("intmax_t",  getattr(rffi, 'INTMAX_T',  rffi.LONGLONG), _WCTSigned)
+eptype("uintmax_t", getattr(rffi, 'UINTMAX_T', rffi.LONGLONG), _WCTUnsign)
+
+if hasattr(rffi, 'INT_LEAST8_T'):
+    eptype("int_least8_t",  rffi.INT_LEAST8_T,  _WCTSigned)
+    eptype("int_least16_t", rffi.INT_LEAST16_T, _WCTSigned)
+    eptype("int_least32_t", rffi.INT_LEAST32_T, _WCTSigned)
+    eptype("int_least64_t", rffi.INT_LEAST64_T, _WCTSigned)
+    eptype("uint_least8_t", rffi.UINT_LEAST8_T,  _WCTUnsign)
+    eptype("uint_least16_t",rffi.UINT_LEAST16_T, _WCTUnsign)
+    eptype("uint_least32_t",rffi.UINT_LEAST32_T, _WCTUnsign)
+    eptype("uint_least64_t",rffi.UINT_LEAST64_T, _WCTUnsign)
+else:
+    eptypesize("int_least8_t",   1, _WCTSigned)
+    eptypesize("uint_least8_t",  1, _WCTUnsign)
+    eptypesize("int_least16_t",  2, _WCTSigned)
+    eptypesize("uint_least16_t", 2, _WCTUnsign)
+    eptypesize("int_least32_t",  4, _WCTSigned)
+    eptypesize("uint_least32_t", 4, _WCTUnsign)
+    eptypesize("int_least64_t",  8, _WCTSigned)
+    eptypesize("uint_least64_t", 8, _WCTUnsign)
+
+if hasattr(rffi, 'INT_FAST8_T'):
+    eptype("int_fast8_t",  rffi.INT_FAST8_T,  _WCTSigned)
+    eptype("int_fast16_t", rffi.INT_FAST16_T, _WCTSigned)
+    eptype("int_fast32_t", rffi.INT_FAST32_T, _WCTSigned)
+    eptype("int_fast64_t", rffi.INT_FAST64_T, _WCTSigned)
+    eptype("uint_fast8_t", rffi.UINT_FAST8_T,  _WCTUnsign)
+    eptype("uint_fast16_t",rffi.UINT_FAST16_T, _WCTUnsign)
+    eptype("uint_fast32_t",rffi.UINT_FAST32_T, _WCTUnsign)
+    eptype("uint_fast64_t",rffi.UINT_FAST64_T, _WCTUnsign)
+else:
+    eptypesize("int_fast8_t",   1, _WCTSigned)
+    eptypesize("uint_fast8_t",  1, _WCTUnsign)
+    eptypesize("int_fast16_t",  2, _WCTSigned)
+    eptypesize("uint_fast16_t", 2, _WCTUnsign)
+    eptypesize("int_fast32_t",  4, _WCTSigned)
+    eptypesize("uint_fast32_t", 4, _WCTUnsign)
+    eptypesize("int_fast64_t",  8, _WCTSigned)
+    eptypesize("uint_fast64_t", 8, _WCTUnsign)
 
 @unwrap_spec(name=str)
 def new_primitive_type(space, name):
diff --git a/rpython/rtyper/lltypesystem/rffi.py 
b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -461,16 +461,7 @@
 TYPES += ['signed char', 'unsigned char',
           'long long', 'unsigned long long',
           'size_t', 'time_t', 'wchar_t',
-          'uintptr_t', 'intptr_t', 'ptrdiff_t',
-          'int_least8_t',  'uint_least8_t',
-          'int_least16_t', 'uint_least16_t',
-          'int_least32_t', 'uint_least32_t',
-          'int_least64_t', 'uint_least64_t',
-          'int_fast8_t',  'uint_fast8_t',
-          'int_fast16_t', 'uint_fast16_t',
-          'int_fast32_t', 'uint_fast32_t',
-          'int_fast64_t', 'uint_fast64_t',
-          'intmax_t', 'uintmax_t',
+          'uintptr_t', 'intptr_t',
           'void*']    # generic pointer type
 
 # This is a bit of a hack since we can't use rffi_platform here.
@@ -484,6 +475,17 @@
     TYPES.append('mode_t')
     TYPES.append('pid_t')
     TYPES.append('ssize_t')
+    # the types below are rare enough and not available on Windows
+    TYPES.extend(['ptrdiff_t',
+          'int_least8_t',  'uint_least8_t',
+          'int_least16_t', 'uint_least16_t',
+          'int_least32_t', 'uint_least32_t',
+          'int_least64_t', 'uint_least64_t',
+          'int_fast8_t',  'uint_fast8_t',
+          'int_fast16_t', 'uint_fast16_t',
+          'int_fast32_t', 'uint_fast32_t',
+          'int_fast64_t', 'uint_fast64_t',
+          'intmax_t', 'uintmax_t'])
 else:
     MODE_T = lltype.Signed
     PID_T = lltype.Signed
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to