[pypy-svn] r56650 - in pypy/dist/pypy/module/_rawffi: . test

arigo at codespeak.net arigo at codespeak.net
Fri Jul 18 23:16:17 CEST 2008


Author: arigo
Date: Fri Jul 18 23:16:17 2008
New Revision: 56650

Modified:
   pypy/dist/pypy/module/_rawffi/callback.py
   pypy/dist/pypy/module/_rawffi/test/test__rawffi.py
Log:
Fix test_callback for 64-bit-ness.  Fix the code to not truncate 
addresses to UINT (!).


Modified: pypy/dist/pypy/module/_rawffi/callback.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/callback.py	(original)
+++ pypy/dist/pypy/module/_rawffi/callback.py	Fri Jul 18 23:16:17 2008
@@ -30,7 +30,7 @@
     argtypes = callback_ptr.args
     space = callback_ptr.space
     try:
-        w_args = space.newlist([space.wrap(rffi.cast(rffi.UINT, ll_args[i]))
+        w_args = space.newlist([space.wrap(rffi.cast(rffi.ULONG, ll_args[i]))
                                 for i in range(len(argtypes))])
         w_res = space.call(w_callable, w_args)
         if callback_ptr.result != 'O': # don't return void

Modified: pypy/dist/pypy/module/_rawffi/test/test__rawffi.py
==============================================================================
--- pypy/dist/pypy/module/_rawffi/test/test__rawffi.py	(original)
+++ pypy/dist/pypy/module/_rawffi/test/test__rawffi.py	Fri Jul 18 23:16:17 2008
@@ -458,12 +458,11 @@
         ll_to_sort = _rawffi.Array('i')(4)
         for i in range(4):
             ll_to_sort[i] = 4-i
-        qsort = libc.ptr('qsort', ['P', 'i', 'i', 'P'], None)
-        resarray = _rawffi.Array('i')(1)
+        qsort = libc.ptr('qsort', ['P', 'l', 'l', 'P'], None)
         bogus_args = []
         def compare(a, b):
-            a1 = _rawffi.Array('i').fromaddress(_rawffi.Array('i').fromaddress(a, 1)[0], 1)
-            a2 = _rawffi.Array('i').fromaddress(_rawffi.Array('i').fromaddress(b, 1)[0], 1)
+            a1 = _rawffi.Array('i').fromaddress(_rawffi.Array('P').fromaddress(a, 1)[0], 1)
+            a2 = _rawffi.Array('i').fromaddress(_rawffi.Array('P').fromaddress(b, 1)[0], 1)
             print "comparing", a1[0], "with", a2[0]
             if a1[0] not in [1,2,3,4] or a2[0] not in [1,2,3,4]:
                 bogus_args.append((a1[0], a2[0]))
@@ -471,9 +470,9 @@
                 return 1
             return -1
         a1 = ll_to_sort.byptr()
-        a2 = _rawffi.Array('i')(1)
+        a2 = _rawffi.Array('l')(1)
         a2[0] = len(ll_to_sort)
-        a3 = _rawffi.Array('i')(1)
+        a3 = _rawffi.Array('l')(1)
         a3[0] = struct.calcsize('i')
         cb = _rawffi.CallbackPtr(compare, ['P', 'P'], 'i')
         a4 = cb.byptr()



More information about the Pypy-commit mailing list