Author: Christian Tismer <[email protected]>
Branch: 
Changeset: r53747:3ecfa5abe34e
Date: 2012-03-17 05:35 +0100
http://bitbucket.org/pypy/pypy/changeset/3ecfa5abe34e/

Log:    sorry, I crashed the nightly builds by not providing SIGNED. It is
        fixed now and seems to work on win32 and win64.

diff --git a/pypy/rpython/lltypesystem/rffi.py 
b/pypy/rpython/lltypesystem/rffi.py
--- a/pypy/rpython/lltypesystem/rffi.py
+++ b/pypy/rpython/lltypesystem/rffi.py
@@ -18,6 +18,7 @@
 from pypy.rlib.rstring import StringBuilder, UnicodeBuilder, assert_str0
 from pypy.rlib import jit
 from pypy.rpython.lltypesystem import llmemory
+from pypy.rlib.rarithmetic import maxint, LONG_BIT
 import os, sys
 
 class CConstant(Symbolic):
@@ -649,8 +650,9 @@
 # float *
 FLOATP = lltype.Ptr(lltype.Array(FLOAT, hints={'nolength': True}))
 
-# SIGNED *
-SIGNEDP = lltype.Ptr(lltype.Array(lltype.Signed, hints={'nolength': True}))
+# Signed, Signed *
+SIGNED = lltype.Signed
+SIGNEDP = lltype.Ptr(lltype.Array(SIGNED, hints={'nolength': True}))
 
 # various type mapping
 
@@ -900,7 +902,7 @@
             size = llmemory.sizeof(tp)    # a symbolic result in this case
         return size
     if isinstance(tp, lltype.Ptr) or tp is llmemory.Address:
-        tp = ULONG     # XXX!
+        tp = lltype.Signed
     if tp is lltype.Char or tp is lltype.Bool:
         return 1
     if tp is lltype.UniChar:
@@ -911,7 +913,7 @@
         return 4
     assert isinstance(tp, lltype.Number)
     if tp is lltype.Signed:
-        return ULONG._type.BITS/8
+        return LONG_BIT/8
     return tp._type.BITS/8
 sizeof._annspecialcase_ = 'specialize:memo'
 
@@ -931,11 +933,11 @@
 offsetof._annspecialcase_ = 'specialize:memo'
 
 # check that we have a sane configuration
-assert sys.maxint == (1 << (8 * sizeof(lltype.Signed) - 1)) - 1, (
+assert maxint == (1 << (8 * sizeof(lltype.Signed) - 1)) - 1, (
     "Mixed configuration of the word size of the machine:\n\t"
     "the underlying Python was compiled with maxint=%d,\n\t"
     "but the C compiler says that 'long' is %d bytes" % (
-    sys.maxint, sizeof(lltype.Signed)))
+    maxint, sizeof(lltype.Signed)))
 
 # ********************** some helpers *******************
 
diff --git a/pypy/rpython/lltypesystem/test/test_rffi.py 
b/pypy/rpython/lltypesystem/test/test_rffi.py
--- a/pypy/rpython/lltypesystem/test/test_rffi.py
+++ b/pypy/rpython/lltypesystem/test/test_rffi.py
@@ -180,7 +180,7 @@
             struct.c_three = cast(INT, 5)
             result = z(struct)
             lltype.free(struct, flavor='raw')
-            return cast(LONG, result)
+            return cast(SIGNED, result)
     
         fn = self.compile(f, [], backendopt=False)
         assert fn() == 8
@@ -377,7 +377,7 @@
         h_source = py.code.Source("""
         #ifndef _CALLBACK_H
         #define _CALLBACK_H
-        extern long eating_callback(long arg, long(*call)(long));
+        extern Signed eating_callback(Signed arg, Signed(*call)(Signed));
         #endif /* _CALLBACK_H */
         """)
         
@@ -385,9 +385,9 @@
         h_include.write(h_source)
 
         c_source = py.code.Source("""
-        long eating_callback(long arg, long(*call)(long))
+        Signed eating_callback(Signed arg, Signed(*call)(Signed))
         {
-            long res = call(arg);
+            Signed res = call(arg);
             if (res == -1)
               return -1;
             return res;
@@ -399,8 +399,8 @@
                                       separate_module_sources=[c_source],
                                       export_symbols=['eating_callback'])
 
-        args = [LONG, CCallback([LONG], LONG)]
-        eating_callback = llexternal('eating_callback', args, LONG,
+        args = [SIGNED, CCallback([SIGNED], SIGNED)]
+        eating_callback = llexternal('eating_callback', args, SIGNED,
                                      compilation_info=eci)
 
         return eating_callback
@@ -554,13 +554,13 @@
             p = make(X, c_one=cast(INT, 3))
             res = p.c_one
             lltype.free(p, flavor='raw')
-            return cast(LONG, res)
+            return cast(SIGNED, res)
         assert f() == 3
         assert interpret(f, []) == 3
     
     def test_structcopy(self):
-        X2 = lltype.Struct('X2', ('x', LONG))
-        X1 = lltype.Struct('X1', ('a', LONG), ('x2', X2), ('p', 
lltype.Ptr(X2)))
+        X2 = lltype.Struct('X2', ('x', SIGNED))
+        X1 = lltype.Struct('X1', ('a', SIGNED), ('x2', X2), ('p', 
lltype.Ptr(X2)))
         def f():
             p2 = make(X2, x=123)
             p1 = make(X1, a=5, p=p2)
@@ -620,7 +620,7 @@
         eci = ExternalCompilationInfo(includes=['string.h'])
         strlen = llexternal('strlen', [CCHARP], SIZE_T, compilation_info=eci)
         def f():
-            return cast(LONG, strlen("Xxx"))
+            return cast(SIGNED, strlen("Xxx"))
         assert interpret(f, [], backendopt=True) == 3
     
     def test_stringpolicy3(self):
@@ -643,7 +643,7 @@
             ll_str = str2charp("Xxx")
             res2 = strlen(ll_str)
             lltype.free(ll_str, flavor='raw')
-            return cast(LONG, res1*10 + res2)
+            return cast(SIGNED, res1*10 + res2)
     
         assert interpret(f, [], backendopt=True) == 43    
     
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to