[pypy-commit] pypy default: Merging the basic win64 changes which are without doubt into default

ctismer noreply at buildbot.pypy.org
Tue Mar 13 23:39:28 CET 2012


Author: Christian Tismer <tismer at stackless.com>
Branch: 
Changeset: r53503:dc515daf2497
Date: 2012-03-13 15:36 -0700
http://bitbucket.org/pypy/pypy/changeset/dc515daf2497/

Log:	Merging the basic win64 changes which are without doubt into default

diff --git a/pypy/rlib/rdtoa.py b/pypy/rlib/rdtoa.py
--- a/pypy/rlib/rdtoa.py
+++ b/pypy/rlib/rdtoa.py
@@ -58,8 +58,8 @@
         try:
             result = dg_strtod(ll_input, end_ptr)
 
-            endpos = (rffi.cast(rffi.LONG, end_ptr[0]) -
-                      rffi.cast(rffi.LONG, ll_input))
+            endpos = (rffi.cast(lltype.Signed, end_ptr[0]) -
+                      rffi.cast(lltype.Signed, ll_input))
 
             if endpos == 0 or endpos < len(input):
                 raise ValueError("invalid input at position %d" % (endpos,))
@@ -244,8 +244,8 @@
                     # The only failure mode is no memory
                     raise MemoryError
                 try:
-                    buflen = (rffi.cast(rffi.LONG, end_ptr[0]) -
-                              rffi.cast(rffi.LONG, digits))
+                    buflen = (rffi.cast(lltype.Signed, end_ptr[0]) -
+                              rffi.cast(lltype.Signed, digits))
                     sign = rffi.cast(lltype.Signed, sign_ptr[0])
 
                     # Handle nan and inf
diff --git a/pypy/rlib/rerased.py b/pypy/rlib/rerased.py
--- a/pypy/rlib/rerased.py
+++ b/pypy/rlib/rerased.py
@@ -24,11 +24,11 @@
 from pypy.rpython.lltypesystem.rclass import OBJECTPTR
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.error import TyperError
-
+from pypy.rlib.rarithmetic import is_valid_int
 
 
 def erase_int(x):
-    assert isinstance(x, int)
+    assert is_valid_int(x)
     res = 2 * x + 1
     if res > sys.maxint or res < -sys.maxint - 1:
         raise OverflowError
@@ -36,7 +36,7 @@
 
 def unerase_int(y):
     assert y._identity is _identity_for_ints
-    assert isinstance(y._x, int)
+    assert is_valid_int(y._x)
     return y._x
 
 
diff --git a/pypy/rlib/rwin32.py b/pypy/rlib/rwin32.py
--- a/pypy/rlib/rwin32.py
+++ b/pypy/rlib/rwin32.py
@@ -133,8 +133,8 @@
         # Prior to Visual Studio 8, the MSVCRT dll doesn't export the
         # _dosmaperr() function, which is available only when compiled
         # against the static CRT library.
-        from pypy.translator.platform import platform, Windows
-        static_platform = Windows()
+        from pypy.translator.platform import host_factory
+        static_platform = host_factory()
         if static_platform.name == 'msvc':
             static_platform.cflags = ['/MT']  # static CRT
             static_platform.version = 0       # no manifest
diff --git a/pypy/rpython/lltypesystem/llarena.py b/pypy/rpython/lltypesystem/llarena.py
--- a/pypy/rpython/lltypesystem/llarena.py
+++ b/pypy/rpython/lltypesystem/llarena.py
@@ -1,5 +1,7 @@
 import array, weakref
 from pypy.rpython.lltypesystem import llmemory
+from pypy.rlib.rarithmetic import is_valid_int
+
 
 # An "arena" is a large area of memory which can hold a number of
 # objects, not necessarily all of the same type or size.  It's used by
@@ -164,7 +166,7 @@
         return '<arenaaddr %s + %d>' % (self.arena, self.offset)
 
     def __add__(self, other):
-        if isinstance(other, (int, long)):
+        if is_valid_int(other):
             position = self.offset + other
         elif isinstance(other, llmemory.AddressOffset):
             # this is really some Do What I Mean logic.  There are two
@@ -184,7 +186,7 @@
     def __sub__(self, other):
         if isinstance(other, llmemory.AddressOffset):
             other = llmemory.raw_malloc_usage(other)
-        if isinstance(other, (int, long)):
+        if is_valid_int(other):
             return self.arena.getaddr(self.offset - other)
         if isinstance(other, fakearenaaddress):
             if self.arena is not other.arena:
diff --git a/pypy/rpython/lltypesystem/opimpl.py b/pypy/rpython/lltypesystem/opimpl.py
--- a/pypy/rpython/lltypesystem/opimpl.py
+++ b/pypy/rpython/lltypesystem/opimpl.py
@@ -4,6 +4,8 @@
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.lltypesystem.lloperation import opimpls
 from pypy.rlib import debug
+from pypy.rlib.rarithmetic import is_valid_int
+
 
 # ____________________________________________________________
 # Implementation of the 'canfold' operations
@@ -22,14 +24,14 @@
 from pypy.rpython.lltypesystem.llmemory import AddressAsInt
 
 if r_longlong is r_int:
-    r_longlong_arg = (r_longlong, int)
-    r_longlong_result = int
+    r_longlong_arg = (r_longlong, int, long)
+    r_longlong_result = long # XXX was int
 else:
     r_longlong_arg = r_longlong
     r_longlong_result = r_longlong
 
 argtype_by_name = {
-    'int': int,
+    'int': (int, long),
     'float': float,
     'uint': r_uint,
     'llong': r_longlong_arg,
@@ -173,7 +175,7 @@
 
 def op_direct_ptradd(obj, index):
     checkptr(obj)
-    assert isinstance(index, int)
+    assert is_valid_int(index)
     return lltype.direct_ptradd(obj, index)
 
 
@@ -182,29 +184,30 @@
     return not b
 
 def op_int_add(x, y):
-    if not isinstance(x, (int, llmemory.AddressOffset)):
+    if not isinstance(x, (int, long, llmemory.AddressOffset)):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, (int, llmemory.AddressOffset))
+    assert isinstance(y, (int, long, llmemory.AddressOffset))
     return intmask(x + y)
 
 def op_int_sub(x, y):
-    if not isinstance(x, int):
+    if not is_valid_int(x):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return intmask(x - y)
 
 def op_int_ge(x, y):
     # special case for 'AddressOffset >= 0'
-    assert isinstance(x, (int, llmemory.AddressOffset))
-    assert isinstance(y, int)
+    assert isinstance(x, (int, long, llmemory.AddressOffset))
+    assert is_valid_int(y)
     return x >= y
 
 def op_int_lt(x, y):
     # special case for 'AddressOffset < 0'
-    assert isinstance(x, (int, llmemory.AddressOffset))
-    assert isinstance(y, int)
+    # hack for win64
+    assert isinstance(x, (int, long, llmemory.AddressOffset))
+    assert is_valid_int(y)
     return x < y
 
 def op_int_between(a, b, c):
@@ -214,50 +217,51 @@
     return a <= b < c
 
 def op_int_and(x, y):
-    if not isinstance(x, int):
+    if not is_valid_int(x):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return x & y
 
 def op_int_or(x, y):
-    if not isinstance(x, int):
+    if not is_valid_int(x):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return x | y
 
 def op_int_xor(x, y):
     # used in computing hashes
     if isinstance(x, AddressAsInt): x = llmemory.cast_adr_to_int(x.adr)
     if isinstance(y, AddressAsInt): y = llmemory.cast_adr_to_int(y.adr)
-    assert isinstance(x, int)
-    assert isinstance(y, int)
+    assert is_valid_int(x)
+    assert is_valid_int(y)
     return x ^ y
 
 def op_int_mul(x, y):
-    assert isinstance(x, (int, llmemory.AddressOffset))
-    assert isinstance(y, (int, llmemory.AddressOffset))
+    assert isinstance(x, (int, long, llmemory.AddressOffset))
+    assert isinstance(y, (int, long, llmemory.AddressOffset))
     return intmask(x * y)
 
 def op_int_rshift(x, y):
-    if not isinstance(x, int):
+    if not is_valid_int(x):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return x >> y
 
 def op_int_floordiv(x, y):
-    assert isinstance(x, (int, llmemory.AddressOffset))
-    assert isinstance(y, (int, llmemory.AddressOffset))
+    # hack for win64
+    assert isinstance(x, (int, long, llmemory.AddressOffset))
+    assert isinstance(y, (int, long, llmemory.AddressOffset))
     r = x//y
     if x^y < 0 and x%y != 0:
         r += 1
     return r
 
 def op_int_mod(x, y):
-    assert isinstance(x, (int, llmemory.AddressOffset))
-    assert isinstance(y, (int, llmemory.AddressOffset))
+    assert isinstance(x, (int, long, llmemory.AddressOffset))
+    assert isinstance(y, (int, long, llmemory.AddressOffset))
     r = x%y
     if x^y < 0 and x%y != 0:
         r -= y
@@ -281,22 +285,22 @@
 
 def op_uint_lshift(x, y):
     assert isinstance(x, r_uint)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return r_uint(x << y)
 
 def op_uint_rshift(x, y):
     assert isinstance(x, r_uint)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return r_uint(x >> y)
 
 def op_llong_lshift(x, y):
     assert isinstance(x, r_longlong_arg)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return r_longlong_result(x << y)
 
 def op_llong_rshift(x, y):
     assert isinstance(x, r_longlong_arg)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return r_longlong_result(x >> y)
 
 def op_ullong_lshift(x, y):
@@ -306,7 +310,7 @@
 
 def op_ullong_rshift(x, y):
     assert isinstance(x, r_ulonglong)
-    assert isinstance(y, int)
+    assert is_valid_int(y)
     return r_ulonglong(x >> y)
 
 def op_same_as(x):
@@ -318,7 +322,8 @@
 op_cast_primitive.need_result_type = True
 
 def op_cast_int_to_float(i):
-    assert type(i) is int
+    # assert type(i) is int
+    assert is_valid_int(i)
     return float(i)
 
 def op_cast_uint_to_float(u):
@@ -340,7 +345,8 @@
     return ui + li
 
 def op_cast_int_to_char(b):
-    assert type(b) is int
+    #assert type(b) is int
+    assert is_valid_int(b)
     return chr(b)
 
 def op_cast_bool_to_int(b):
@@ -384,11 +390,12 @@
     return ord(b)
 
 def op_cast_int_to_unichar(b):
-    assert type(b) is int
+    assert is_valid_int(b)
     return unichr(b)
 
 def op_cast_int_to_uint(b):
-    assert type(b) is int
+    # assert type(b) is int
+    assert is_valid_int(b)
     return r_uint(b)
 
 def op_cast_uint_to_int(b):
@@ -396,7 +403,7 @@
     return intmask(b)
 
 def op_cast_int_to_longlong(b):
-    assert type(b) is int
+    assert is_valid_int(b)
     return r_longlong_result(b)
 
 def op_truncate_longlong_to_int(b):
@@ -570,7 +577,7 @@
     if isinstance(memberoffset, llgroup.GroupMemberOffset):
         return memberoffset.index != 0
     else:
-        assert isinstance(memberoffset, int)
+        assert is_valid_int(memberoffset)
         return memberoffset != 0
 
 def op_extract_ushort(combinedoffset):
diff --git a/pypy/rpython/lltypesystem/test/test_llmemory.py b/pypy/rpython/lltypesystem/test/test_llmemory.py
--- a/pypy/rpython/lltypesystem/test/test_llmemory.py
+++ b/pypy/rpython/lltypesystem/test/test_llmemory.py
@@ -1,6 +1,7 @@
 from pypy.rpython.lltypesystem.llmemory import *
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.test.test_llinterp import interpret
+from pypy.rlib.rarithmetic import is_valid_int
 import py
 
 def test_simple():
@@ -639,12 +640,12 @@
     assert cast_int_to_adr(0) == NULL
     #
     i = cast_adr_to_int(adr, mode="emulated")
-    assert type(i) is int
+    assert is_valid_int(i)
     i = cast_adr_to_int(NULL, mode="emulated")
-    assert type(i) is int and i == 0
+    assert is_valid_int(i) and i == 0
     #
     i = cast_adr_to_int(adr, mode="forced")
-    assert type(i) is int
+    assert is_valid_int(i)
     #assert cast_int_to_adr(i) == adr -- depends on ll2ctypes details
     i = cast_adr_to_int(NULL, mode="forced")
-    assert type(i) is int and i == 0
+    assert is_valid_int(i) and i == 0
diff --git a/pypy/rpython/memory/gc/inspector.py b/pypy/rpython/memory/gc/inspector.py
--- a/pypy/rpython/memory/gc/inspector.py
+++ b/pypy/rpython/memory/gc/inspector.py
@@ -109,7 +109,7 @@
         self.gc = gc
         self.gcflag = gc.gcflag_extra
         self.fd = rffi.cast(rffi.INT, fd)
-        self.writebuffer = lltype.malloc(rffi.LONGP.TO, self.BUFSIZE,
+        self.writebuffer = lltype.malloc(rffi.SIGNEDP.TO, self.BUFSIZE,
                                          flavor='raw')
         self.buf_count = 0
         if self.gcflag == 0:
diff --git a/pypy/rpython/memory/gc/markcompact.py b/pypy/rpython/memory/gc/markcompact.py
--- a/pypy/rpython/memory/gc/markcompact.py
+++ b/pypy/rpython/memory/gc/markcompact.py
@@ -11,6 +11,8 @@
 from pypy.rlib.objectmodel import we_are_translated, running_on_llinterp
 from pypy.rpython.lltypesystem import rffi
 from pypy.rpython.memory.gcheader import GCHeaderBuilder
+from pypy.rlib.rarithmetic import is_valid_int
+
 
 # Mark'n'compact garbage collector
 #
@@ -353,7 +355,7 @@
         # like header(), but asserts that we have a forwarding header
         hdr = MovingGCBase.header(self, addr)
         if not we_are_translated():
-            assert isinstance(hdr.tid, int)
+            assert is_valid_int(hdr.tid)
         return hdr
 
     def combine(self, typeid16, flags):
diff --git a/pypy/rpython/memory/lltypelayout.py b/pypy/rpython/memory/lltypelayout.py
--- a/pypy/rpython/memory/lltypelayout.py
+++ b/pypy/rpython/memory/lltypelayout.py
@@ -1,4 +1,5 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, llarena
+from pypy.rlib.rarithmetic import is_emulated_long
 
 import struct
 
@@ -12,7 +13,11 @@
                     lltype.Float:           "d",
                     llmemory.Address:       "P",
                     }
-
+if is_emulated_long:
+    primitive_to_fmt.update( {
+        lltype.Signed:     "q",
+        lltype.Unsigned:   "Q",
+        } )
 
 #___________________________________________________________________________
 # Utility functions that know about the memory layout of the lltypes
diff --git a/pypy/rpython/memory/test/test_transformed_gc.py b/pypy/rpython/memory/test/test_transformed_gc.py
--- a/pypy/rpython/memory/test/test_transformed_gc.py
+++ b/pypy/rpython/memory/test/test_transformed_gc.py
@@ -737,7 +737,7 @@
         def f():
             from pypy.rpython.lltypesystem import rffi
             alist = [A() for i in range(50)]
-            idarray = lltype.malloc(rffi.LONGP.TO, len(alist), flavor='raw')
+            idarray = lltype.malloc(rffi.SIGNEDP.TO, len(alist), flavor='raw')
             # Compute the id of all the elements of the list.  The goal is
             # to not allocate memory, so that if the GC needs memory to
             # remember the ids, it will trigger some collections itself
diff --git a/pypy/rpython/module/ll_os_stat.py b/pypy/rpython/module/ll_os_stat.py
--- a/pypy/rpython/module/ll_os_stat.py
+++ b/pypy/rpython/module/ll_os_stat.py
@@ -319,6 +319,7 @@
 
     def attributes_to_mode(attributes):
         m = 0
+        attributes = intmask(attributes)
         if attributes & win32traits.FILE_ATTRIBUTE_DIRECTORY:
             m |= win32traits._S_IFDIR | 0111 # IFEXEC for user,group,other
         else:
diff --git a/pypy/rpython/module/test/test_ll_os.py b/pypy/rpython/module/test/test_ll_os.py
--- a/pypy/rpython/module/test/test_ll_os.py
+++ b/pypy/rpython/module/test/test_ll_os.py
@@ -80,8 +80,12 @@
         pwd = os.getcwd()
         import ctypes
         buf = ctypes.create_string_buffer(1000)
-        ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], buf, 1000)
-        assert str(buf.value) == pwd
+        len = ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], buf, 1000)
+        if (len == 0) and "WINGDB_PYTHON" in os.environ:
+            # the ctypes call seems not to work in the Wing debugger
+            return
+        assert str(buf.value).lower() == pwd
+        # ctypes returns the drive letter in uppercase, os.getcwd does not
 
     pwd = os.getcwd()
     try:
diff --git a/pypy/rpython/module/test/test_ll_os_stat.py b/pypy/rpython/module/test/test_ll_os_stat.py
--- a/pypy/rpython/module/test/test_ll_os_stat.py
+++ b/pypy/rpython/module/test/test_ll_os_stat.py
@@ -26,7 +26,7 @@
             assert wstat(unicode(f)).st_mtime == expected
 
         check('c:/')
-        check('c:/temp')
+        check(os.environ['TEMP'])
         check('c:/pagefile.sys')
 
     def test_fstat(self):
diff --git a/pypy/rpython/module/test/test_posix.py b/pypy/rpython/module/test/test_posix.py
--- a/pypy/rpython/module/test/test_posix.py
+++ b/pypy/rpython/module/test/test_posix.py
@@ -1,6 +1,8 @@
 import py
 from pypy.rpython.test.tool import BaseRtypingTest, LLRtypeMixin, OORtypeMixin
 from pypy.tool.udir import udir
+from pypy.rlib.rarithmetic import is_valid_int
+
 import os
 exec 'import %s as posix' % os.name
 
@@ -18,10 +20,10 @@
 
     def test_open(self):
         def f():
-            ff = posix.open(path,posix.O_RDONLY,0777)
+            ff = posix.open(path, posix.O_RDONLY, 0777)
             return ff
-        func = self.interpret(f,[])
-        assert type(func) == int
+        func = self.interpret(f, [])
+        assert is_valid_int(func)
 
     def test_fstat(self):
         def fo(fi):
@@ -61,25 +63,25 @@
         assert isinstance(times, tuple)
         assert len(times) == 5
         for value in times:
-            assert isinstance(value, int)
+            assert is_valid_int(value)
 
 
     def test_lseek(self):
-        def f(fi,pos):
-            posix.lseek(fi,pos,0)
-        fi = os.open(path,os.O_RDONLY,0777)
-        func = self.interpret(f,[fi,5]) 
-        res = os.read(fi,2)
+        def f(fi, pos):
+            posix.lseek(fi, pos, 0)
+        fi = os.open(path, os.O_RDONLY, 0777)
+        func = self.interpret(f, [fi, 5]) 
+        res = os.read(fi, 2)
         assert res =='is'
 
     def test_isatty(self):
         def f(fi):
             posix.isatty(fi)
-        fi = os.open(path,os.O_RDONLY,0777)
-        func = self.interpret(f,[fi])
+        fi = os.open(path, os.O_RDONLY, 0777)
+        func = self.interpret(f, [fi])
         assert not func
         os.close(fi)
-        func = self.interpret(f,[fi])
+        func = self.interpret(f, [fi])
         assert not func
 
     def test_getcwd(self):


More information about the pypy-commit mailing list