[pypy-commit] pypy win64-stage1: Merge with default

ctismer noreply at buildbot.pypy.org
Mon Nov 21 19:03:47 CET 2011


Author: Christian Tismer <tismer at stackless.com>
Branch: win64-stage1
Changeset: r49636:44db5b5f850f
Date: 2011-11-21 16:32 +0100
http://bitbucket.org/pypy/pypy/changeset/44db5b5f850f/

Log:	Merge with default

diff --git a/.hgtags b/.hgtags
--- a/.hgtags
+++ b/.hgtags
@@ -1,3 +1,4 @@
 b590cf6de4190623aad9aa698694c22e614d67b9 release-1.5
 b48df0bf4e75b81d98f19ce89d4a7dc3e1dab5e5 benchmarked
 d8ac7d23d3ec5f9a0fa1264972f74a010dbfd07f release-1.6
+ff4af8f318821f7f5ca998613a60fca09aa137da release-1.7
diff --git a/lib_pypy/pyrepl/unix_console.py b/lib_pypy/pyrepl/unix_console.py
--- a/lib_pypy/pyrepl/unix_console.py
+++ b/lib_pypy/pyrepl/unix_console.py
@@ -412,7 +412,12 @@
                    e.args[4] == 'unexpected end of data':
                 pass
             else:
-                raise
+                # was: "raise".  But it crashes pyrepl, and by extension the
+                # pypy currently running, in which we are e.g. in the middle
+                # of some debugging session.  Argh.  Instead just print an
+                # error message to stderr and continue running, for now.
+                self.partial_char = ''
+                sys.stderr.write('\n%s: %s\n' % (e.__class__.__name__, e))
         else:
             self.partial_char = ''
             self.event_queue.push(c)
diff --git a/lib_pypy/syslog.py b/lib_pypy/syslog.py
--- a/lib_pypy/syslog.py
+++ b/lib_pypy/syslog.py
@@ -38,9 +38,27 @@
 _setlogmask.argtypes = (c_int,)
 _setlogmask.restype = c_int
 
+_S_log_open = False
+_S_ident_o = None
+
+def _get_argv():
+    try:
+        import sys
+        script = sys.argv[0]
+        if isinstance(script, str):
+            return script[script.rfind('/')+1:] or None
+    except Exception:
+        pass
+    return None
+
 @builtinify
-def openlog(ident, option, facility):
-    _openlog(ident, option, facility)
+def openlog(ident=None, logoption=0, facility=LOG_USER):
+    global _S_ident_o, _S_log_open
+    if ident is None:
+        ident = _get_argv()
+    _S_ident_o = c_char_p(ident)    # keepalive
+    _openlog(_S_ident_o, logoption, facility)
+    _S_log_open = True
 
 @builtinify
 def syslog(arg1, arg2=None):
@@ -48,11 +66,18 @@
         priority, message = arg1, arg2
     else:
         priority, message = LOG_INFO, arg1
+    # if log is not opened, open it now
+    if not _S_log_open:
+        openlog()
     _syslog(priority, "%s", message)
 
 @builtinify
 def closelog():
-    _closelog()
+    global _S_log_open, S_ident_o
+    if _S_log_open:
+        _closelog()
+        _S_log_open = False
+        _S_ident_o = None
 
 @builtinify
 def setlogmask(mask):
diff --git a/pypy/doc/coding-guide.rst b/pypy/doc/coding-guide.rst
--- a/pypy/doc/coding-guide.rst
+++ b/pypy/doc/coding-guide.rst
@@ -270,7 +270,12 @@
   - *slicing*:
     the slice start must be within bounds. The stop doesn't need to, but it must
     not be smaller than the start.  All negative indexes are disallowed, except for
-    the [:-1] special case.  No step.
+    the [:-1] special case.  No step.  Slice deletion follows the same rules.
+    
+  - *slice assignment*:
+    only supports ``lst[x:y] = sublist``, if ``len(sublist) == y - x``.
+    In other words, slice assignment cannot change the total length of the list,
+    but just replace items.
 
   - *other operators*:
     ``+``, ``+=``, ``in``, ``*``, ``*=``, ``==``, ``!=`` work as expected.
diff --git a/pypy/doc/how-to-release.rst b/pypy/doc/how-to-release.rst
--- a/pypy/doc/how-to-release.rst
+++ b/pypy/doc/how-to-release.rst
@@ -1,6 +1,3 @@
-.. include:: needswork.txt
-
-.. needs work, it talks about svn. also, it is not really user documentation
 
 Making a PyPy Release
 =======================
@@ -12,11 +9,8 @@
 forgetting things. A set of todo files may also work.
 
 Check and prioritize all issues for the release, postpone some if necessary,
-create new  issues also as necessary. A meeting (or meetings) should be
-organized to decide what things are priorities, should go in and work for
-the release. 
-
-An important thing is to get the documentation into an up-to-date state!
+create new  issues also as necessary. An important thing is to get
+the documentation into an up-to-date state!
 
 Release Steps
 ----------------
diff --git a/pypy/doc/project-ideas.rst b/pypy/doc/project-ideas.rst
--- a/pypy/doc/project-ideas.rst
+++ b/pypy/doc/project-ideas.rst
@@ -26,14 +26,11 @@
 Numpy improvements
 ------------------
 
-This is more of a project-container than a single project. Possible ideas:
+The numpy is rapidly progressing in pypy, so feel free to come to IRC and
+ask for proposed topic. A not necesarilly up-to-date `list of topics`_
+is also available.
 
-* experiment with auto-vectorization using SSE or implement vectorization
-  without automatically detecting it for array operations.
-
-* improve numpy, for example implement memory views.
-
-* interface with fortran/C libraries.
+.. _`list of topics`: https://bitbucket.org/pypy/extradoc/src/extradoc/planning/micronumpy.txt
 
 Improving the jitviewer
 ------------------------
diff --git a/pypy/jit/backend/conftest.py b/pypy/jit/backend/conftest.py
--- a/pypy/jit/backend/conftest.py
+++ b/pypy/jit/backend/conftest.py
@@ -12,7 +12,7 @@
                     help="choose a fixed random seed")
     group.addoption('--backend', action="store",
                     default='llgraph',
-                    choices=['llgraph', 'x86'],
+                    choices=['llgraph', 'cpu'],
                     dest="backend",
                     help="select the backend to run the functions with")
     group.addoption('--block-length', action="store", type="int",
diff --git a/pypy/jit/backend/llgraph/llimpl.py b/pypy/jit/backend/llgraph/llimpl.py
--- a/pypy/jit/backend/llgraph/llimpl.py
+++ b/pypy/jit/backend/llgraph/llimpl.py
@@ -20,6 +20,7 @@
 from pypy.jit.backend.llgraph import symbolic
 from pypy.jit.codewriter import longlong
 
+from pypy.rlib import libffi
 from pypy.rlib.objectmodel import ComputedIntSymbolic, we_are_translated
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.rlib.rarithmetic import r_longlong, r_ulonglong, r_uint
@@ -325,12 +326,12 @@
     loop = _from_opaque(loop)
     loop.operations.append(Operation(opnum))
 
-def compile_add_descr(loop, ofs, type, arg_types):
+def compile_add_descr(loop, ofs, type, arg_types, extrainfo, width):
     from pypy.jit.backend.llgraph.runner import Descr
     loop = _from_opaque(loop)
     op = loop.operations[-1]
     assert isinstance(type, str) and len(type) == 1
-    op.descr = Descr(ofs, type, arg_types=arg_types)
+    op.descr = Descr(ofs, type, arg_types=arg_types, extrainfo=extrainfo, width=width)
 
 def compile_add_descr_arg(loop, ofs, type, arg_types):
     from pypy.jit.backend.llgraph.runner import Descr
@@ -825,6 +826,16 @@
         else:
             raise NotImplementedError
 
+    def op_getinteriorfield_raw(self, descr, array, index):
+        if descr.typeinfo == REF:
+            return do_getinteriorfield_raw_ptr(array, index, descr.width, descr.ofs)
+        elif descr.typeinfo == INT:
+            return do_getinteriorfield_raw_int(array, index, descr.width, descr.ofs)
+        elif descr.typeinfo == FLOAT:
+            return do_getinteriorfield_raw_float(array, index, descr.width, descr.ofs)
+        else:
+            raise NotImplementedError
+
     def op_setinteriorfield_gc(self, descr, array, index, newvalue):
         if descr.typeinfo == REF:
             return do_setinteriorfield_gc_ptr(array, index, descr.ofs,
@@ -838,6 +849,16 @@
         else:
             raise NotImplementedError
 
+    def op_setinteriorfield_raw(self, descr, array, index, newvalue):
+        if descr.typeinfo == REF:
+            return do_setinteriorfield_raw_ptr(array, index, newvalue, descr.width, descr.ofs)
+        elif descr.typeinfo == INT:
+            return do_setinteriorfield_raw_int(array, index, newvalue, descr.width, descr.ofs)
+        elif descr.typeinfo == FLOAT:
+            return do_setinteriorfield_raw_float(array, index, newvalue, descr.width, descr.ofs)
+        else:
+            raise NotImplementedError
+
     def op_setfield_gc(self, fielddescr, struct, newvalue):
         if fielddescr.typeinfo == REF:
             do_setfield_gc_ptr(struct, fielddescr.ofs, newvalue)
@@ -1403,6 +1424,14 @@
     struct = array._obj.container.getitem(index)
     return cast_to_ptr(_getinteriorfield_gc(struct, fieldnum))
 
+def _getinteriorfield_raw(ffitype, array, index, width, ofs):
+    addr = rffi.cast(rffi.VOIDP, array)
+    return libffi.array_getitem(ffitype, width, addr, index, ofs)
+
+def do_getinteriorfield_raw_int(array, index, width, ofs):
+    res = _getinteriorfield_raw(libffi.types.slong, array, index, width, ofs)
+    return res
+
 def _getfield_raw(struct, fieldnum):
     STRUCT, fieldname = symbolic.TokenToField[fieldnum]
     ptr = cast_from_int(lltype.Ptr(STRUCT), struct)
@@ -1479,7 +1508,14 @@
     return do_setinteriorfield_gc
 do_setinteriorfield_gc_int = new_setinteriorfield_gc(cast_from_int)
 do_setinteriorfield_gc_float = new_setinteriorfield_gc(cast_from_floatstorage)
-do_setinteriorfield_gc_ptr = new_setinteriorfield_gc(cast_from_ptr)        
+do_setinteriorfield_gc_ptr = new_setinteriorfield_gc(cast_from_ptr)
+
+def new_setinteriorfield_raw(ffitype):
+    def do_setinteriorfield_raw(array, index, newvalue, width, ofs):
+        addr = rffi.cast(rffi.VOIDP, array)
+        return libffi.array_setitem(ffitype, width, addr, index, ofs, newvalue)
+    return do_setinteriorfield_raw
+do_setinteriorfield_raw_int = new_setinteriorfield_raw(libffi.types.slong)
 
 def do_setfield_raw_int(struct, fieldnum, newvalue):
     STRUCT, fieldname = symbolic.TokenToField[fieldnum]
diff --git a/pypy/jit/backend/llgraph/runner.py b/pypy/jit/backend/llgraph/runner.py
--- a/pypy/jit/backend/llgraph/runner.py
+++ b/pypy/jit/backend/llgraph/runner.py
@@ -23,8 +23,10 @@
 class Descr(history.AbstractDescr):
 
     def __init__(self, ofs, typeinfo, extrainfo=None, name=None,
-                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0):
+                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0, width=-1):
+
         self.ofs = ofs
+        self.width = width
         self.typeinfo = typeinfo
         self.extrainfo = extrainfo
         self.name = name
@@ -119,14 +121,14 @@
         return False
 
     def getdescr(self, ofs, typeinfo='?', extrainfo=None, name=None,
-                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0):
+                 arg_types=None, count_fields_if_immut=-1, ffi_flags=0, width=-1):
         key = (ofs, typeinfo, extrainfo, name, arg_types,
-               count_fields_if_immut, ffi_flags)
+               count_fields_if_immut, ffi_flags, width)
         try:
             return self._descrs[key]
         except KeyError:
             descr = Descr(ofs, typeinfo, extrainfo, name, arg_types,
-                          count_fields_if_immut, ffi_flags)
+                          count_fields_if_immut, ffi_flags, width)
             self._descrs[key] = descr
             return descr
 
@@ -179,7 +181,8 @@
             descr = op.getdescr()
             if isinstance(descr, Descr):
                 llimpl.compile_add_descr(c, descr.ofs, descr.typeinfo,
-                                         descr.arg_types)
+                                         descr.arg_types, descr.extrainfo,
+                                         descr.width)
             if (isinstance(descr, history.LoopToken) and
                 op.getopnum() != rop.JUMP):
                 llimpl.compile_add_loop_token(c, descr)
@@ -324,10 +327,22 @@
 
     def interiorfielddescrof(self, A, fieldname):
         S = A.OF
-        ofs2 = symbolic.get_size(A)
+        width = symbolic.get_size(A)
         ofs, size = symbolic.get_field_token(S, fieldname)
         token = history.getkind(getattr(S, fieldname))
-        return self.getdescr(ofs, token[0], name=fieldname, extrainfo=ofs2)
+        return self.getdescr(ofs, token[0], name=fieldname, width=width)
+
+    def interiorfielddescrof_dynamic(self, offset, width, fieldsize,
+        is_pointer, is_float, is_signed):
+
+        if is_pointer:
+            typeinfo = REF
+        elif is_float:
+            typeinfo = FLOAT
+        else:
+            typeinfo = INT
+        # we abuse the arg_types field to distinguish dynamic and static descrs
+        return Descr(offset, typeinfo, arg_types='dynamic', name='<dynamic interior field>', width=width)
 
     def calldescrof(self, FUNC, ARGS, RESULT, extrainfo):
         arg_types = []
diff --git a/pypy/jit/backend/llsupport/descr.py b/pypy/jit/backend/llsupport/descr.py
--- a/pypy/jit/backend/llsupport/descr.py
+++ b/pypy/jit/backend/llsupport/descr.py
@@ -111,6 +111,16 @@
     def repr_of_descr(self):
         return '<%s %s %s>' % (self._clsname, self.name, self.offset)
 
+class DynamicFieldDescr(BaseFieldDescr):
+    def __init__(self, offset, fieldsize, is_pointer, is_float, is_signed):
+        self.offset = offset
+        self._fieldsize = fieldsize
+        self._is_pointer_field = is_pointer
+        self._is_float_field = is_float
+        self._is_field_signed = is_signed
+
+    def get_field_size(self, translate_support_code):
+        return self._fieldsize
 
 class NonGcPtrFieldDescr(BaseFieldDescr):
     _clsname = 'NonGcPtrFieldDescr'
@@ -182,6 +192,7 @@
     def repr_of_descr(self):
         return '<%s>' % self._clsname
 
+
 class NonGcPtrArrayDescr(BaseArrayDescr):
     _clsname = 'NonGcPtrArrayDescr'
     def get_item_size(self, translate_support_code):
@@ -211,6 +222,13 @@
     def get_ofs_length(self, translate_support_code):
         return -1
 
+class DynamicArrayNoLengthDescr(BaseArrayNoLengthDescr):
+    def __init__(self, itemsize):
+        self.itemsize = itemsize
+
+    def get_item_size(self, translate_support_code):
+        return self.itemsize
+
 class NonGcPtrArrayNoLengthDescr(BaseArrayNoLengthDescr):
     _clsname = 'NonGcPtrArrayNoLengthDescr'
     def get_item_size(self, translate_support_code):
diff --git a/pypy/jit/backend/llsupport/llmodel.py b/pypy/jit/backend/llsupport/llmodel.py
--- a/pypy/jit/backend/llsupport/llmodel.py
+++ b/pypy/jit/backend/llsupport/llmodel.py
@@ -9,9 +9,10 @@
 from pypy.jit.backend.llsupport import symbolic
 from pypy.jit.backend.llsupport.symbolic import WORD, unroll_basic_sizes
 from pypy.jit.backend.llsupport.descr import (get_size_descr,
-     get_field_descr, BaseFieldDescr, get_array_descr, BaseArrayDescr,
-     get_call_descr, BaseIntCallDescr, GcPtrCallDescr, FloatCallDescr,
-     VoidCallDescr, InteriorFieldDescr, get_interiorfield_descr)
+     get_field_descr, BaseFieldDescr, DynamicFieldDescr, get_array_descr,
+     BaseArrayDescr, DynamicArrayNoLengthDescr, get_call_descr,
+     BaseIntCallDescr, GcPtrCallDescr, FloatCallDescr, VoidCallDescr,
+     InteriorFieldDescr, get_interiorfield_descr)
 from pypy.jit.backend.llsupport.asmmemmgr import AsmMemoryManager
 
 
@@ -238,6 +239,12 @@
     def interiorfielddescrof(self, A, fieldname):
         return get_interiorfield_descr(self.gc_ll_descr, A, A.OF, fieldname)
 
+    def interiorfielddescrof_dynamic(self, offset, width, fieldsize,
+        is_pointer, is_float, is_signed):
+        arraydescr = DynamicArrayNoLengthDescr(width)
+        fielddescr = DynamicFieldDescr(offset, fieldsize, is_pointer, is_float, is_signed)
+        return InteriorFieldDescr(arraydescr, fielddescr)
+
     def unpack_arraydescr(self, arraydescr):
         assert isinstance(arraydescr, BaseArrayDescr)
         return arraydescr.get_base_size(self.translate_support_code)
diff --git a/pypy/jit/backend/llsupport/test/test_gc.py b/pypy/jit/backend/llsupport/test/test_gc.py
--- a/pypy/jit/backend/llsupport/test/test_gc.py
+++ b/pypy/jit/backend/llsupport/test/test_gc.py
@@ -101,7 +101,7 @@
         gcrootmap.put(retaddr, shapeaddr)
         assert gcrootmap._gcmap[0] == retaddr
         assert gcrootmap._gcmap[1] == shapeaddr
-        p = rffi.cast(rffi.SIGNEDP, gcrootmap.gcmapstart())
+        p = rffi.cast(rffi.LONGP, gcrootmap.gcmapstart())
         assert p[0] == retaddr
         assert (gcrootmap.gcmapend() ==
                 gcrootmap.gcmapstart() + rffi.sizeof(lltype.Signed) * 2)
diff --git a/pypy/jit/backend/model.py b/pypy/jit/backend/model.py
--- a/pypy/jit/backend/model.py
+++ b/pypy/jit/backend/model.py
@@ -183,38 +183,35 @@
             lst[n] = None
         self.fail_descr_free_list.extend(faildescr_indices)
 
-    @staticmethod
-    def sizeof(S):
+    def sizeof(self, S):
         raise NotImplementedError
 
-    @staticmethod
-    def fielddescrof(S, fieldname):
+    def fielddescrof(self, S, fieldname):
         """Return the Descr corresponding to field 'fieldname' on the
         structure 'S'.  It is important that this function (at least)
         caches the results."""
         raise NotImplementedError
 
-    @staticmethod
-    def arraydescrof(A):
+    def interiorfielddescrof(self, A, fieldname):
         raise NotImplementedError
 
-    @staticmethod
-    def calldescrof(FUNC, ARGS, RESULT):
+    def interiorfielddescrof_dynamic(self, offset, width, fieldsize, is_pointer,
+        is_float, is_signed):
+        raise NotImplementedError
+
+    def arraydescrof(self, A):
+        raise NotImplementedError
+
+    def calldescrof(self, FUNC, ARGS, RESULT):
         # FUNC is the original function type, but ARGS is a list of types
         # with Voids removed
         raise NotImplementedError
 
-    @staticmethod
-    def methdescrof(SELFTYPE, methname):
+    def methdescrof(self, SELFTYPE, methname):
         # must return a subclass of history.AbstractMethDescr
         raise NotImplementedError
 
-    @staticmethod
-    def typedescrof(TYPE):
-        raise NotImplementedError
-
-    @staticmethod
-    def interiorfielddescrof(A, fieldname):
+    def typedescrof(self, TYPE):
         raise NotImplementedError
 
     # ---------- the backend-dependent operations ----------
diff --git a/pypy/jit/backend/test/test_random.py b/pypy/jit/backend/test/test_random.py
--- a/pypy/jit/backend/test/test_random.py
+++ b/pypy/jit/backend/test/test_random.py
@@ -495,9 +495,9 @@
     if pytest.config.option.backend == 'llgraph':
         from pypy.jit.backend.llgraph.runner import LLtypeCPU
         return LLtypeCPU(None)
-    elif pytest.config.option.backend == 'x86':
-        from pypy.jit.backend.x86.runner import CPU386
-        return CPU386(None, None)
+    elif pytest.config.option.backend == 'cpu':
+        from pypy.jit.backend.detect_cpu import getcpuclass
+        return getcpuclass()(None, None)
     else:
         assert 0, "unknown backend %r" % pytest.config.option.backend
 
diff --git a/pypy/jit/backend/x86/assembler.py b/pypy/jit/backend/x86/assembler.py
--- a/pypy/jit/backend/x86/assembler.py
+++ b/pypy/jit/backend/x86/assembler.py
@@ -8,8 +8,8 @@
 from pypy.rpython.lltypesystem.lloperation import llop
 from pypy.rpython.annlowlevel import llhelper
 from pypy.jit.backend.model import CompiledLoopToken
-from pypy.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs,
-                                           _get_scale, gpr_reg_mgr_cls)
+from pypy.jit.backend.x86.regalloc import (RegAlloc, get_ebp_ofs, _get_scale,
+    gpr_reg_mgr_cls, _valid_addressing_size)
 
 from pypy.jit.backend.x86.arch import (FRAME_FIXED_SIZE, FORCE_INDEX_OFS, WORD,
                                        IS_X86_32, IS_X86_64)
@@ -403,7 +403,7 @@
             after()
 
     _NOARG_FUNC = lltype.Ptr(lltype.FuncType([], lltype.Void))
-    _CLOSESTACK_FUNC = lltype.Ptr(lltype.FuncType([rffi.SIGNEDP],
+    _CLOSESTACK_FUNC = lltype.Ptr(lltype.FuncType([rffi.LONGP],
                                                   lltype.Void))
 
     def _build_release_gil(self, gcrootmap):
@@ -1601,8 +1601,10 @@
         assert isinstance(itemsize_loc, ImmedLoc)
         if isinstance(index_loc, ImmedLoc):
             temp_loc = imm(index_loc.value * itemsize_loc.value)
+        elif _valid_addressing_size(itemsize_loc.value):
+            return AddressLoc(base_loc, index_loc, _get_scale(itemsize_loc.value), ofs_loc.value)
         else:
-            # XXX should not use IMUL in most cases
+            # XXX should not use IMUL in more cases, it can use a clever LEA
             assert isinstance(temp_loc, RegLoc)
             assert isinstance(index_loc, RegLoc)
             assert not temp_loc.is_xmm
@@ -1619,6 +1621,8 @@
                                                 ofs_loc)
         self.load_from_mem(resloc, src_addr, fieldsize_loc, sign_loc)
 
+    genop_getinteriorfield_raw = genop_getinteriorfield_gc
+
 
     def genop_discard_setfield_gc(self, op, arglocs):
         base_loc, ofs_loc, size_loc, value_loc = arglocs
@@ -1634,6 +1638,8 @@
                                                  ofs_loc)
         self.save_into_mem(dest_addr, value_loc, fieldsize_loc)
 
+    genop_discard_setinteriorfield_raw = genop_discard_setinteriorfield_gc
+
     def genop_discard_setarrayitem_gc(self, op, arglocs):
         base_loc, ofs_loc, value_loc, size_loc, baseofs = arglocs
         assert isinstance(baseofs, ImmedLoc)
@@ -1974,10 +1980,10 @@
                 kind = code & 3
                 code = (code - self.CODE_FROMSTACK) >> 2
                 stackloc = frame_addr + get_ebp_ofs(code)
-                value = rffi.cast(rffi.SIGNEDP, stackloc)[0]
+                value = rffi.cast(rffi.LONGP, stackloc)[0]
                 if kind == self.DESCR_FLOAT and WORD == 4:
                     value_hi = value
-                    value = rffi.cast(rffi.SIGNEDP, stackloc - 4)[0]
+                    value = rffi.cast(rffi.LONGP, stackloc - 4)[0]
             else:
                 # 'code' identifies a register: load its value
                 kind = code & 3
@@ -2005,10 +2011,10 @@
             elif kind == self.DESCR_FLOAT:
                 tgt = self.fail_boxes_float.get_addr_for_num(num)
                 if WORD == 4:
-                    rffi.cast(rffi.SIGNEDP, tgt)[1] = value_hi
+                    rffi.cast(rffi.LONGP, tgt)[1] = value_hi
             else:
                 assert 0, "bogus kind"
-            rffi.cast(rffi.SIGNEDP, tgt)[0] = value
+            rffi.cast(rffi.LONGP, tgt)[0] = value
             num += 1
         #
         if not we_are_translated():
@@ -2034,7 +2040,7 @@
         self.failure_recovery_func = failure_recovery_func
         self.failure_recovery_code = [0, 0, 0, 0]
 
-    _FAILURE_RECOVERY_FUNC = lltype.Ptr(lltype.FuncType([rffi.SIGNEDP],
+    _FAILURE_RECOVERY_FUNC = lltype.Ptr(lltype.FuncType([rffi.LONGP],
                                                         lltype.Signed))
 
     def _build_failure_recovery(self, exc, withfloats=False):
diff --git a/pypy/jit/backend/x86/codebuf.py b/pypy/jit/backend/x86/codebuf.py
--- a/pypy/jit/backend/x86/codebuf.py
+++ b/pypy/jit/backend/x86/codebuf.py
@@ -48,7 +48,7 @@
         if self.relocations is not None:
             for reloc in self.relocations:
                 p = addr + reloc
-                adr = rffi.cast(rffi.SIGNEDP, p - WORD)
+                adr = rffi.cast(rffi.LONGP, p - WORD)
                 adr[0] = intmask(adr[0] - p)
         valgrind.discard_translations(addr, self.get_relative_pos())
         self._dump(addr, "jit-backend-dump", backend_name)
diff --git a/pypy/jit/backend/x86/regalloc.py b/pypy/jit/backend/x86/regalloc.py
--- a/pypy/jit/backend/x86/regalloc.py
+++ b/pypy/jit/backend/x86/regalloc.py
@@ -1067,6 +1067,8 @@
         self.PerformDiscard(op, [base_loc, ofs, itemsize, fieldsize,
                                  index_loc, temp_loc, value_loc])
 
+    consider_setinteriorfield_raw = consider_setinteriorfield_gc
+
     def consider_strsetitem(self, op):
         args = op.getarglist()
         base_loc = self.rm.make_sure_var_in_reg(op.getarg(0), args)
@@ -1158,6 +1160,8 @@
         self.Perform(op, [base_loc, ofs, itemsize, fieldsize,
                           index_loc, temp_loc, sign_loc], result_loc)
 
+    consider_getinteriorfield_raw = consider_getinteriorfield_gc
+
     def consider_int_is_true(self, op, guard_op):
         # doesn't need arg to be in a register
         argloc = self.loc(op.getarg(0))
@@ -1430,8 +1434,11 @@
     # i.e. the n'th word beyond the fixed frame size.
     return -WORD * (FRAME_FIXED_SIZE + position)
 
+def _valid_addressing_size(size):
+    return size == 1 or size == 2 or size == 4 or size == 8
+
 def _get_scale(size):
-    assert size == 1 or size == 2 or size == 4 or size == 8
+    assert _valid_addressing_size(size)
     if size < 4:
         return size - 1         # 1, 2 => 0, 1
     else:
diff --git a/pypy/jit/backend/x86/runner.py b/pypy/jit/backend/x86/runner.py
--- a/pypy/jit/backend/x86/runner.py
+++ b/pypy/jit/backend/x86/runner.py
@@ -150,7 +150,7 @@
     cast_ptr_to_int._annspecialcase_ = 'specialize:arglltype(0)'
     cast_ptr_to_int = staticmethod(cast_ptr_to_int)
 
-    all_null_registers = lltype.malloc(rffi.SIGNEDP.TO, 24,
+    all_null_registers = lltype.malloc(rffi.LONGP.TO, 24,
                                        flavor='raw', zero=True,
                                        immortal=True)
 
diff --git a/pypy/jit/backend/x86/test/test_assembler.py b/pypy/jit/backend/x86/test/test_assembler.py
--- a/pypy/jit/backend/x86/test/test_assembler.py
+++ b/pypy/jit/backend/x86/test/test_assembler.py
@@ -101,7 +101,7 @@
         assert withfloats
         value = random.random() - 0.5
         # make sure it fits into 64 bits
-        tmp = lltype.malloc(rffi.SIGNEDP.TO, 2, flavor='raw',
+        tmp = lltype.malloc(rffi.LONGP.TO, 2, flavor='raw',
                             track_allocation=False)
         rffi.cast(rffi.DOUBLEP, tmp)[0] = value
         return rffi.cast(rffi.DOUBLEP, tmp)[0], tmp[0], tmp[1]
@@ -139,11 +139,11 @@
 
     # prepare the expected target arrays, the descr_bytecode,
     # the 'registers' and the 'stack' arrays according to 'content'
-    xmmregisters = lltype.malloc(rffi.SIGNEDP.TO, 16+ACTUAL_CPU.NUM_REGS+1,
+    xmmregisters = lltype.malloc(rffi.LONGP.TO, 16+ACTUAL_CPU.NUM_REGS+1,
                                  flavor='raw', immortal=True)
     registers = rffi.ptradd(xmmregisters, 16)
     stacklen = baseloc + 30
-    stack = lltype.malloc(rffi.SIGNEDP.TO, stacklen, flavor='raw',
+    stack = lltype.malloc(rffi.LONGP.TO, stacklen, flavor='raw',
                           immortal=True)
     expected_ints = [0] * len(content)
     expected_ptrs = [lltype.nullptr(llmemory.GCREF.TO)] * len(content)
diff --git a/pypy/jit/backend/x86/test/test_ztranslation.py b/pypy/jit/backend/x86/test/test_ztranslation.py
--- a/pypy/jit/backend/x86/test/test_ztranslation.py
+++ b/pypy/jit/backend/x86/test/test_ztranslation.py
@@ -1,6 +1,6 @@
 import py, os, sys
 from pypy.tool.udir import udir
-from pypy.rlib.jit import JitDriver, unroll_parameters
+from pypy.rlib.jit import JitDriver, unroll_parameters, set_param
 from pypy.rlib.jit import PARAMETERS, dont_look_inside
 from pypy.rlib.jit import promote
 from pypy.jit.metainterp.jitprof import Profiler
@@ -47,9 +47,9 @@
         def f(i, j):
             for param, _ in unroll_parameters:
                 defl = PARAMETERS[param]
-                jitdriver.set_param(param, defl)
-            jitdriver.set_param("threshold", 3)
-            jitdriver.set_param("trace_eagerness", 2)
+                set_param(jitdriver, param, defl)
+            set_param(jitdriver, "threshold", 3)
+            set_param(jitdriver, "trace_eagerness", 2)
             total = 0
             frame = Frame(i)
             while frame.i > 3:
@@ -213,8 +213,8 @@
             else:
                 return Base()
         def myportal(i):
-            jitdriver.set_param("threshold", 3)
-            jitdriver.set_param("trace_eagerness", 2)
+            set_param(jitdriver, "threshold", 3)
+            set_param(jitdriver, "trace_eagerness", 2)
             total = 0
             n = i
             while True:
diff --git a/pypy/jit/codewriter/codewriter.py b/pypy/jit/codewriter/codewriter.py
--- a/pypy/jit/codewriter/codewriter.py
+++ b/pypy/jit/codewriter/codewriter.py
@@ -104,6 +104,8 @@
         else:
             name = 'unnamed' % id(ssarepr)
         i = 1
+        # escape <lambda> names for windows
+        name = name.replace('<lambda>', '_(lambda)_')
         extra = ''
         while name+extra in self._seen_files:
             i += 1
diff --git a/pypy/jit/codewriter/effectinfo.py b/pypy/jit/codewriter/effectinfo.py
--- a/pypy/jit/codewriter/effectinfo.py
+++ b/pypy/jit/codewriter/effectinfo.py
@@ -48,6 +48,8 @@
     OS_LIBFFI_PREPARE           = 60
     OS_LIBFFI_PUSH_ARG          = 61
     OS_LIBFFI_CALL              = 62
+    OS_LIBFFI_GETARRAYITEM      = 63
+    OS_LIBFFI_SETARRAYITEM      = 64
     #
     OS_LLONG_INVERT             = 69
     OS_LLONG_ADD                = 70
diff --git a/pypy/jit/codewriter/jtransform.py b/pypy/jit/codewriter/jtransform.py
--- a/pypy/jit/codewriter/jtransform.py
+++ b/pypy/jit/codewriter/jtransform.py
@@ -1615,6 +1615,12 @@
         elif oopspec_name.startswith('libffi_call_'):
             oopspecindex = EffectInfo.OS_LIBFFI_CALL
             extraeffect = EffectInfo.EF_RANDOM_EFFECTS
+        elif oopspec_name == 'libffi_array_getitem':
+            oopspecindex = EffectInfo.OS_LIBFFI_GETARRAYITEM
+            extraeffect = EffectInfo.EF_CANNOT_RAISE
+        elif oopspec_name == 'libffi_array_setitem':
+            oopspecindex = EffectInfo.OS_LIBFFI_SETARRAYITEM
+            extraeffect = EffectInfo.EF_CANNOT_RAISE
         else:
             assert False, 'unsupported oopspec: %s' % oopspec_name
         return self._handle_oopspec_call(op, args, oopspecindex, extraeffect)
diff --git a/pypy/jit/metainterp/executor.py b/pypy/jit/metainterp/executor.py
--- a/pypy/jit/metainterp/executor.py
+++ b/pypy/jit/metainterp/executor.py
@@ -340,6 +340,8 @@
                          rop.DEBUG_MERGE_POINT,
                          rop.JIT_DEBUG,
                          rop.SETARRAYITEM_RAW,
+                         rop.GETINTERIORFIELD_RAW,
+                         rop.SETINTERIORFIELD_RAW,
                          rop.CALL_RELEASE_GIL,
                          rop.QUASIIMMUT_FIELD,
                          ):      # list of opcodes never executed by pyjitpl
diff --git a/pypy/jit/metainterp/optimizeopt/fficall.py b/pypy/jit/metainterp/optimizeopt/fficall.py
--- a/pypy/jit/metainterp/optimizeopt/fficall.py
+++ b/pypy/jit/metainterp/optimizeopt/fficall.py
@@ -1,11 +1,13 @@
+from pypy.jit.codewriter.effectinfo import EffectInfo
+from pypy.jit.metainterp.optimizeopt.optimizer import Optimization
+from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
+from pypy.jit.metainterp.resoperation import rop, ResOperation
+from pypy.rlib import clibffi, libffi
+from pypy.rlib.debug import debug_print
+from pypy.rlib.libffi import Func
+from pypy.rlib.objectmodel import we_are_translated
 from pypy.rpython.annlowlevel import cast_base_ptr_to_instance
-from pypy.rlib.objectmodel import we_are_translated
-from pypy.rlib.libffi import Func
-from pypy.rlib.debug import debug_print
-from pypy.jit.codewriter.effectinfo import EffectInfo
-from pypy.jit.metainterp.resoperation import rop, ResOperation
-from pypy.jit.metainterp.optimizeopt.util import make_dispatcher_method
-from pypy.jit.metainterp.optimizeopt.optimizer import Optimization
+from pypy.rpython.lltypesystem import llmemory
 
 
 class FuncInfo(object):
@@ -78,7 +80,7 @@
 
     def new(self):
         return OptFfiCall()
-    
+
     def begin_optimization(self, funcval, op):
         self.rollback_maybe('begin_optimization', op)
         self.funcinfo = FuncInfo(funcval, self.optimizer.cpu, op)
@@ -116,6 +118,9 @@
             ops = self.do_push_arg(op)
         elif oopspec == EffectInfo.OS_LIBFFI_CALL:
             ops = self.do_call(op)
+        elif (oopspec == EffectInfo.OS_LIBFFI_GETARRAYITEM or
+            oopspec == EffectInfo.OS_LIBFFI_SETARRAYITEM):
+            ops = self.do_getsetarrayitem(op, oopspec)
         #
         for op in ops:
             self.emit_operation(op)
@@ -190,6 +195,53 @@
         ops.append(newop)
         return ops
 
+    def do_getsetarrayitem(self, op, oopspec):
+        ffitypeval = self.getvalue(op.getarg(1))
+        widthval = self.getvalue(op.getarg(2))
+        offsetval = self.getvalue(op.getarg(5))
+        if not ffitypeval.is_constant() or not widthval.is_constant() or not offsetval.is_constant():
+            return [op]
+
+        ffitypeaddr = ffitypeval.box.getaddr()
+        ffitype = llmemory.cast_adr_to_ptr(ffitypeaddr, clibffi.FFI_TYPE_P)
+        offset = offsetval.box.getint()
+        width = widthval.box.getint()
+        descr = self._get_interior_descr(ffitype, width, offset)
+
+        arglist = [
+            self.getvalue(op.getarg(3)).force_box(self.optimizer),
+            self.getvalue(op.getarg(4)).force_box(self.optimizer),
+        ]
+        if oopspec == EffectInfo.OS_LIBFFI_GETARRAYITEM:
+            opnum = rop.GETINTERIORFIELD_RAW
+        elif oopspec == EffectInfo.OS_LIBFFI_SETARRAYITEM:
+            opnum = rop.SETINTERIORFIELD_RAW
+            arglist.append(self.getvalue(op.getarg(6)).force_box(self.optimizer))
+        else:
+            assert False
+        return [
+            ResOperation(opnum, arglist, op.result, descr=descr),
+        ]
+
+    def _get_interior_descr(self, ffitype, width, offset):
+        kind = libffi.types.getkind(ffitype)
+        is_pointer = is_float = is_signed = False
+        if ffitype is libffi.types.pointer:
+            is_pointer = True
+        elif kind == 'i':
+            is_signed = True
+        elif kind == 'f' or kind == 'I' or kind == 'U':
+            # longlongs are treated as floats, see
+            # e.g. llsupport/descr.py:getDescrClass
+            is_float = True
+        else:
+            assert False, "unsupported ffitype or kind"
+        #
+        fieldsize = ffitype.c_size
+        return self.optimizer.cpu.interiorfielddescrof_dynamic(
+            offset, width, fieldsize, is_pointer, is_float, is_signed
+        )
+
     def propagate_forward(self, op):
         if self.logops is not None:
             debug_print(self.logops.repr_of_resop(op))
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_optimizeopt.py
@@ -1218,6 +1218,48 @@
         """
         self.optimize_loop(ops, expected, preamble)
 
+    def test_virtual_recursive_forced(self):
+        ops = """
+        [p0]
+        p41 = getfield_gc(p0, descr=nextdescr)
+        i0 = getfield_gc(p41, descr=valuedescr)
+        p1 = new_with_vtable(ConstClass(node_vtable2))
+        p2 = new_with_vtable(ConstClass(node_vtable2))
+        setfield_gc(p2, p1, descr=nextdescr)
+        setfield_gc(p1, p2, descr=nextdescr)
+        i1 = int_add(i0, 1)
+        setfield_gc(p2, i1, descr=valuedescr)
+        setfield_gc(p0, p1, descr=nextdescr)
+        jump(p1)
+        """
+        preamble = """
+        [p0]
+        p41 = getfield_gc(p0, descr=nextdescr)
+        i0 = getfield_gc(p41, descr=valuedescr)
+        i1 = int_add(i0, 1)
+        p1 = new_with_vtable(ConstClass(node_vtable2))
+        p2 = new_with_vtable(ConstClass(node_vtable2))
+        setfield_gc(p2, i1, descr=valuedescr)
+        setfield_gc(p2, p1, descr=nextdescr)
+        setfield_gc(p1, p2, descr=nextdescr)
+        setfield_gc(p0, p1, descr=nextdescr)
+        jump(p1)
+        """
+        loop = """
+        [p0]
+        p41 = getfield_gc(p0, descr=nextdescr)
+        i0 = getfield_gc(p41, descr=valuedescr)
+        i1 = int_add(i0, 1)
+        p1 = new_with_vtable(ConstClass(node_vtable2))
+        p2 = new_with_vtable(ConstClass(node_vtable2))
+        setfield_gc(p0, p1, descr=nextdescr)
+        setfield_gc(p2, p1, descr=nextdescr)
+        setfield_gc(p1, p2, descr=nextdescr)
+        setfield_gc(p2, i1, descr=valuedescr)
+        jump(p1)
+        """
+        self.optimize_loop(ops, loop, preamble)
+
     def test_virtual_constant_isnull(self):
         ops = """
         [i0]
@@ -5466,6 +5508,16 @@
         """
         self.optimize_loop(ops, expected)
 
+    def test_immutable_dont_constantfold_recursive(self):
+        ops = """
+        []
+        p0 = new_with_vtable(ConstClass(ptrobj_immut_vtable))
+        setfield_gc(p0, p0, descr=immut_ptrval)
+        escape(p0)
+        jump()
+        """
+        self.optimize_loop(ops, ops)
+
     # ----------
     def optimize_strunicode_loop(self, ops, optops, preamble):
         # check with the arguments passed in
diff --git a/pypy/jit/metainterp/optimizeopt/test/test_util.py b/pypy/jit/metainterp/optimizeopt/test/test_util.py
--- a/pypy/jit/metainterp/optimizeopt/test/test_util.py
+++ b/pypy/jit/metainterp/optimizeopt/test/test_util.py
@@ -139,6 +139,12 @@
     noimmut_intval = cpu.fielddescrof(INTOBJ_NOIMMUT, 'intval')
     immut_intval = cpu.fielddescrof(INTOBJ_IMMUT, 'intval')
 
+    PTROBJ_IMMUT = lltype.GcStruct('PTROBJ_IMMUT', ('parent', OBJECT),
+                                            ('ptrval', lltype.Ptr(OBJECT)),
+                                            hints={'immutable': True})
+    ptrobj_immut_vtable = lltype.malloc(OBJECT_VTABLE, immortal=True)
+    immut_ptrval = cpu.fielddescrof(PTROBJ_IMMUT, 'ptrval')
+
     arraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Signed))
     floatarraydescr = cpu.arraydescrof(lltype.GcArray(lltype.Float))
 
@@ -246,6 +252,7 @@
     register_known_gctype(cpu, jit_virtual_ref_vtable,vrefinfo.JIT_VIRTUAL_REF)
     register_known_gctype(cpu, intobj_noimmut_vtable, INTOBJ_NOIMMUT)
     register_known_gctype(cpu, intobj_immut_vtable,   INTOBJ_IMMUT)
+    register_known_gctype(cpu, ptrobj_immut_vtable,   PTROBJ_IMMUT)
 
     namespace = locals()
 
diff --git a/pypy/jit/metainterp/resoperation.py b/pypy/jit/metainterp/resoperation.py
--- a/pypy/jit/metainterp/resoperation.py
+++ b/pypy/jit/metainterp/resoperation.py
@@ -461,6 +461,7 @@
     'GETARRAYITEM_GC/2d',
     'GETARRAYITEM_RAW/2d',
     'GETINTERIORFIELD_GC/2d',
+    'GETINTERIORFIELD_RAW/2d',
     'GETFIELD_GC/1d',
     'GETFIELD_RAW/1d',
     '_MALLOC_FIRST',
@@ -479,6 +480,7 @@
     'SETARRAYITEM_GC/3d',
     'SETARRAYITEM_RAW/3d',
     'SETINTERIORFIELD_GC/3d',
+    'SETINTERIORFIELD_RAW/3d',
     'SETFIELD_GC/2d',
     'SETFIELD_RAW/2d',
     'STRSETITEM/3',
diff --git a/pypy/jit/metainterp/test/test_ajit.py b/pypy/jit/metainterp/test/test_ajit.py
--- a/pypy/jit/metainterp/test/test_ajit.py
+++ b/pypy/jit/metainterp/test/test_ajit.py
@@ -14,7 +14,7 @@
 from pypy.rlib.jit import (JitDriver, we_are_jitted, hint, dont_look_inside,
     loop_invariant, elidable, promote, jit_debug, assert_green,
     AssertGreenFailed, unroll_safe, current_trace_length, look_inside_iff,
-    isconstant, isvirtual, promote_string)
+    isconstant, isvirtual, promote_string, set_param)
 from pypy.rlib.rarithmetic import ovfcheck
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.rpython.ootypesystem import ootype
@@ -1256,15 +1256,18 @@
                 n -= 1
                 x += n
             return x
-        def f(n, threshold):
-            myjitdriver.set_param('threshold', threshold)
+        def f(n, threshold, arg):
+            if arg:
+                set_param(myjitdriver, 'threshold', threshold)
+            else:
+                set_param(None, 'threshold', threshold)
             return g(n)
 
-        res = self.meta_interp(f, [10, 3])
+        res = self.meta_interp(f, [10, 3, 1])
         assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
         self.check_tree_loop_count(2)
 
-        res = self.meta_interp(f, [10, 13])
+        res = self.meta_interp(f, [10, 13, 0])
         assert res == 9 + 8 + 7 + 6 + 5 + 4 + 3 + 2 + 1 + 0
         self.check_tree_loop_count(0)
 
@@ -2328,8 +2331,8 @@
                                 get_printable_location=get_printable_location)
         bytecode = "0j10jc20a3"
         def f():
-            myjitdriver.set_param('threshold', 7)
-            myjitdriver.set_param('trace_eagerness', 1)
+            set_param(myjitdriver, 'threshold', 7)
+            set_param(myjitdriver, 'trace_eagerness', 1)
             i = j = c = a = 1
             while True:
                 myjitdriver.jit_merge_point(i=i, j=j, c=c, a=a)
@@ -2607,7 +2610,7 @@
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
 
         def f(n, limit):
-            myjitdriver.set_param('retrace_limit', limit)
+            set_param(myjitdriver, 'retrace_limit', limit)
             sa = i = a = 0
             while i < n:
                 myjitdriver.jit_merge_point(n=n, i=i, sa=sa, a=a)
@@ -2625,8 +2628,8 @@
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a'])
 
         def f(n, limit):
-            myjitdriver.set_param('retrace_limit', 3)
-            myjitdriver.set_param('max_retrace_guards', limit)
+            set_param(myjitdriver, 'retrace_limit', 3)
+            set_param(myjitdriver, 'max_retrace_guards', limit)
             sa = i = a = 0
             while i < n:
                 myjitdriver.jit_merge_point(n=n, i=i, sa=sa, a=a)
@@ -2645,7 +2648,7 @@
         myjitdriver = JitDriver(greens = [], reds = ['n', 'i', 'sa', 'a',
                                                      'node'])
         def f(n, limit):
-            myjitdriver.set_param('retrace_limit', limit)
+            set_param(myjitdriver, 'retrace_limit', limit)
             sa = i = a = 0
             node = [1, 2, 3]
             node[1] = n
@@ -2668,10 +2671,10 @@
         myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'i', 'sa'])
         bytecode = "0+sI0+SI"
         def f(n):
-            myjitdriver.set_param('threshold', 3)
-            myjitdriver.set_param('trace_eagerness', 1)
-            myjitdriver.set_param('retrace_limit', 5)
-            myjitdriver.set_param('function_threshold', -1)
+            set_param(None, 'threshold', 3)
+            set_param(None, 'trace_eagerness', 1)
+            set_param(None, 'retrace_limit', 5)
+            set_param(None, 'function_threshold', -1)
             pc = sa = i = 0
             while pc < len(bytecode):
                 myjitdriver.jit_merge_point(pc=pc, n=n, sa=sa, i=i)
@@ -2728,9 +2731,9 @@
         myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'a', 'i', 'j', 'sa'])
         bytecode = "ij+Jj+JI"
         def f(n, a):
-            myjitdriver.set_param('threshold', 5)
-            myjitdriver.set_param('trace_eagerness', 1)
-            myjitdriver.set_param('retrace_limit', 2)
+            set_param(None, 'threshold', 5)
+            set_param(None, 'trace_eagerness', 1)
+            set_param(None, 'retrace_limit', 2)
             pc = sa = i = j = 0
             while pc < len(bytecode):
                 myjitdriver.jit_merge_point(pc=pc, n=n, sa=sa, i=i, j=j, a=a)
@@ -2793,8 +2796,8 @@
                 return B(self.val + 1)
         myjitdriver = JitDriver(greens = [], reds = ['sa', 'a'])
         def f():
-            myjitdriver.set_param('threshold', 3)
-            myjitdriver.set_param('trace_eagerness', 2)
+            set_param(None, 'threshold', 3)
+            set_param(None, 'trace_eagerness', 2)
             a = A(0)
             sa = 0
             while a.val < 8:
@@ -2824,8 +2827,8 @@
                 return B(self.val + 1)
         myjitdriver = JitDriver(greens = [], reds = ['sa', 'b', 'a'])
         def f(b):
-            myjitdriver.set_param('threshold', 6)
-            myjitdriver.set_param('trace_eagerness', 4)
+            set_param(None, 'threshold', 6)
+            set_param(None, 'trace_eagerness', 4)
             a = A(0)
             sa = 0
             while a.val < 15:
@@ -2862,10 +2865,10 @@
         myjitdriver = JitDriver(greens = ['pc'], reds = ['n', 'i', 'sa'])
         bytecode = "0+sI0+SI"
         def f(n):
-            myjitdriver.set_param('threshold', 3)
-            myjitdriver.set_param('trace_eagerness', 1)
-            myjitdriver.set_param('retrace_limit', 5)
-            myjitdriver.set_param('function_threshold', -1)
+            set_param(None, 'threshold', 3)
+            set_param(None, 'trace_eagerness', 1)
+            set_param(None, 'retrace_limit', 5)
+            set_param(None, 'function_threshold', -1)
             pc = sa = i = 0
             while pc < len(bytecode):
                 myjitdriver.jit_merge_point(pc=pc, n=n, sa=sa, i=i)
diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py
--- a/pypy/jit/metainterp/test/test_fficall.py
+++ b/pypy/jit/metainterp/test/test_fficall.py
@@ -1,19 +1,18 @@
+import py
 
-import py
+from pypy.jit.metainterp.test.support import LLJitMixin
+from pypy.rlib.jit import JitDriver, promote, dont_look_inside
+from pypy.rlib.libffi import (ArgChain, IS_32_BIT, array_getitem, array_setitem,
+    types)
+from pypy.rlib.objectmodel import specialize
 from pypy.rlib.rarithmetic import r_singlefloat, r_longlong, r_ulonglong
-from pypy.rlib.jit import JitDriver, promote, dont_look_inside
+from pypy.rlib.test.test_libffi import TestLibffiCall as _TestLibffiCall
 from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib.libffi import ArgChain
-from pypy.rlib.libffi import IS_32_BIT
-from pypy.rlib.test.test_libffi import TestLibffiCall as _TestLibffiCall
 from pypy.rpython.lltypesystem import lltype, rffi
-from pypy.rlib.objectmodel import specialize
 from pypy.tool.sourcetools import func_with_new_name
-from pypy.jit.metainterp.test.support import LLJitMixin
 
-class TestFfiCall(LLJitMixin, _TestLibffiCall):
-    supports_all = False     # supports_{floats,longlong,singlefloats}
 
+class FfiCallTests(_TestLibffiCall):
     # ===> ../../../rlib/test/test_libffi.py
 
     def call(self, funcspec, args, RESULT, is_struct=False, jitif=[]):
@@ -92,6 +91,69 @@
     test_byval_result.__doc__ = _TestLibffiCall.test_byval_result.__doc__
     test_byval_result.dont_track_allocations = True
 
+class FfiLookupTests(object):
+    def test_array_fields(self):
+        myjitdriver = JitDriver(
+            greens = [],
+            reds = ["n", "i", "points", "result_point"],
+        )
 
-class TestFfiCallSupportAll(TestFfiCall):
+        POINT = lltype.Struct("POINT",
+            ("x", lltype.Signed),
+            ("y", lltype.Signed),
+        )
+        def f(points, result_point, n):
+            i = 0
+            while i < n:
+                myjitdriver.jit_merge_point(i=i, points=points, n=n,
+                                            result_point=result_point)
+                x = array_getitem(
+                    types.slong, rffi.sizeof(lltype.Signed) * 2, points, i, 0
+                )
+                y = array_getitem(
+                    types.slong, rffi.sizeof(lltype.Signed) * 2, points, i, rffi.sizeof(lltype.Signed)
+                )
+
+                cur_x = array_getitem(
+                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, 0
+                )
+                cur_y = array_getitem(
+                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, rffi.sizeof(lltype.Signed)
+                )
+
+                array_setitem(
+                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, 0, cur_x + x
+                )
+                array_setitem(
+                    types.slong, rffi.sizeof(lltype.Signed) * 2, result_point, 0, rffi.sizeof(lltype.Signed), cur_y + y
+                )
+                i += 1
+
+        def main(n):
+            with lltype.scoped_alloc(rffi.CArray(POINT), n) as points:
+                with lltype.scoped_alloc(rffi.CArray(POINT), 1) as result_point:
+                    for i in xrange(n):
+                        points[i].x = i * 2
+                        points[i].y = i * 2 + 1
+                    points = rffi.cast(rffi.CArrayPtr(lltype.Char), points)
+                    result_point[0].x = 0
+                    result_point[0].y = 0
+                    result_point = rffi.cast(rffi.CArrayPtr(lltype.Char), result_point)
+                    f(points, result_point, n)
+                    result_point = rffi.cast(rffi.CArrayPtr(POINT), result_point)
+                    return result_point[0].x * result_point[0].y
+
+        assert self.meta_interp(main, [10]) == main(10) == 9000
+        self.check_loops({"int_add": 3, "jump": 1, "int_lt": 1, "guard_true": 1,
+                          "getinteriorfield_raw": 4, "setinteriorfield_raw": 2
+        })
+
+
+class TestFfiCall(FfiCallTests, LLJitMixin):
+    supports_all = False
+
+class TestFfiCallSupportAll(FfiCallTests, LLJitMixin):
     supports_all = True     # supports_{floats,longlong,singlefloats}
+
+class TestFfiLookup(FfiLookupTests, LLJitMixin):
+    pass
\ No newline at end of file
diff --git a/pypy/jit/metainterp/test/test_jitdriver.py b/pypy/jit/metainterp/test/test_jitdriver.py
--- a/pypy/jit/metainterp/test/test_jitdriver.py
+++ b/pypy/jit/metainterp/test/test_jitdriver.py
@@ -1,5 +1,5 @@
 """Tests for multiple JitDrivers."""
-from pypy.rlib.jit import JitDriver, unroll_safe
+from pypy.rlib.jit import JitDriver, unroll_safe, set_param
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.warmspot import get_stats
 
@@ -113,7 +113,7 @@
             return n
         #
         def loop2(g, r):
-            myjitdriver1.set_param('function_threshold', 0)
+            set_param(None, 'function_threshold', 0)
             while r > 0:
                 myjitdriver2.can_enter_jit(g=g, r=r)
                 myjitdriver2.jit_merge_point(g=g, r=r)
diff --git a/pypy/jit/metainterp/test/test_loop.py b/pypy/jit/metainterp/test/test_loop.py
--- a/pypy/jit/metainterp/test/test_loop.py
+++ b/pypy/jit/metainterp/test/test_loop.py
@@ -1,5 +1,5 @@
 import py
-from pypy.rlib.jit import JitDriver, hint
+from pypy.rlib.jit import JitDriver, hint, set_param
 from pypy.rlib.objectmodel import compute_hash
 from pypy.jit.metainterp.warmspot import ll_meta_interp, get_stats
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
@@ -364,7 +364,7 @@
         myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'j', 'n', 'x'])
         bytecode = "IzJxji"
         def f(n, threshold):
-            myjitdriver.set_param('threshold', threshold)        
+            set_param(myjitdriver, 'threshold', threshold)        
             i = j = x = 0
             pos = 0
             op = '-'
@@ -411,7 +411,7 @@
         myjitdriver = JitDriver(greens = ['pos'], reds = ['i', 'j', 'n', 'x'])
         bytecode = "IzJxji"
         def f(nval, threshold):
-            myjitdriver.set_param('threshold', threshold)        
+            set_param(myjitdriver, 'threshold', threshold)        
             i, j, x = A(0), A(0), A(0)
             n = A(nval)
             pos = 0
diff --git a/pypy/jit/metainterp/test/test_recursive.py b/pypy/jit/metainterp/test/test_recursive.py
--- a/pypy/jit/metainterp/test/test_recursive.py
+++ b/pypy/jit/metainterp/test/test_recursive.py
@@ -1,5 +1,5 @@
 import py
-from pypy.rlib.jit import JitDriver, we_are_jitted, hint
+from pypy.rlib.jit import JitDriver, hint, set_param
 from pypy.rlib.jit import unroll_safe, dont_look_inside, promote
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.debug import fatalerror
@@ -308,8 +308,8 @@
                 pc += 1
             return n
         def main(n):
-            myjitdriver.set_param('threshold', 3)
-            myjitdriver.set_param('trace_eagerness', 5)            
+            set_param(None, 'threshold', 3)
+            set_param(None, 'trace_eagerness', 5)            
             return f("c-l", n)
         expected = main(100)
         res = self.meta_interp(main, [100], enable_opts='', inline=True)
@@ -329,7 +329,7 @@
                 return recursive(n - 1) + 1
             return 0
         def loop(n):            
-            myjitdriver.set_param("threshold", 10)
+            set_param(myjitdriver, "threshold", 10)
             pc = 0
             while n:
                 myjitdriver.can_enter_jit(n=n)
@@ -351,8 +351,8 @@
             return 0
         myjitdriver = JitDriver(greens=[], reds=['n'])
         def loop(n):
-            myjitdriver.set_param("threshold", 4)
-            myjitdriver.set_param("trace_eagerness", 2)
+            set_param(None, "threshold", 4)
+            set_param(None, "trace_eagerness", 2)
             while n:
                 myjitdriver.can_enter_jit(n=n)
                 myjitdriver.jit_merge_point(n=n)
@@ -482,12 +482,12 @@
         TRACE_LIMIT = 66
  
         def main(inline):
-            myjitdriver.set_param("threshold", 10)
-            myjitdriver.set_param('function_threshold', 60)
+            set_param(None, "threshold", 10)
+            set_param(None, 'function_threshold', 60)
             if inline:
-                myjitdriver.set_param('inlining', True)
+                set_param(None, 'inlining', True)
             else:
-                myjitdriver.set_param('inlining', False)
+                set_param(None, 'inlining', False)
             return loop(100)
 
         res = self.meta_interp(main, [0], enable_opts='', trace_limit=TRACE_LIMIT)
@@ -564,11 +564,11 @@
                 pc += 1
             return n
         def g(m):
-            myjitdriver.set_param('inlining', True)
+            set_param(None, 'inlining', True)
             # carefully chosen threshold to make sure that the inner function
             # cannot be inlined, but the inner function on its own is small
             # enough
-            myjitdriver.set_param('trace_limit', 40)
+            set_param(None, 'trace_limit', 40)
             if m > 1000000:
                 f('', 0)
             result = 0
@@ -1207,9 +1207,9 @@
                     driver.can_enter_jit(c=c, i=i, v=v)
                 break
 
-        def main(c, i, set_param, v):
-            if set_param:
-                driver.set_param('function_threshold', 0)
+        def main(c, i, _set_param, v):
+            if _set_param:
+                set_param(driver, 'function_threshold', 0)
             portal(c, i, v)
 
         self.meta_interp(main, [10, 10, False, False], inline=True)
diff --git a/pypy/jit/metainterp/test/test_warmspot.py b/pypy/jit/metainterp/test/test_warmspot.py
--- a/pypy/jit/metainterp/test/test_warmspot.py
+++ b/pypy/jit/metainterp/test/test_warmspot.py
@@ -1,10 +1,7 @@
 import py
-from pypy.jit.metainterp.warmspot import ll_meta_interp
 from pypy.jit.metainterp.warmspot import get_stats
-from pypy.rlib.jit import JitDriver
-from pypy.rlib.jit import unroll_safe
+from pypy.rlib.jit import JitDriver, set_param, unroll_safe
 from pypy.jit.backend.llgraph import runner
-from pypy.jit.metainterp.history import BoxInt
 
 from pypy.jit.metainterp.test.support import LLJitMixin, OOJitMixin
 from pypy.jit.metainterp.optimizeopt import ALL_OPTS_NAMES
@@ -97,7 +94,7 @@
                 n = A().m(n)
             return n
         def f(n, enable_opts):
-            myjitdriver.set_param('enable_opts', hlstr(enable_opts))
+            set_param(None, 'enable_opts', hlstr(enable_opts))
             return g(n)
 
         # check that the set_param will override the default
diff --git a/pypy/jit/metainterp/test/test_ztranslation.py b/pypy/jit/metainterp/test/test_ztranslation.py
--- a/pypy/jit/metainterp/test/test_ztranslation.py
+++ b/pypy/jit/metainterp/test/test_ztranslation.py
@@ -1,7 +1,7 @@
 import py
 from pypy.jit.metainterp.warmspot import rpython_ll_meta_interp, ll_meta_interp
 from pypy.jit.backend.llgraph import runner
-from pypy.rlib.jit import JitDriver, unroll_parameters
+from pypy.rlib.jit import JitDriver, unroll_parameters, set_param
 from pypy.rlib.jit import PARAMETERS, dont_look_inside, hint
 from pypy.jit.metainterp.jitprof import Profiler
 from pypy.rpython.lltypesystem import lltype, llmemory
@@ -57,9 +57,9 @@
                               get_printable_location=get_printable_location)
         def f(i):
             for param, defl in unroll_parameters:
-                jitdriver.set_param(param, defl)
-            jitdriver.set_param("threshold", 3)
-            jitdriver.set_param("trace_eagerness", 2)
+                set_param(jitdriver, param, defl)
+            set_param(jitdriver, "threshold", 3)
+            set_param(jitdriver, "trace_eagerness", 2)
             total = 0
             frame = Frame(i)
             while frame.l[0] > 3:
@@ -117,8 +117,8 @@
                 raise ValueError
             return 2
         def main(i):
-            jitdriver.set_param("threshold", 3)
-            jitdriver.set_param("trace_eagerness", 2)
+            set_param(jitdriver, "threshold", 3)
+            set_param(jitdriver, "trace_eagerness", 2)
             total = 0
             n = i
             while n > 3:
diff --git a/pypy/jit/metainterp/warmspot.py b/pypy/jit/metainterp/warmspot.py
--- a/pypy/jit/metainterp/warmspot.py
+++ b/pypy/jit/metainterp/warmspot.py
@@ -120,7 +120,8 @@
                 op = block.operations[i]
                 if (op.opname == 'jit_marker' and
                     op.args[0].value == marker_name and
-                    op.args[1].value.active):   # the jitdriver
+                    (op.args[1].value is None or
+                    op.args[1].value.active)):   # the jitdriver
                     results.append((graph, block, i))
     return results
 
@@ -846,11 +847,18 @@
         _, PTR_SET_PARAM_STR_FUNCTYPE = self.cpu.ts.get_FuncType(
             [lltype.Ptr(STR)], lltype.Void)
         def make_closure(jd, fullfuncname, is_string):
-            state = jd.warmstate
-            def closure(i):
-                if is_string:
-                    i = hlstr(i)
-                getattr(state, fullfuncname)(i)
+            if jd is None:
+                def closure(i):
+                    if is_string:
+                        i = hlstr(i)
+                    for jd in self.jitdrivers_sd:
+                        getattr(jd.warmstate, fullfuncname)(i)
+            else:
+                state = jd.warmstate
+                def closure(i):
+                    if is_string:
+                        i = hlstr(i)
+                    getattr(state, fullfuncname)(i)
             if is_string:
                 TP = PTR_SET_PARAM_STR_FUNCTYPE
             else:
@@ -859,12 +867,16 @@
             return Constant(funcptr, TP)
         #
         for graph, block, i in find_set_param(graphs):
+            
             op = block.operations[i]
-            for jd in self.jitdrivers_sd:
-                if jd.jitdriver is op.args[1].value:
-                    break
+            if op.args[1].value is not None:
+                for jd in self.jitdrivers_sd:
+                    if jd.jitdriver is op.args[1].value:
+                        break
+                else:
+                    assert 0, "jitdriver of set_param() not found"
             else:
-                assert 0, "jitdriver of set_param() not found"
+                jd = None
             funcname = op.args[2].value
             key = jd, funcname
             if key not in closures:
diff --git a/pypy/module/cpyext/include/modsupport.h b/pypy/module/cpyext/include/modsupport.h
--- a/pypy/module/cpyext/include/modsupport.h
+++ b/pypy/module/cpyext/include/modsupport.h
@@ -48,7 +48,11 @@
 /*
  * This is from pyport.h.  Perhaps it belongs elsewhere.
  */
+#ifdef __cplusplus
+#define PyMODINIT_FUNC extern "C" void
+#else
 #define PyMODINIT_FUNC void
+#endif
 
 
 #ifdef __cplusplus
diff --git a/pypy/module/cpyext/presetup.py b/pypy/module/cpyext/presetup.py
--- a/pypy/module/cpyext/presetup.py
+++ b/pypy/module/cpyext/presetup.py
@@ -42,4 +42,4 @@
 patch_distutils()
 
 del sys.argv[0]
-execfile(sys.argv[0], {'__file__': sys.argv[0]})
+execfile(sys.argv[0], {'__file__': sys.argv[0], '__name__': '__main__'})
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -9,7 +9,8 @@
     unaryfunc, wrapperfunc, ternaryfunc, PyTypeObjectPtr, binaryfunc,
     getattrfunc, getattrofunc, setattrofunc, lenfunc, ssizeargfunc,
     ssizessizeargfunc, ssizeobjargproc, iternextfunc, initproc, richcmpfunc,
-    cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, readbufferproc)
+    cmpfunc, hashfunc, descrgetfunc, descrsetfunc, objobjproc, objobjargproc,
+    readbufferproc)
 from pypy.module.cpyext.pyobject import from_ref
 from pypy.module.cpyext.pyerrors import PyErr_Occurred
 from pypy.module.cpyext.state import State
@@ -175,6 +176,15 @@
         space.fromcache(State).check_and_raise_exception(always=True)
     return space.wrap(res)
 
+def wrap_objobjargproc(space, w_self, w_args, func):
+    func_target = rffi.cast(objobjargproc, func)
+    check_num_args(space, w_args, 2)
+    w_key, w_value = space.fixedview(w_args)
+    res = generic_cpy_call(space, func_target, w_self, w_key, w_value)
+    if rffi.cast(lltype.Signed, res) == -1:
+        space.fromcache(State).check_and_raise_exception(always=True)
+    return space.wrap(res)
+
 def wrap_ssizessizeargfunc(space, w_self, w_args, func):
     func_target = rffi.cast(ssizessizeargfunc, func)
     check_num_args(space, w_args, 2)
diff --git a/pypy/module/cpyext/test/test_typeobject.py b/pypy/module/cpyext/test/test_typeobject.py
--- a/pypy/module/cpyext/test/test_typeobject.py
+++ b/pypy/module/cpyext/test/test_typeobject.py
@@ -397,3 +397,31 @@
             def __str__(self):
                 return "text"
         assert module.tp_str(C()) == "text"
+
+    def test_mp_ass_subscript(self):
+        module = self.import_extension('foo', [
+           ("new_obj", "METH_NOARGS",
+            '''
+                PyObject *obj;
+                Foo_Type.tp_as_mapping = &tp_as_mapping;
+                tp_as_mapping.mp_ass_subscript = mp_ass_subscript;
+                if (PyType_Ready(&Foo_Type) < 0) return NULL;
+                obj = PyObject_New(PyObject, &Foo_Type);
+                return obj;
+            '''
+            )],
+            '''
+            static int
+            mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
+            {
+                PyErr_SetNone(PyExc_ZeroDivisionError);
+                return -1;
+            }
+            PyMappingMethods tp_as_mapping;
+            static PyTypeObject Foo_Type = {
+                PyVarObject_HEAD_INIT(NULL, 0)
+                "foo.foo",
+            };
+            ''')
+        obj = module.new_obj()
+        raises(ZeroDivisionError, obj.__setitem__, 5, None)
diff --git a/pypy/module/micronumpy/__init__.py b/pypy/module/micronumpy/__init__.py
--- a/pypy/module/micronumpy/__init__.py
+++ b/pypy/module/micronumpy/__init__.py
@@ -2,7 +2,7 @@
 
 
 class Module(MixedModule):
-    applevel_name = 'numpy'
+    applevel_name = 'numpypy'
 
     interpleveldefs = {
         'array': 'interp_numarray.SingleDimArray',
diff --git a/pypy/module/micronumpy/app_numpy.py b/pypy/module/micronumpy/app_numpy.py
--- a/pypy/module/micronumpy/app_numpy.py
+++ b/pypy/module/micronumpy/app_numpy.py
@@ -1,6 +1,6 @@
 import math
 
-import numpy
+import numpypy
 
 
 inf = float("inf")
@@ -13,5 +13,5 @@
 
 def mean(a):
     if not hasattr(a, "mean"):
-        a = numpy.array(a)
+        a = numpypy.array(a)
     return a.mean()
diff --git a/pypy/module/micronumpy/bench/add.py b/pypy/module/micronumpy/bench/add.py
--- a/pypy/module/micronumpy/bench/add.py
+++ b/pypy/module/micronumpy/bench/add.py
@@ -1,5 +1,8 @@
 
-import numpy
+try:
+    import numpypy as numpy
+except:
+    import numpy
 
 def f():
     a = numpy.zeros(10000000)
diff --git a/pypy/module/micronumpy/bench/iterate.py b/pypy/module/micronumpy/bench/iterate.py
--- a/pypy/module/micronumpy/bench/iterate.py
+++ b/pypy/module/micronumpy/bench/iterate.py
@@ -1,5 +1,8 @@
 
-import numpy
+try:
+    import numpypy as numpy
+except:
+    import numpy
 
 def f():
     sum = 0
diff --git a/pypy/module/micronumpy/test/test_dtypes.py b/pypy/module/micronumpy/test/test_dtypes.py
--- a/pypy/module/micronumpy/test/test_dtypes.py
+++ b/pypy/module/micronumpy/test/test_dtypes.py
@@ -3,7 +3,7 @@
 
 class AppTestDtypes(BaseNumpyAppTest):
     def test_dtype(self):
-        from numpy import dtype
+        from numpypy import dtype
 
         d = dtype('?')
         assert d.num == 0
@@ -14,7 +14,7 @@
         raises(TypeError, dtype, 1042)
 
     def test_dtype_with_types(self):
-        from numpy import dtype
+        from numpypy import dtype
 
         assert dtype(bool).num == 0
         assert dtype(int).num == 7
@@ -22,13 +22,13 @@
         assert dtype(float).num == 12
 
     def test_array_dtype_attr(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
 
         a = array(range(5), long)
         assert a.dtype is dtype(long)
 
     def test_repr_str(self):
-        from numpy import dtype
+        from numpypy import dtype
 
         assert repr(dtype) == "<type 'numpy.dtype'>"
         d = dtype('?')
@@ -36,57 +36,57 @@
         assert str(d) == "bool"
 
     def test_bool_array(self):
-        import numpy
+        from numpypy import array, False_, True_
 
-        a = numpy.array([0, 1, 2, 2.5], dtype='?')
-        assert a[0] is numpy.False_
+        a = array([0, 1, 2, 2.5], dtype='?')
+        assert a[0] is False_
         for i in xrange(1, 4):
-            assert a[i] is numpy.True_
+            assert a[i] is True_
 
     def test_copy_array_with_dtype(self):
-        import numpy
+        from numpypy import array, False_, True_
 
-        a = numpy.array([0, 1, 2, 3], dtype=long)
+        a = array([0, 1, 2, 3], dtype=long)
         # int on 64-bit, long in 32-bit
         assert isinstance(a[0], (int, long))
         b = a.copy()
         assert isinstance(b[0], (int, long))
 
-        a = numpy.array([0, 1, 2, 3], dtype=bool)
-        assert a[0] is numpy.False_
+        a = array([0, 1, 2, 3], dtype=bool)
+        assert a[0] is False_
         b = a.copy()
-        assert b[0] is numpy.False_
+        assert b[0] is False_
 
     def test_zeros_bool(self):
-        import numpy
+        from numpypy import zeros, False_
 
-        a = numpy.zeros(10, dtype=bool)
+        a = zeros(10, dtype=bool)
         for i in range(10):
-            assert a[i] is numpy.False_
+            assert a[i] is False_
 
     def test_ones_bool(self):
-        import numpy
+        from numpypy import ones, True_
 
-        a = numpy.ones(10, dtype=bool)
+        a = ones(10, dtype=bool)
         for i in range(10):
-            assert a[i] is numpy.True_
+            assert a[i] is True_
 
     def test_zeros_long(self):
-        from numpy import zeros
+        from numpypy import zeros
         a = zeros(10, dtype=long)
         for i in range(10):
             assert isinstance(a[i], (int, long))
             assert a[1] == 0
 
     def test_ones_long(self):
-        from numpy import ones
+        from numpypy import ones
         a = ones(10, dtype=long)
         for i in range(10):
             assert isinstance(a[i], (int, long))
             assert a[1] == 1
 
     def test_overflow(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
         assert array([128], 'b')[0] == -128
         assert array([256], 'B')[0] == 0
         assert array([32768], 'h')[0] == -32768
@@ -98,7 +98,7 @@
         raises(OverflowError, "array([2**64], 'Q')")
 
     def test_bool_binop_types(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
         types = [
             '?', 'b', 'B', 'h', 'H', 'i', 'I', 'l', 'L', 'q', 'Q', 'f', 'd'
         ]
@@ -107,7 +107,7 @@
             assert (a + array([0], t)).dtype is dtype(t)
 
     def test_binop_types(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
         tests = [('b','B','h'), ('b','h','h'), ('b','H','i'), ('b','i','i'),
                  ('b','l','l'), ('b','q','q'), ('b','Q','d'), ('B','h','h'),
                  ('B','H','H'), ('B','i','i'), ('B','I','I'), ('B','l','l'),
@@ -129,7 +129,7 @@
             assert (array([1], d1) + array([1], d2)).dtype is dtype(dout)
 
     def test_add_int8(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
 
         a = array(range(5), dtype="int8")
         b = a + a
@@ -138,7 +138,7 @@
             assert b[i] == i * 2
 
     def test_add_int16(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
 
         a = array(range(5), dtype="int16")
         b = a + a
@@ -147,7 +147,7 @@
             assert b[i] == i * 2
 
     def test_add_uint32(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
 
         a = array(range(5), dtype="I")
         b = a + a
@@ -156,12 +156,12 @@
             assert b[i] == i * 2
 
     def test_shape(self):
-        from numpy import dtype
+        from numpypy import dtype
 
         assert dtype(long).shape == ()
 
     def test_cant_subclass(self):
-        from numpy import dtype
+        from numpypy import dtype
 
         # You can't subclass dtype
         raises(TypeError, type, "Foo", (dtype,), {})
diff --git a/pypy/module/micronumpy/test/test_module.py b/pypy/module/micronumpy/test/test_module.py
--- a/pypy/module/micronumpy/test/test_module.py
+++ b/pypy/module/micronumpy/test/test_module.py
@@ -3,19 +3,19 @@
 
 class AppTestNumPyModule(BaseNumpyAppTest):
     def test_mean(self):
-        from numpy import array, mean
+        from numpypy import array, mean
         assert mean(array(range(5))) == 2.0
         assert mean(range(5)) == 2.0
 
     def test_average(self):
-        from numpy import array, average
+        from numpypy import array, average
         assert average(range(10)) == 4.5
         assert average(array(range(10))) == 4.5
 
     def test_constants(self):
         import math
-        from numpy import inf, e
+        from numpypy import inf, e
         assert type(inf) is float
         assert inf == float("inf")
         assert e == math.e
-        assert type(e) is float
\ No newline at end of file
+        assert type(e) is float
diff --git a/pypy/module/micronumpy/test/test_numarray.py b/pypy/module/micronumpy/test/test_numarray.py
--- a/pypy/module/micronumpy/test/test_numarray.py
+++ b/pypy/module/micronumpy/test/test_numarray.py
@@ -4,12 +4,12 @@
 
 class AppTestNumArray(BaseNumpyAppTest):
     def test_type(self):
-        from numpy import array
+        from numpypy import array
         ar = array(range(5))
         assert type(ar) is type(ar + ar)
 
     def test_init(self):
-        from numpy import zeros
+        from numpypy import zeros
         a = zeros(15)
         # Check that storage was actually zero'd.
         assert a[10] == 0.0
@@ -18,7 +18,7 @@
         assert a[13] == 5.3
 
     def test_size(self):
-        from numpy import array
+        from numpypy import array
         # XXX fixed on multidim branch
         #assert array(3).size == 1
         a = array([1, 2, 3])
@@ -30,13 +30,13 @@
         Test that empty() works.
         """
 
-        from numpy import empty
+        from numpypy import empty
         a = empty(2)
         a[1] = 1.0
         assert a[1] == 1.0
 
     def test_ones(self):
-        from numpy import ones
+        from numpypy import ones
         a = ones(3)
         assert len(a) == 3
         assert a[0] == 1
@@ -45,19 +45,19 @@
         assert a[2] == 4
 
     def test_copy(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a.copy()
         for i in xrange(5):
             assert b[i] == a[i]
 
     def test_iterator_init(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert a[3] == 3
 
     def test_repr(self):
-        from numpy import array, zeros
+        from numpypy import array, zeros
         a = array(range(5), float)
         assert repr(a) == "array([0.0, 1.0, 2.0, 3.0, 4.0])"
         a = array([], float)
@@ -72,7 +72,7 @@
         assert repr(a) == "array([True, False, True, False], dtype=bool)"
 
     def test_repr_slice(self):
-        from numpy import array, zeros
+        from numpypy import array, zeros
         a = array(range(5), float)
         b = a[1::2]
         assert repr(b) == "array([1.0, 3.0])"
@@ -81,7 +81,7 @@
         assert repr(b) == "array([0.0, 0.0, 0.0, ..., 0.0, 0.0, 0.0])"
 
     def test_str(self):
-        from numpy import array, zeros
+        from numpypy import array, zeros
         a = array(range(5), float)
         assert str(a) == "[0.0 1.0 2.0 3.0 4.0]"
         assert str((2*a)[:]) == "[0.0 2.0 4.0 6.0 8.0]"
@@ -100,7 +100,7 @@
         assert str(a) == "[0 1 2 3 4]"
 
     def test_str_slice(self):
-        from numpy import array, zeros
+        from numpypy import array, zeros
         a = array(range(5), float)
         b = a[1::2]
         assert str(b) == "[1.0 3.0]"
@@ -109,7 +109,7 @@
         assert str(b) == "[0.0 0.0 0.0 ..., 0.0 0.0 0.0]"
 
     def test_getitem(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         raises(IndexError, "a[5]")
         a = a + a
@@ -118,7 +118,7 @@
         raises(IndexError, "a[-6]")
 
     def test_getitem_tuple(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         raises(IndexError, "a[(1,2)]")
         for i in xrange(5):
@@ -128,7 +128,7 @@
             assert a[i] == b[i]
 
     def test_setitem(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         a[-1] = 5.0
         assert a[4] == 5.0
@@ -136,7 +136,7 @@
         raises(IndexError, "a[-6] = 3.0")
 
     def test_setitem_tuple(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         raises(IndexError, "a[(1,2)] = [0,1]")
         for i in xrange(5):
@@ -147,7 +147,7 @@
             assert a[i] == i
 
     def test_setslice_array(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = array(range(2))
         a[1:4:2] = b
@@ -158,7 +158,7 @@
         assert b[1] == 0.
 
     def test_setslice_of_slice_array(self):
-        from numpy import array, zeros
+        from numpypy import array, zeros
         a = zeros(5)
         a[::2] = array([9., 10., 11.])
         assert a[0] == 9.
@@ -177,7 +177,7 @@
         assert a[0] == 3.
 
     def test_setslice_list(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5), float)
         b = [0., 1.]
         a[1:4:2] = b
@@ -185,20 +185,20 @@
         assert a[3] == 1.
 
     def test_setslice_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5), float)
         a[1:4:2] = 0.
         assert a[1] == 0.
         assert a[3] == 0.
 
     def test_len(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert len(a) == 5
         assert len(a + a) == 5
 
     def test_shape(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert a.shape == (5,)
         b = a + a
@@ -207,7 +207,7 @@
         assert c.shape == (3,)
 
     def test_add(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a + a
         for i in range(5):
@@ -220,7 +220,7 @@
             assert c[i] == bool(a[i] + b[i])
 
     def test_add_other(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = array(range(4, -1, -1))
         c = a + b
@@ -228,20 +228,20 @@
             assert c[i] == 4
 
     def test_add_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a + 5
         for i in range(5):
             assert b[i] == i + 5
 
     def test_radd(self):
-        from numpy import array
+        from numpypy import array
         r = 3 + array(range(3))
         for i in range(3):
             assert r[i] == i + 3
 
     def test_add_list(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = list(reversed(range(5)))
         c = a + b
@@ -250,14 +250,14 @@
             assert c[i] == 4
 
     def test_subtract(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a - a
         for i in range(5):
             assert b[i] == 0
 
     def test_subtract_other(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = array([1, 1, 1, 1, 1])
         c = a - b
@@ -265,29 +265,29 @@
             assert c[i] == i - 1
 
     def test_subtract_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a - 5
         for i in range(5):
             assert b[i] == i - 5
 
     def test_mul(self):
-        import numpy
+        import numpypy
 
-        a = numpy.array(range(5))
+        a = numpypy.array(range(5))
         b = a * a
         for i in range(5):
             assert b[i] == i * i
 
-        a = numpy.array(range(5), dtype=bool)
+        a = numpypy.array(range(5), dtype=bool)
         b = a * a
-        assert b.dtype is numpy.dtype(bool)
-        assert b[0] is numpy.False_
+        assert b.dtype is numpypy.dtype(bool)
+        assert b[0] is numpypy.False_
         for i in range(1, 5):
-            assert b[i] is numpy.True_
+            assert b[i] is numpypy.True_
 
     def test_mul_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a * 5
         for i in range(5):
@@ -295,7 +295,7 @@
 
     def test_div(self):
         from math import isnan
-        from numpy import array, dtype, inf
+        from numpypy import array, dtype, inf
 
         a = array(range(1, 6))
         b = a / a
@@ -327,7 +327,7 @@
         assert c[2] == -inf
 
     def test_div_other(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = array([2, 2, 2, 2, 2], float)
         c = a / b
@@ -335,14 +335,14 @@
             assert c[i] == i / 2.0
 
     def test_div_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a / 5.0
         for i in range(5):
             assert b[i] == i / 5.0
 
     def test_pow(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5), float)
         b = a ** a
         for i in range(5):
@@ -350,7 +350,7 @@
             assert b[i] == i**i
 
     def test_pow_other(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5), float)
         b = array([2, 2, 2, 2, 2])
         c = a ** b
@@ -358,14 +358,14 @@
             assert c[i] == i ** 2
 
     def test_pow_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5), float)
         b = a ** 2
         for i in range(5):
             assert b[i] == i ** 2
 
     def test_mod(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(1,6))
         b = a % a
         for i in range(5):
@@ -378,7 +378,7 @@
             assert b[i] == 1
 
     def test_mod_other(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = array([2, 2, 2, 2, 2])
         c = a % b
@@ -386,14 +386,14 @@
             assert c[i] == i % 2
 
     def test_mod_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a % 2
         for i in range(5):
             assert b[i] == i % 2
 
     def test_pos(self):
-        from numpy import array
+        from numpypy import array
         a = array([1.,-2.,3.,-4.,-5.])
         b = +a
         for i in range(5):
@@ -404,7 +404,7 @@
             assert a[i] == i
 
     def test_neg(self):
-        from numpy import array
+        from numpypy import array
         a = array([1.,-2.,3.,-4.,-5.])
         b = -a
         for i in range(5):
@@ -415,7 +415,7 @@
             assert a[i] == -i
 
     def test_abs(self):
-        from numpy import array
+        from numpypy import array
         a = array([1.,-2.,3.,-4.,-5.])
         b = abs(a)
         for i in range(5):
@@ -426,7 +426,7 @@
             assert a[i + 5] == abs(i)
 
     def test_auto_force(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a - 1
         a[2] = 3
@@ -440,7 +440,7 @@
         assert c[1] == 4
 
     def test_getslice(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         s = a[1:5]
         assert len(s) == 4
@@ -454,7 +454,7 @@
         assert s[0] == 5
 
     def test_getslice_step(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(10))
         s = a[1:9:2]
         assert len(s) == 4
@@ -462,7 +462,7 @@
             assert s[i] == a[2*i+1]
 
     def test_slice_update(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         s = a[0:3]
         s[1] = 10
@@ -473,7 +473,7 @@
 
     def test_slice_invaidate(self):
         # check that slice shares invalidation list with
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         s = a[0:2]
         b = array([10,11])
@@ -487,13 +487,13 @@
         assert d[1] == 12
 
     def test_mean(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert a.mean() == 2.0
         assert a[:4].mean() == 1.5
 
     def test_sum(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert a.sum() == 10.0
         assert a[:4].sum() == 6.0
@@ -502,32 +502,32 @@
         assert a.sum() == 5
 
     def test_prod(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(1,6))
         assert a.prod() == 120.0
         assert a[:4].prod() == 24.0
 
     def test_max(self):
-        from numpy import array
+        from numpypy import array
         a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
         assert a.max() == 5.7
         b = array([])
         raises(ValueError, "b.max()")
 
     def test_max_add(self):
-        from numpy import array
+        from numpypy import array
         a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
         assert (a+a).max() == 11.4
 
     def test_min(self):
-        from numpy import array
+        from numpypy import array
         a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
         assert a.min() == -3.0
         b = array([])
         raises(ValueError, "b.min()")
 
     def test_argmax(self):
-        from numpy import array
+        from numpypy import array
         a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
         assert a.argmax() == 2
         b = array([])
@@ -537,14 +537,14 @@
         assert a.argmax() == 9
 
     def test_argmin(self):
-        from numpy import array
+        from numpypy import array
         a = array([-1.2, 3.4, 5.7, -3.0, 2.7])
         assert a.argmin() == 3
         b = array([])
         raises(ValueError, "b.argmin()")
 
     def test_all(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert a.all() == False
         a[0] = 3.0
@@ -553,7 +553,7 @@
         assert b.all() == True
 
     def test_any(self):
-        from numpy import array, zeros
+        from numpypy import array, zeros
         a = array(range(5))
         assert a.any() == True
         b = zeros(5)
@@ -562,7 +562,7 @@
         assert c.any() == False
 
     def test_dot(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         assert a.dot(a) == 30.0
 
@@ -570,14 +570,14 @@
         assert a.dot(range(5)) == 30
 
     def test_dot_constant(self):
-        from numpy import array
+        from numpypy import array
         a = array(range(5))
         b = a.dot(2.5)
         for i in xrange(5):
             assert b[i] == 2.5 * a[i]
 
     def test_dtype_guessing(self):
-        from numpy import array, dtype
+        from numpypy import array, dtype
 
         assert array([True]).dtype is dtype(bool)
         assert array([True, False]).dtype is dtype(bool)
@@ -590,7 +590,7 @@
 
     def test_comparison(self):
         import operator
-        from numpy import array, dtype
+        from numpypy import array, dtype
 
         a = array(range(5))
         b = array(range(5), float)
@@ -616,7 +616,7 @@
         cls.w_data = cls.space.wrap(struct.pack('dddd', 1, 2, 3, 4))
 
     def test_fromstring(self):
-        from numpy import fromstring
+        from numpypy import fromstring
         a = fromstring(self.data)
         for i in range(4):
             assert a[i] == i + 1
diff --git a/pypy/module/micronumpy/test/test_ufuncs.py b/pypy/module/micronumpy/test/test_ufuncs.py
--- a/pypy/module/micronumpy/test/test_ufuncs.py
+++ b/pypy/module/micronumpy/test/test_ufuncs.py
@@ -4,14 +4,14 @@
 
 class AppTestUfuncs(BaseNumpyAppTest):
     def test_ufunc_instance(self):
-        from numpy import add, ufunc
+        from numpypy import add, ufunc
 
         assert isinstance(add, ufunc)
         assert repr(add) == "<ufunc 'add'>"
         assert repr(ufunc) == "<type 'numpy.ufunc'>"
 
     def test_ufunc_attrs(self):
-        from numpy import add, multiply, sin
+        from numpypy import add, multiply, sin
 
         assert add.identity == 0
         assert multiply.identity == 1
@@ -22,7 +22,7 @@
         assert sin.nin == 1
 
     def test_wrong_arguments(self):
-        from numpy import add, sin
+        from numpypy import add, sin
 
         raises(ValueError, add, 1)
         raises(TypeError, add, 1, 2, 3)
@@ -30,14 +30,14 @@
         raises(ValueError, sin)
 
     def test_single_item(self):
-        from numpy import negative, sign, minimum
+        from numpypy import negative, sign, minimum
 
         assert negative(5.0) == -5.0
         assert sign(-0.0) == 0.0
         assert minimum(2.0, 3.0) == 2.0
 
     def test_sequence(self):
-        from numpy import array, negative, minimum
+        from numpypy import array, negative, minimum
         a = array(range(3))
         b = [2.0, 1.0, 0.0]
         c = 1.0
@@ -71,7 +71,7 @@
             assert min_c_b[i] == min(b[i], c)
 
     def test_negative(self):
-        from numpy import array, negative
+        from numpypy import array, negative
 
         a = array([-5.0, 0.0, 1.0])
         b = negative(a)
@@ -86,7 +86,7 @@
         assert negative(a + a)[3] == -6
 
     def test_abs(self):
-        from numpy import array, absolute
+        from numpypy import array, absolute
 
         a = array([-5.0, -0.0, 1.0])
         b = absolute(a)
@@ -94,7 +94,7 @@
             assert b[i] == abs(a[i])
 
     def test_add(self):
-        from numpy import array, add
+        from numpypy import array, add
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -103,7 +103,7 @@
             assert c[i] == a[i] + b[i]
 
     def test_divide(self):
-        from numpy import array, divide
+        from numpypy import array, divide
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -112,7 +112,7 @@
             assert c[i] == a[i] / b[i]
 
     def test_fabs(self):
-        from numpy import array, fabs
+        from numpypy import array, fabs
         from math import fabs as math_fabs
 
         a = array([-5.0, -0.0, 1.0])
@@ -121,7 +121,7 @@
             assert b[i] == math_fabs(a[i])
 
     def test_minimum(self):
-        from numpy import array, minimum
+        from numpypy import array, minimum
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -130,7 +130,7 @@
             assert c[i] == min(a[i], b[i])
 
     def test_maximum(self):
-        from numpy import array, maximum
+        from numpypy import array, maximum
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -143,7 +143,7 @@
         assert isinstance(x, (int, long))
 
     def test_multiply(self):
-        from numpy import array, multiply
+        from numpypy import array, multiply
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -152,7 +152,7 @@
             assert c[i] == a[i] * b[i]
 
     def test_sign(self):
-        from numpy import array, sign, dtype
+        from numpypy import array, sign, dtype
 
         reference = [-1.0, 0.0, 0.0, 1.0]
         a = array([-5.0, -0.0, 0.0, 6.0])
@@ -171,7 +171,7 @@
         assert a[1] == 0
 
     def test_reciporocal(self):
-        from numpy import array, reciprocal
+        from numpypy import array, reciprocal
 
         reference = [-0.2, float("inf"), float("-inf"), 2.0]
         a = array([-5.0, 0.0, -0.0, 0.5])
@@ -180,7 +180,7 @@
             assert b[i] == reference[i]
 
     def test_subtract(self):
-        from numpy import array, subtract
+        from numpypy import array, subtract
 
         a = array([-5.0, -0.0, 1.0])
         b = array([ 3.0, -2.0,-3.0])
@@ -189,7 +189,7 @@
             assert c[i] == a[i] - b[i]
 
     def test_floor(self):
-        from numpy import array, floor
+        from numpypy import array, floor
 
         reference = [-2.0, -1.0, 0.0, 1.0, 1.0]
         a = array([-1.4, -1.0, 0.0, 1.0, 1.4])
@@ -198,7 +198,7 @@
             assert b[i] == reference[i]
 
     def test_copysign(self):
-        from numpy import array, copysign
+        from numpypy import array, copysign
 
         reference = [5.0, -0.0, 0.0, -6.0]
         a = array([-5.0, 0.0, 0.0, 6.0])
@@ -214,7 +214,7 @@
 
     def test_exp(self):
         import math
-        from numpy import array, exp
+        from numpypy import array, exp
 
         a = array([-5.0, -0.0, 0.0, 12345678.0, float("inf"),
                    -float('inf'), -12343424.0])
@@ -228,7 +228,7 @@
 
     def test_sin(self):
         import math
-        from numpy import array, sin
+        from numpypy import array, sin
 
         a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
         b = sin(a)
@@ -241,7 +241,7 @@
 
     def test_cos(self):
         import math
-        from numpy import array, cos
+        from numpypy import array, cos
 
         a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
         b = cos(a)
@@ -250,7 +250,7 @@
 
     def test_tan(self):
         import math
-        from numpy import array, tan
+        from numpypy import array, tan
 
         a = array([0, 1, 2, 3, math.pi, math.pi*1.5, math.pi*2])
         b = tan(a)
@@ -260,7 +260,7 @@
 
     def test_arcsin(self):
         import math
-        from numpy import array, arcsin
+        from numpypy import array, arcsin
 
         a = array([-1, -0.5, -0.33, 0, 0.33, 0.5, 1])
         b = arcsin(a)
@@ -274,7 +274,7 @@
 
     def test_arccos(self):
         import math
-        from numpy import array, arccos
+        from numpypy import array, arccos
 
         a = array([-1, -0.5, -0.33, 0, 0.33, 0.5, 1])
         b = arccos(a)
@@ -289,7 +289,7 @@
 
     def test_arctan(self):
         import math
-        from numpy import array, arctan
+        from numpypy import array, arctan
 
         a = array([-3, -2, -1, 0, 1, 2, 3, float('inf'), float('-inf')])
         b = arctan(a)
@@ -302,7 +302,7 @@
 
     def test_arcsinh(self):
         import math
-        from numpy import arcsinh, inf
+        from numpypy import arcsinh, inf
 
         for v in [inf, -inf, 1.0, math.e]:
             assert math.asinh(v) == arcsinh(v)
@@ -310,7 +310,7 @@
 
     def test_arctanh(self):
         import math
-        from numpy import arctanh
+        from numpypy import arctanh
 
         for v in [.99, .5, 0, -.5, -.99]:
             assert math.atanh(v) == arctanh(v)
@@ -320,13 +320,13 @@
             assert arctanh(v) == math.copysign(float("inf"), v)
 
     def test_reduce_errors(self):
-        from numpy import sin, add
+        from numpypy import sin, add
 
         raises(ValueError, sin.reduce, [1, 2, 3])
         raises(TypeError, add.reduce, 1)
 
     def test_reduce(self):
-        from numpy import add, maximum
+        from numpypy import add, maximum
 
         assert add.reduce([1, 2, 3]) == 6
         assert maximum.reduce([1]) == 1
@@ -335,7 +335,7 @@
 
     def test_comparisons(self):
         import operator
-        from numpy import equal, not_equal, less, less_equal, greater, greater_equal
+        from numpypy import equal, not_equal, less, less_equal, greater, greater_equal
 
         for ufunc, func in [
             (equal, operator.eq),
diff --git a/pypy/module/pypyjit/interp_jit.py b/pypy/module/pypyjit/interp_jit.py
--- a/pypy/module/pypyjit/interp_jit.py
+++ b/pypy/module/pypyjit/interp_jit.py
@@ -6,6 +6,7 @@
 from pypy.tool.pairtype import extendabletype
 from pypy.rlib.rarithmetic import r_uint, intmask
 from pypy.rlib.jit import JitDriver, hint, we_are_jitted, dont_look_inside
+from pypy.rlib import jit
 from pypy.rlib.jit import current_trace_length, unroll_parameters
 import pypy.interpreter.pyopcode   # for side-effects
 from pypy.interpreter.error import OperationError, operationerrfmt
@@ -200,18 +201,18 @@
     if len(args_w) == 1:
         text = space.str_w(args_w[0])
         try:
-            pypyjitdriver.set_user_param(text)
+            jit.set_user_param(None, text)
         except ValueError:
             raise OperationError(space.w_ValueError,
                                  space.wrap("error in JIT parameters string"))
     for key, w_value in kwds_w.items():
         if key == 'enable_opts':
-            pypyjitdriver.set_param('enable_opts', space.str_w(w_value))
+            jit.set_param(None, 'enable_opts', space.str_w(w_value))
         else:
             intval = space.int_w(w_value)
             for name, _ in unroll_parameters:
                 if name == key and name != 'enable_opts':
-                    pypyjitdriver.set_param(name, intval)
+                    jit.set_param(None, name, intval)
                     break
             else:
                 raise operationerrfmt(space.w_TypeError,
diff --git a/pypy/module/pypyjit/test_pypy_c/test_string.py b/pypy/module/pypyjit/test_pypy_c/test_string.py
--- a/pypy/module/pypyjit/test_pypy_c/test_string.py
+++ b/pypy/module/pypyjit/test_pypy_c/test_string.py
@@ -147,8 +147,8 @@
             i31 = int_gt(i30, 23)
             guard_false(i31, descr=...)
             copystrcontent(p9, p21, 0, i25, i10)
-            i33 = int_eq(i30, 23)
-            guard_false(i33, descr=...)
+            i33 = int_lt(i30, 23)
+            guard_true(i33, descr=...)
             p35 = call(ConstClass(ll_shrink_array__rpy_stringPtr_Signed), p21, i30, descr=<GcPtrCallDescr>)
             guard_no_exception(descr=...)
             i37 = strlen(p35)
diff --git a/pypy/module/sys/test/test_sysmodule.py b/pypy/module/sys/test/test_sysmodule.py
--- a/pypy/module/sys/test/test_sysmodule.py
+++ b/pypy/module/sys/test/test_sysmodule.py
@@ -567,6 +567,11 @@
         import time
         import thread
 
+        # XXX workaround for now: to prevent deadlocks, call
+        # sys._current_frames() once before starting threads.
+        # This is an issue in non-translated versions only.
+        sys._current_frames()
+
         thread_id = thread.get_ident()
         def other_thread():
             print "thread started"
diff --git a/pypy/objspace/std/objspace.py b/pypy/objspace/std/objspace.py
--- a/pypy/objspace/std/objspace.py
+++ b/pypy/objspace/std/objspace.py
@@ -9,7 +9,7 @@
 from pypy.objspace.descroperation import DescrOperation, raiseattrerror
 from pypy.rlib.objectmodel import instantiate, r_dict, specialize, is_annotation_constant
 from pypy.rlib.debug import make_sure_not_resized
-from pypy.rlib.rarithmetic import base_int, widen, is_valid_int
+from pypy.rlib.rarithmetic import base_int, widen
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib import jit
 
@@ -160,7 +160,7 @@
         if isinstance(x, OperationError):
             raise TypeError, ("attempt to wrap already wrapped exception: %s"%
                               (x,))
-        if isinstance(x, (int, long)) and is_valid_int(x):
+        if isinstance(x, int):
             if isinstance(x, bool):
                 return self.newbool(x)
             else:
diff --git a/pypy/rlib/_rffi_stacklet.py b/pypy/rlib/_rffi_stacklet.py
--- a/pypy/rlib/_rffi_stacklet.py
+++ b/pypy/rlib/_rffi_stacklet.py
@@ -3,7 +3,6 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, rffi
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 from pypy.rpython.tool import rffi_platform
-from pypy.rlib.rarithmetic import is_emulated_long
 import sys
 
 
@@ -15,11 +14,7 @@
     separate_module_sources = ['#include "src/stacklet/stacklet.c"\n'],
 )
 if sys.platform == 'win32':
-    if is_emulated_long:
-        asmsrc = 'switch_x64_msvc.asm'
-    else:
-        asmsrc = 'switch_x86_msvc.asm'
-    eci.separate_module_files += (cdir / 'src' / 'stacklet' / asmsrc, )
+    eci.separate_module_files += (cdir / "src/stacklet/switch_x86_msvc.asm", )
     eci.export_symbols += (
         'stacklet_newthread',
         'stacklet_deletethread',
diff --git a/pypy/rlib/clibffi.py b/pypy/rlib/clibffi.py
--- a/pypy/rlib/clibffi.py
+++ b/pypy/rlib/clibffi.py
@@ -5,7 +5,7 @@
 from pypy.rpython.tool import rffi_platform
 from pypy.rpython.lltypesystem import lltype, rffi
 from pypy.rlib.unroll import unrolling_iterable
-from pypy.rlib.rarithmetic import intmask, r_uint, is_emulated_long
+from pypy.rlib.rarithmetic import intmask, r_uint
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.rmmap import alloc
 from pypy.rlib.rdynload import dlopen, dlclose, dlsym, dlsym_byordinal
@@ -27,7 +27,6 @@
 _MSVC = platform.name == "msvc"
 _MINGW = platform.name == "mingw32"
 _WIN32 = _MSVC or _MINGW
-_WIN64 = _WIN32 and is_emulated_long
 _MAC_OS = platform.name == "darwin"
 _FREEBSD_7 = platform.name == "freebsd7"
 
@@ -117,10 +116,6 @@
          ])
 else:
     libffidir = py.path.local(pypydir).join('translator', 'c', 'src', 'libffi_msvc')
-    if not _WIN64:
-        asm_ifc = 'win32.c'
-    else:
-        asm_ifc = 'win64.asm'
     eci = ExternalCompilationInfo(
         includes = ['ffi.h', 'windows.h'],
         libraries = ['kernel32'],
@@ -128,7 +123,7 @@
         separate_module_sources = separate_module_sources,
         separate_module_files = [libffidir.join('ffi.c'),
                                  libffidir.join('prep_cif.c'),
-                                 libffidir.join(asm_ifc),
+                                 libffidir.join('win32.c'),
                                  libffidir.join('pypy_ffi.c'),
                                  ],
         export_symbols = ['ffi_call', 'ffi_prep_cif', 'ffi_prep_closure',
@@ -144,7 +139,7 @@
     FFI_OK = rffi_platform.ConstantInteger('FFI_OK')
     FFI_BAD_TYPEDEF = rffi_platform.ConstantInteger('FFI_BAD_TYPEDEF')
     FFI_DEFAULT_ABI = rffi_platform.ConstantInteger('FFI_DEFAULT_ABI')
-    if _WIN32 and not _WIN64:
+    if _WIN32:
         FFI_STDCALL = rffi_platform.ConstantInteger('FFI_STDCALL')
 
     FFI_TYPE_STRUCT = rffi_platform.ConstantInteger('FFI_TYPE_STRUCT')
@@ -436,7 +431,7 @@
 FUNCFLAG_USE_LASTERROR = 16
 
 def get_call_conv(flags, from_jit):
-    if _WIN32 and not _WIN64 and (flags & FUNCFLAG_CDECL == 0):
+    if _WIN32 and (flags & FUNCFLAG_CDECL == 0):
         return FFI_STDCALL
     else:
         return FFI_DEFAULT_ABI
diff --git a/pypy/rlib/debug.py b/pypy/rlib/debug.py
--- a/pypy/rlib/debug.py
+++ b/pypy/rlib/debug.py
@@ -325,7 +325,7 @@
     """Give a translation-time error if 'x' is not a plain int
     (e.g. if it's a r_longlong or an r_uint).
     """
-    assert type(x) in (int, long)
+    assert type(x) is int
     return x
 
 class Entry(ExtRegistryEntry):
diff --git a/pypy/rlib/rarithmetic.py b/pypy/rlib/rarithmetic.py
--- a/pypy/rlib/rarithmetic.py
+++ b/pypy/rlib/rarithmetic.py
@@ -30,54 +30,22 @@
 
 
 """
-import sys, struct
+import sys
 from pypy.rpython import extregistry
 from pypy.rlib import objectmodel
 
-"""
-Long-term target:
-We want to make pypy very flexible concerning its data type layout.
-This is a larger task for later.
+# set up of machine internals
+_bits = 0
+_itest = 1
+_Ltest = 1L
+while _itest == _Ltest and type(_itest) is int:
+    _itest *= 2
+    _Ltest *= 2
+    _bits += 1
 
-Short-term target:
-We want to run PyPy on windows 64 bit.
-
-Problem:
-On windows 64 bit, integers are only 32 bit. This is a problem for PyPy
-right now, since it assumes that a c long can hold a pointer.
-We therefore set up the target machine constants to obey this rule.
-Right now this affects 64 bit Python only on windows.
-
-Note: We use the struct module, because the array module doesn's support
-all typecodes.
-"""
-
-def _get_bitsize(typecode):
-    return len(struct.pack(typecode, 1)) * 8
-
-_long_typecode = 'l'
-if _get_bitsize('P') > _get_bitsize('l'):
-    _long_typecode = 'P'
-
-def _get_long_bit():
-    # whatever size a long has, make it big enough for a pointer.
-    return _get_bitsize(_long_typecode)
-
-# exported for now for testing array values. 
-# might go into its own module.
-def get_long_pattern(x):
-    """get the bit pattern for a long, adjusted to pointer size"""
-    return struct.pack(_long_typecode, x)
-
-# used in tests for ctypes and for genc and friends
-# to handle the win64 special case:
-is_emulated_long = _long_typecode <> 'l'
-    
-LONG_BIT = _get_long_bit()
-LONG_MASK = (2**LONG_BIT)-1
-LONG_TEST = 2**(LONG_BIT-1)
-
-# XXX this is a good guess, but what if a long long is 128 bit?
+LONG_BIT = _bits+1
+LONG_MASK = _Ltest*2-1
+LONG_TEST = _Ltest
 LONGLONG_BIT  = 64
 LONGLONG_MASK = (2**LONGLONG_BIT)-1
 LONGLONG_TEST = 2**(LONGLONG_BIT-1)
@@ -87,23 +55,17 @@
     LONG_BIT_SHIFT += 1
     assert LONG_BIT_SHIFT < 99, "LONG_BIT_SHIFT value not found?"
 
-"""
-int is no longer necessarily the same size as the target int.
-We therefore can no longer use the int type as it is, but need
-to use long everywhere.
-"""
-    
 def intmask(n):
+    if isinstance(n, int):
+        return int(n)   # possibly bool->int
     if isinstance(n, objectmodel.Symbolic):
         return n        # assume Symbolics don't overflow
     assert not isinstance(n, float)
-    if is_valid_int(n):
-        return int(n)
     n = long(n)
     n &= LONG_MASK
     if n >= LONG_TEST:
         n -= 2*LONG_TEST
-    return n
+    return int(n)
 
 def longlongmask(n):
     assert isinstance(n, (int, long))
@@ -133,8 +95,7 @@
         r_class.BITS == LONG_BIT and r_class.SIGNED)
 _should_widen_type._annspecialcase_ = 'specialize:memo'
 
-def is_valid_int(r):
-    return -sys.maxint - 1 <= r <= sys.maxint
+del _bits, _itest, _Ltest
 
 def ovfcheck(r):
     "NOT_RPYTHON"
@@ -142,10 +103,8 @@
     # raise OverflowError if the operation did overflow
     assert not isinstance(r, r_uint), "unexpected ovf check on unsigned"
     assert not isinstance(r, r_longlong), "ovfcheck not supported on r_longlong"
-    assert not isinstance(r, r_ulonglong), "ovfcheck not supported on r_ulonglong"
-    if type(r) is long and not is_valid_int(r):
-        # the type check is needed to make ovfcheck skip symbolics.
-        # this happens in the garbage collector.
+    assert not isinstance(r,r_ulonglong),"ovfcheck not supported on r_ulonglong"
+    if type(r) is long:
         raise OverflowError, "signed integer expression did overflow"
     return r
 
@@ -457,9 +416,6 @@
 r_longlong = build_int('r_longlong', True, 64)
 r_ulonglong = build_int('r_ulonglong', False, 64)
 
-r_long = build_int('r_long', True, 32)
-r_ulong = build_int('r_ulong', False, 32)
-
 longlongmax = r_longlong(LONGLONG_TEST - 1)
 
 if r_longlong is not r_int:
@@ -467,14 +423,6 @@
 else:
     r_int64 = int
 
-# needed for ll_os_stat.time_t_to_FILE_TIME in the 64 bit case
-if r_long is not r_int:
-    r_uint32 = r_ulong
-else:
-    r_uint32 = r_uint
-
-# needed for ll_time.time_sleep_llimpl
-maxint32 = int((1 << 31) -1)
 
 # the 'float' C type
 
diff --git a/pypy/rlib/rbigint.py b/pypy/rlib/rbigint.py
--- a/pypy/rlib/rbigint.py
+++ b/pypy/rlib/rbigint.py
@@ -1,5 +1,5 @@
 from pypy.rlib.rarithmetic import LONG_BIT, intmask, r_uint, r_ulonglong
-from pypy.rlib.rarithmetic import ovfcheck, r_longlong, widen, is_valid_int
+from pypy.rlib.rarithmetic import ovfcheck, r_longlong, widen
 from pypy.rlib.rarithmetic import most_neg_value_of_same_type
 from pypy.rlib.rfloat import isfinite
 from pypy.rlib.debug import make_sure_not_resized, check_regular_int
@@ -44,19 +44,21 @@
 
 
 def _mask_digit(x):
+    if not we_are_translated():
+        assert type(x) is not long, "overflow occurred!"
     return intmask(x & MASK)
 _mask_digit._annspecialcase_ = 'specialize:argtype(0)'
 
 def _widen_digit(x):
     if not we_are_translated():
-        assert type(x) in (int, long) and is_valid_int(x), "widen_digit() takes an int, got a %r" % type(x)
+        assert type(x) is int, "widen_digit() takes an int, got a %r" % type(x)
     if SHIFT <= 15:
         return int(x)
     return r_longlong(x)
 
 def _store_digit(x):
     if not we_are_translated():
-        assert type(x) in (int, long) and is_valid_int(x), "store_digit() takes an int, got a %r" % type(x)
+        assert type(x) is int, "store_digit() takes an int, got a %r" % type(x)
     if SHIFT <= 15:
         return rffi.cast(rffi.SHORT, x)
     elif SHIFT <= 31:
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(lltype.Signed, end_ptr[0]) -
-                      rffi.cast(lltype.Signed, ll_input))
+            endpos = (rffi.cast(rffi.LONG, end_ptr[0]) -
+                      rffi.cast(rffi.LONG, 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(lltype.Signed, end_ptr[0]) -
-                              rffi.cast(lltype.Signed, digits))
+                    buflen = (rffi.cast(rffi.LONG, end_ptr[0]) -
+                              rffi.cast(rffi.LONG, 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
@@ -28,7 +28,7 @@
 
 
 def erase_int(x):
-    assert isinstance(x, (int, long))
+    assert isinstance(x, int)
     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, long))
+    assert isinstance(y._x, int)
     return y._x
 
 
diff --git a/pypy/rpython/llinterp.py b/pypy/rpython/llinterp.py
--- a/pypy/rpython/llinterp.py
+++ b/pypy/rpython/llinterp.py
@@ -1018,25 +1018,22 @@
     # Overflow-detecting variants
 
     def op_int_neg_ovf(self, x):
-        # assert type(x) is int
-        assert isinstance(x, (int, long))
+        assert type(x) is int
         try:
             return ovfcheck(-x)
         except OverflowError:
             self.make_llexception()
 
     def op_int_abs_ovf(self, x):
-        # assert type(x) is int
-        assert isinstance(x, (int, long))
+        assert type(x) is int
         try:
             return ovfcheck(abs(x))
         except OverflowError:
             self.make_llexception()
 
     def op_int_lshift_ovf(self, x, y):
-        # win64: int or long because target size differs
-        assert isinstance(x, (int, long))
-        assert isinstance(y, (int, long))
+        assert isinstance(x, int)
+        assert isinstance(y, int)
         try:
             return ovfcheck(x << y)
         except OverflowError:
@@ -1077,15 +1074,15 @@
                 self.make_llexception()
         """ % locals()).compile() in globals(), d
 
-    _makefunc2('op_int_add_ovf', '+', '(int, long, llmemory.AddressOffset)')
-    _makefunc2('op_int_mul_ovf', '*', '(int, long, llmemory.AddressOffset)', '(int, long)')
-    _makefunc2('op_int_sub_ovf',          '-',  '(int, long)')
-    _makefunc2('op_int_floordiv_ovf',     '//', '(int, long)')  # XXX negative args
-    _makefunc2('op_int_floordiv_zer',     '//', '(int, long)')  # can get off-by-one
-    _makefunc2('op_int_floordiv_ovf_zer', '//', '(int, long)')  # (see op_int_floordiv)
-    _makefunc2('op_int_mod_ovf',          '%',  '(int, long)')
-    _makefunc2('op_int_mod_zer',          '%',  '(int, long)')
-    _makefunc2('op_int_mod_ovf_zer',      '%',  '(int, long)')
+    _makefunc2('op_int_add_ovf', '+', '(int, llmemory.AddressOffset)')
+    _makefunc2('op_int_mul_ovf', '*', '(int, llmemory.AddressOffset)', 'int')
+    _makefunc2('op_int_sub_ovf',          '-',  'int')
+    _makefunc2('op_int_floordiv_ovf',     '//', 'int')  # XXX negative args
+    _makefunc2('op_int_floordiv_zer',     '//', 'int')  # can get off-by-one
+    _makefunc2('op_int_floordiv_ovf_zer', '//', 'int')  # (see op_int_floordiv)
+    _makefunc2('op_int_mod_ovf',          '%',  'int')
+    _makefunc2('op_int_mod_zer',          '%',  'int')
+    _makefunc2('op_int_mod_ovf_zer',      '%',  'int')
 
     _makefunc2('op_uint_floordiv_zer',    '//', 'r_uint')
     _makefunc2('op_uint_mod_zer',         '%',  'r_uint')
@@ -1107,7 +1104,7 @@
             x = x.default
         # if type(x) is a subclass of Symbolic, bool(x) will usually raise
         # a TypeError -- unless __nonzero__ has been explicitly overridden.
-        assert isinstance(x, (int, long, Symbolic))
+        assert isinstance(x, (int, Symbolic))
         return bool(x)
 
     # hack for jit.codegen.llgraph
diff --git a/pypy/rpython/lltypesystem/ll2ctypes.py b/pypy/rpython/lltypesystem/ll2ctypes.py
--- a/pypy/rpython/lltypesystem/ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/ll2ctypes.py
@@ -15,7 +15,6 @@
     load_library_kwargs = {}
 
 import os
-from pypy import conftest
 from pypy.rpython.lltypesystem import lltype, llmemory
 from pypy.rpython.extfunc import ExtRegistryEntry
 from pypy.rlib.objectmodel import Symbolic, ComputedIntSymbolic
@@ -177,17 +176,6 @@
     assert max_n >= 0
     ITEM = A.OF
     ctypes_item = get_ctypes_type(ITEM, delayed_builders)
-    # Python 2.5 ctypes can raise OverflowError on 64-bit builds
-    for n in [sys.maxint, 2**31]:
-        MAX_SIZE = n/64
-        try:
-            PtrType = ctypes.POINTER(MAX_SIZE * ctypes_item)
-        except (OverflowError, AttributeError), e:
-            pass      #        ^^^ bah, blame ctypes
-        else:
-            break
-    else:
-        raise e
 
     class CArray(ctypes.Structure):
         if not A._hints.get('nolength'):
@@ -219,9 +207,6 @@
                     cls._ptrtype = ctypes.POINTER(cls.MAX_SIZE * ctypes_item)
                 except OverflowError, e:
                     pass
-                except AttributeError, e:
-                    pass # XXX win64 failure and segfault, afterwards:
-                    # AttributeError: class must define a '_length_' attribute, which must be a positive integer
                 else:
                     break
             else:
diff --git a/pypy/rpython/lltypesystem/llmemory.py b/pypy/rpython/lltypesystem/llmemory.py
--- a/pypy/rpython/lltypesystem/llmemory.py
+++ b/pypy/rpython/lltypesystem/llmemory.py
@@ -57,7 +57,7 @@
         return "<ItemOffset %r %r>" % (self.TYPE, self.repeat)
 
     def __mul__(self, other):
-        if not isinstance(other, (int, long)):
+        if not isinstance(other, int):
             return NotImplemented
         return ItemOffset(self.TYPE, self.repeat * other)
 
diff --git a/pypy/rpython/lltypesystem/lltype.py b/pypy/rpython/lltypesystem/lltype.py
--- a/pypy/rpython/lltypesystem/lltype.py
+++ b/pypy/rpython/lltypesystem/lltype.py
@@ -1,8 +1,7 @@
 import py
 from pypy.rlib.rarithmetic import (r_int, r_uint, intmask, r_singlefloat,
                                    r_ulonglong, r_longlong, r_longfloat,
-                                   base_int, normalizedinttype, longlongmask,
-                                   r_uint32)
+                                   base_int, normalizedinttype, longlongmask)
 from pypy.rlib.objectmodel import Symbolic
 from pypy.tool.uid import Hashable
 from pypy.tool.identity_dict import identity_dict
@@ -1655,7 +1654,7 @@
     __slots__ = ('items',)
 
     def __init__(self, TYPE, n, initialization=None, parent=None, parentindex=None):
-        if not isinstance(n, (int, long)):
+        if not isinstance(n, int):
             raise TypeError, "array length must be an int"
         if n < 0:
             raise ValueError, "negative array length"
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
@@ -22,14 +22,14 @@
 from pypy.rpython.lltypesystem.llmemory import AddressAsInt
 
 if r_longlong is r_int:
-    r_longlong_arg = (r_longlong, int, long)
-    r_longlong_result = long # XXX was int
+    r_longlong_arg = (r_longlong, int)
+    r_longlong_result = int
 else:
     r_longlong_arg = r_longlong
     r_longlong_result = r_longlong
 
 argtype_by_name = {
-    'int': (int, long),
+    'int': int,
     'float': float,
     'uint': r_uint,
     'llong': r_longlong_arg,
@@ -173,7 +173,7 @@
 
 def op_direct_ptradd(obj, index):
     checkptr(obj)
-    assert isinstance(index, (int, long))
+    assert isinstance(index, int)
     return lltype.direct_ptradd(obj, index)
 
 
@@ -182,30 +182,29 @@
     return not b
 
 def op_int_add(x, y):
-    if not isinstance(x, (int, long, llmemory.AddressOffset)):
+    if not isinstance(x, (int, llmemory.AddressOffset)):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, (int, long, llmemory.AddressOffset))
+    assert isinstance(y, (int, llmemory.AddressOffset))
     return intmask(x + y)
 
 def op_int_sub(x, y):
-    if not isinstance(x, (int, long)):
+    if not isinstance(x, int):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return intmask(x - y)
 
 def op_int_ge(x, y):
     # special case for 'AddressOffset >= 0'
-    assert isinstance(x, (int, long, llmemory.AddressOffset))
-    assert isinstance(y, (int, long))
+    assert isinstance(x, (int, llmemory.AddressOffset))
+    assert isinstance(y, int)
     return x >= y
 
 def op_int_lt(x, y):
     # special case for 'AddressOffset < 0'
-    # hack for win64
-    assert isinstance(x, (int, long, llmemory.AddressOffset))
-    assert isinstance(y, (int, long))
+    assert isinstance(x, (int, llmemory.AddressOffset))
+    assert isinstance(y, int)
     return x < y
 
 def op_int_between(a, b, c):
@@ -215,51 +214,50 @@
     return a <= b < c
 
 def op_int_and(x, y):
-    if not isinstance(x, (int, long)):
+    if not isinstance(x, int):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return x & y
 
 def op_int_or(x, y):
-    if not isinstance(x, (int, long)):
+    if not isinstance(x, int):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     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, long))
-    assert isinstance(y, (int, long))
+    assert isinstance(x, int)
+    assert isinstance(y, int)
     return x ^ y
 
 def op_int_mul(x, y):
-    assert isinstance(x, (int, long, llmemory.AddressOffset))
-    assert isinstance(y, (int, long, llmemory.AddressOffset))
+    assert isinstance(x, (int, llmemory.AddressOffset))
+    assert isinstance(y, (int, llmemory.AddressOffset))
     return intmask(x * y)
 
 def op_int_rshift(x, y):
-    if not isinstance(x, (int, long)):
+    if not isinstance(x, int):
         from pypy.rpython.lltypesystem import llgroup
         assert isinstance(x, llgroup.CombinedSymbolic)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return x >> y
 
 def op_int_floordiv(x, y):
-    # hack for win64
-    assert isinstance(x, (int, long, llmemory.AddressOffset))
-    assert isinstance(y, (int, long, llmemory.AddressOffset))
+    assert isinstance(x, (int, llmemory.AddressOffset))
+    assert isinstance(y, (int, 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, long, llmemory.AddressOffset))
-    assert isinstance(y, (int, long, llmemory.AddressOffset))
+    assert isinstance(x, (int, llmemory.AddressOffset))
+    assert isinstance(y, (int, llmemory.AddressOffset))
     r = x%y
     if x^y < 0 and x%y != 0:
         r -= y
@@ -283,22 +281,22 @@
 
 def op_uint_lshift(x, y):
     assert isinstance(x, r_uint)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return r_uint(x << y)
 
 def op_uint_rshift(x, y):
     assert isinstance(x, r_uint)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return r_uint(x >> y)
 
 def op_llong_lshift(x, y):
     assert isinstance(x, r_longlong_arg)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return r_longlong_result(x << y)
 
 def op_llong_rshift(x, y):
     assert isinstance(x, r_longlong_arg)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return r_longlong_result(x >> y)
 
 def op_ullong_lshift(x, y):
@@ -308,7 +306,7 @@
 
 def op_ullong_rshift(x, y):
     assert isinstance(x, r_ulonglong)
-    assert isinstance(y, (int, long))
+    assert isinstance(y, int)
     return r_ulonglong(x >> y)
 
 def op_same_as(x):
@@ -320,8 +318,7 @@
 op_cast_primitive.need_result_type = True
 
 def op_cast_int_to_float(i):
-    # assert type(i) is int
-    assert isinstance(i, (int, long))
+    assert type(i) is int
     return float(i)
 
 def op_cast_uint_to_float(u):
@@ -343,8 +340,7 @@
     return ui + li
 
 def op_cast_int_to_char(b):
-    #assert type(b) is int
-    assert isinstance(b, (int, long))
+    assert type(b) is int
     return chr(b)
 
 def op_cast_bool_to_int(b):
@@ -388,12 +384,11 @@
     return ord(b)
 
 def op_cast_int_to_unichar(b):
-    assert isinstance(b, (int, long))
+    assert type(b) is int
     return unichr(b)
 
 def op_cast_int_to_uint(b):
-    # assert type(b) is int
-    assert isinstance(b, (int, long))
+    assert type(b) is int
     return r_uint(b)
 
 def op_cast_uint_to_int(b):
@@ -401,7 +396,7 @@
     return intmask(b)
 
 def op_cast_int_to_longlong(b):
-    assert isinstance(b, (int, long))
+    assert type(b) is int
     return r_longlong_result(b)
 
 def op_truncate_longlong_to_int(b):
@@ -572,7 +567,7 @@
     if isinstance(memberoffset, llgroup.GroupMemberOffset):
         return memberoffset.index != 0
     else:
-        assert isinstance(memberoffset, (int, long))
+        assert isinstance(memberoffset, int)
         return memberoffset != 0
 
 def op_extract_ushort(combinedoffset):
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
@@ -17,7 +17,6 @@
 from pypy.rlib.objectmodel import we_are_translated
 from pypy.rlib.rstring import StringBuilder, UnicodeBuilder
 from pypy.rpython.lltypesystem import llmemory
-from pypy.rlib.rarithmetic import LONG_BIT
 import os, sys
 
 class CConstant(Symbolic):
@@ -647,9 +646,6 @@
 # float *
 FLOATP = lltype.Ptr(lltype.Array(FLOAT, hints={'nolength': True}))
 
-# Signed *
-SIGNEDP = lltype.Ptr(lltype.Array(lltype.Signed, hints={'nolength': True}))
-
 # various type mapping
 
 # conversions between str and char*
@@ -891,7 +887,7 @@
             size = llmemory.sizeof(tp)    # a symbolic result in this case
         return size
     if isinstance(tp, lltype.Ptr) or tp is llmemory.Address:
-        tp = lltype.Signed
+        tp = ULONG     # XXX!
     if tp is lltype.Char or tp is lltype.Bool:
         return 1
     if tp is lltype.UniChar:
@@ -902,7 +898,7 @@
         return 4
     assert isinstance(tp, lltype.Number)
     if tp is lltype.Signed:
-        return LONG_BIT/8
+        return ULONG._type.BITS/8
     return tp._type.BITS/8
 sizeof._annspecialcase_ = 'specialize:memo'
 
@@ -922,14 +918,11 @@
 offsetof._annspecialcase_ = 'specialize:memo'
 
 # check that we have a sane configuration
-# XXX re-enable this after correcting the windows case
-"""
-assert maxint == (1 << (8 * sizeof(lltype.Signed) - 1)) - 1, (
+assert sys.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" % (
-    maxint, sizeof(lltype.Signed)))
-"""
+    sys.maxint, sizeof(lltype.Signed)))
 
 # ********************** some helpers *******************
 
diff --git a/pypy/rpython/lltypesystem/test/test_ll2ctypes.py b/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
--- a/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
+++ b/pypy/rpython/lltypesystem/test/test_ll2ctypes.py
@@ -16,27 +16,12 @@
 from pypy.rpython.test.test_llinterp import interpret
 from pypy.annotation.annrpython import RPythonAnnotator
 from pypy.rpython.rtyper import RPythonTyper
-from pypy.rlib.rarithmetic import r_uint, get_long_pattern, is_emulated_long
+
 
 if False:    # for now, please keep it False by default
     from pypy.rpython.lltypesystem import ll2ctypes
     ll2ctypes.do_allocation_in_far_regions()
 
-"""
-Win64:
-To decouple the cpython machine level long from the faked integer
-of the target rpython, I replaced most 'lltype.Signed' by 'rffi.LONG'.
-It would be nicer to replace all lltypes constants by rffi equivalents,
-or better if we had a way to address the specific different types of
-the current and the target system layout explicitly.
-Let's think of that when we go further and make the target completely
-independent and configurable.
-Why most and not all replaced?
-Tests with direct tests become cumbersome, instead of direct number
-assignment rffi.setintfield(s, 'x', 123) must be used.
-So in cases with number constants, where the size is not relevant,
-I kept lltype.signed .
-"""
 
 class TestLL2Ctypes(object):
 
@@ -48,7 +33,7 @@
         assert lltype2ctypes('?') == ord('?')
         assert lltype2ctypes('\xE0') == 0xE0
         assert lltype2ctypes(unichr(1234)) == 1234
-        assert ctypes2lltype(rffi.LONG, 5) == 5
+        assert ctypes2lltype(lltype.Signed, 5) == 5
         assert ctypes2lltype(lltype.Char, ord('a')) == 'a'
         assert ctypes2lltype(lltype.UniChar, ord(u'x')) == u'x'
         assert ctypes2lltype(lltype.Char, 0xFF) == '\xFF'
@@ -61,15 +46,15 @@
         res = ctypes2lltype(lltype.SingleFloat, ctypes.c_float(-3.5))
         assert isinstance(res, rffi.r_singlefloat)
         assert float(res) == -3.5
-        assert lltype2ctypes(rffi.r_ulong(-1)) == (1 << rffi.r_ulong.BITS) - 1
+        assert lltype2ctypes(rffi.r_ulong(-1)) == sys.maxint * 2 + 1
         res = ctypes2lltype(lltype.Unsigned, sys.maxint * 2 + 1)
-        assert (res, type(res)) == (r_uint(-1), r_uint)
+        assert (res, type(res)) == (rffi.r_ulong(-1), rffi.r_ulong)
         assert ctypes2lltype(lltype.Bool, 0) is False
         assert ctypes2lltype(lltype.Bool, 1) is True
 
-        res = lltype2ctypes(llmemory.sizeof(rffi.LONG))
+        res = lltype2ctypes(llmemory.sizeof(lltype.Signed))
         assert res == struct.calcsize("l")
-        S = lltype.Struct('S', ('x', rffi.LONG), ('y', rffi.LONG))
+        S = lltype.Struct('S', ('x', lltype.Signed), ('y', lltype.Signed))
         res = lltype2ctypes(llmemory.sizeof(S))
         assert res == struct.calcsize("ll")
 
@@ -84,7 +69,7 @@
     def test_simple_struct(self):
         S = lltype.Struct('S', ('x', lltype.Signed), ('y', lltype.Signed))
         s = lltype.malloc(S, flavor='raw')
-        rffi.setintfield(s, 'x', 123)
+        s.x = 123
         sc = lltype2ctypes(s)
         assert isinstance(sc.contents, ctypes.Structure)
         assert sc.contents.x == 123
@@ -159,7 +144,7 @@
 
     def test_array_inside_struct(self):
         # like rstr.STR, but not Gc
-        STR = lltype.Struct('STR', ('x', rffi.LONG), ('y', lltype.Array(lltype.Char)))
+        STR = lltype.Struct('STR', ('x', lltype.Signed), ('y', lltype.Array(lltype.Char)))
         a = lltype.malloc(STR, 3, flavor='raw')
         a.y[0] = 'x'
         a.y[1] = 'y'
@@ -186,7 +171,7 @@
         assert a[2] == 456
         a[3] = 789
         assert ac.contents.items[3] == 789
-        assert ctypes.sizeof(ac.contents) == 10 * rffi.sizeof(lltype.Signed)
+        assert ctypes.sizeof(ac.contents) == 10 * ctypes.sizeof(ctypes.c_long)
         lltype.free(a, flavor='raw')
         assert not ALLOCATED     # detects memory leaks in the test
 
@@ -238,20 +223,20 @@
 
     def test_func_not_in_clib(self):
         eci = ExternalCompilationInfo(libraries=['m'])
-        foobar = rffi.llexternal('I_really_dont_exist', [], rffi.LONG)
+        foobar = rffi.llexternal('I_really_dont_exist', [], lltype.Signed)
         py.test.raises(NotImplementedError, foobar)
 
-        foobar = rffi.llexternal('I_really_dont_exist', [], rffi.LONG,
+        foobar = rffi.llexternal('I_really_dont_exist', [], lltype.Signed,
                                  compilation_info=eci)    # math library
         py.test.raises(NotImplementedError, foobar)
 
         eci = ExternalCompilationInfo(libraries=['m', 'z'])
-        foobar = rffi.llexternal('I_really_dont_exist', [], rffi.LONG,
+        foobar = rffi.llexternal('I_really_dont_exist', [], lltype.Signed,
                                  compilation_info=eci)  # math and zlib
         py.test.raises(NotImplementedError, foobar)
 
         eci = ExternalCompilationInfo(libraries=['I_really_dont_exist_either'])
-        foobar = rffi.llexternal('I_really_dont_exist', [], rffi.LONG,
+        foobar = rffi.llexternal('I_really_dont_exist', [], lltype.Signed,
                                  compilation_info=eci)
         py.test.raises(NotImplementedError, foobar)
         assert not ALLOCATED     # detects memory leaks in the test
@@ -414,9 +399,10 @@
 
         b = rffi.cast(lltype.Ptr(B), a)
 
-        expected = ''
+        checker = array.array('l')
         for i in range(10):
-            expected += get_long_pattern(i*i)
+            checker.append(i*i)
+        expected = checker.tostring()
 
         for i in range(len(expected)):
             assert b[i] == expected[i]
@@ -432,7 +418,7 @@
             assert e[i] == i*i
 
         c = lltype.nullptr(rffi.VOIDP.TO)
-        addr = rffi.cast(rffi.LONG, c)
+        addr = rffi.cast(lltype.Signed, c)
         assert addr == 0
 
         lltype.free(a, flavor='raw')
@@ -458,13 +444,8 @@
 
         FUNCTYPE = lltype.FuncType([lltype.Signed], lltype.Signed)
         cdummy = lltype2ctypes(llhelper(lltype.Ptr(FUNCTYPE), dummy))
-        if not is_emulated_long:
-            assert isinstance(cdummy,
-                              ctypes.CFUNCTYPE(ctypes.c_long, ctypes.c_long))
-        else:
-            # XXX maybe we skip this if it breaks on some platforms
-            assert isinstance(cdummy,
-                              ctypes.CFUNCTYPE(ctypes.c_longlong, ctypes.c_longlong))
+        assert isinstance(cdummy,
+                          ctypes.CFUNCTYPE(ctypes.c_long, ctypes.c_long))
         res = cdummy(41)
         assert res == 42
         lldummy = ctypes2lltype(lltype.Ptr(FUNCTYPE), cdummy)
@@ -474,7 +455,7 @@
         assert not ALLOCATED     # detects memory leaks in the test
 
     def test_funcptr2(self):
-        FUNCTYPE = lltype.FuncType([rffi.CCHARP], rffi.LONG)
+        FUNCTYPE = lltype.FuncType([rffi.CCHARP], lltype.Signed)
         cstrlen = standard_c_lib.strlen
         llstrlen = ctypes2lltype(lltype.Ptr(FUNCTYPE), cstrlen)
         assert lltype.typeOf(llstrlen) == lltype.Ptr(FUNCTYPE)
@@ -564,9 +545,8 @@
 
         checkval(uninitialized2ctypes(rffi.CHAR), 'B')
         checkval(uninitialized2ctypes(rffi.SHORT), 'h')
-        if not is_emulated_long:
-            checkval(uninitialized2ctypes(rffi.INT), 'i')
-            checkval(uninitialized2ctypes(rffi.UINT), 'I')
+        checkval(uninitialized2ctypes(rffi.INT), 'i')
+        checkval(uninitialized2ctypes(rffi.UINT), 'I')
         checkval(uninitialized2ctypes(rffi.LONGLONG), 'q')
         checkval(uninitialized2ctypes(rffi.DOUBLE), 'd')
         checkobj(uninitialized2ctypes(rffi.INTP),
@@ -574,7 +554,7 @@
         checkobj(uninitialized2ctypes(rffi.CCHARP),
                  ctypes.sizeof(ctypes.c_void_p))
 
-        S = lltype.Struct('S', ('x', rffi.LONG), ('y', rffi.LONG))
+        S = lltype.Struct('S', ('x', lltype.Signed), ('y', lltype.Signed))
         s = lltype.malloc(S, flavor='raw')
         sc = lltype2ctypes(s)
         checkval(sc.contents.x, 'l')
@@ -737,13 +717,9 @@
         assert not ALLOCATED     # detects memory leaks in the test
 
     def test_get_errno(self):
-        # win64: works with python 2.6.7, but not with 2.7.2
-        # XXX check what is different with ctypes!
         eci = ExternalCompilationInfo(includes=['string.h'])
         if sys.platform.startswith('win'):
             underscore_on_windows = '_'
-            if sys.version.startswith('2.7.2 '):
-                py.test.skip('ctypes is buggy. errno crashes with win64 and python 2.7.2')
         else:
             underscore_on_windows = ''
         strlen = rffi.llexternal('strlen', [rffi.CCHARP], rffi.SIZE_T,
@@ -754,7 +730,7 @@
         buffer = lltype.malloc(rffi.CCHARP.TO, 5, flavor='raw')
         written = os_write(12312312, buffer, 5)
         lltype.free(buffer, flavor='raw')
-        assert rffi.cast(rffi.LONG, written) < 0
+        assert rffi.cast(lltype.Signed, written) < 0
         # the next line is a random external function call,
         # to check that it doesn't reset errno
         strlen("hi!")
@@ -873,9 +849,9 @@
             return one + get_x()
 
         def fy():
-            one = rffi.cast(rffi.LONG, get_y())
+            one = rffi.cast(lltype.Signed, get_y())
             set_y(rffi.cast(rffi.INT, 13))
-            return one + rffi.cast(rffi.LONG, get_y())
+            return one + rffi.cast(lltype.Signed, get_y())
 
         def g():
             l = rffi.liststr2charpp(["a", "b", "c"])
@@ -940,7 +916,7 @@
         lltype.free(a, flavor='raw')
 
     def test_array_type_bug(self):
-        A = lltype.Array(rffi.LONG)
+        A = lltype.Array(lltype.Signed)
         a1 = lltype.malloc(A, 0, flavor='raw')
         a2 = lltype.malloc(A, 0, flavor='raw')
         c1 = lltype2ctypes(a1)
@@ -1030,7 +1006,7 @@
 
     def test_recursive_struct_more(self):
         NODE = lltype.ForwardReference()
-        NODE.become(lltype.Struct('NODE', ('value', rffi.LONG),
+        NODE.become(lltype.Struct('NODE', ('value', lltype.Signed),
                                           ('next', lltype.Ptr(NODE))))
         CNODEPTR = get_ctypes_type(NODE)
         pc = CNODEPTR()
@@ -1058,11 +1034,11 @@
         assert p.pong.ping == p
 
     def test_typedef(self):
-        assert ctypes2lltype(lltype.Typedef(rffi.LONG, 'test'), 6) == 6
+        assert ctypes2lltype(lltype.Typedef(lltype.Signed, 'test'), 6) == 6
         assert ctypes2lltype(lltype.Typedef(lltype.Float, 'test2'), 3.4) == 3.4
 
-        assert get_ctypes_type(rffi.LONG) == get_ctypes_type(
-            lltype.Typedef(rffi.LONG, 'test3'))
+        assert get_ctypes_type(lltype.Signed) == get_ctypes_type(
+            lltype.Typedef(lltype.Signed, 'test3'))
 
     def test_cast_adr_to_int(self):
         class someaddr(object):
@@ -1070,7 +1046,7 @@
                 return sys.maxint/2 * 3
 
         res = cast_adr_to_int(someaddr())
-        assert isinstance(res, (int, long))
+        assert isinstance(res, int)
         assert res == -sys.maxint/2 - 3
 
     def test_cast_gcref_back_and_forth(self):
@@ -1323,7 +1299,7 @@
         p = lltype.malloc(S, flavor='raw')
         a = llmemory.cast_ptr_to_adr(p)
         i = llmemory.cast_adr_to_int(a, "forced")
-        assert isinstance(i, (int, long))
+        assert type(i) is int
         assert i == llmemory.cast_adr_to_int(a, "forced")
         lltype.free(p, flavor='raw')
 
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.SIGNEDP.TO, self.BUFSIZE,
+        self.writebuffer = lltype.malloc(rffi.LONGP.TO, self.BUFSIZE,
                                          flavor='raw')
         self.buf_count = 0
         if self.gcflag == 0:
diff --git a/pypy/rpython/memory/gctransform/asmgcroot.py b/pypy/rpython/memory/gctransform/asmgcroot.py
--- a/pypy/rpython/memory/gctransform/asmgcroot.py
+++ b/pypy/rpython/memory/gctransform/asmgcroot.py
@@ -533,11 +533,10 @@
         # The initial gcmap table contains addresses to a JMP
         # instruction that jumps indirectly to the real code.
         # Replace them with the target addresses.
-        assert rffi.SIGNEDP is rffi.LONGP, "win64 support missing"
         while start < end:
             code = rffi.cast(rffi.CCHARP, start.address[0])[0]
             if code == '\xe9': # jmp
-                rel32 = rffi.cast(rffi.SIGNEDP, start.address[0]+1)[0]
+                rel32 = rffi.cast(rffi.LONGP, start.address[0]+1)[0]
                 target = start.address[0] + (rel32 + 5)
                 start.address[0] = target
             start += arrayitemsize
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,5 +1,4 @@
 from pypy.rpython.lltypesystem import lltype, llmemory, llarena
-from pypy.rlib.rarithmetic import is_emulated_long
 
 import struct
 
@@ -13,11 +12,7 @@
                     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.SIGNEDP.TO, len(alist), flavor='raw')
+            idarray = lltype.malloc(rffi.LONGP.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.py b/pypy/rpython/module/ll_os.py
--- a/pypy/rpython/module/ll_os.py
+++ b/pypy/rpython/module/ll_os.py
@@ -428,13 +428,9 @@
         UTIMBUFP = lltype.Ptr(self.UTIMBUF)
         os_utime = self.llexternal('utime', [rffi.CCHARP, UTIMBUFP], rffi.INT)
 
-        if not _WIN32:
-            includes = ['sys/time.h']
-        else:
-            includes = ['time.h']
         class CConfig:
             _compilation_info_ = ExternalCompilationInfo(
-                includes=includes
+                includes=['sys/time.h']
             )
             HAVE_UTIMES = platform.Has('utimes')
         config = platform.configure(CConfig)
@@ -444,14 +440,9 @@
 
         if config['HAVE_UTIMES']:
             class CConfig:
-                if not _WIN32:
-                    _compilation_info_ = ExternalCompilationInfo(
-                        includes = ['sys/time.h']
-                    )
-                else:
-                    _compilation_info_ = ExternalCompilationInfo(
-                        includes = ['time.h']
-                    )
+                _compilation_info_ = ExternalCompilationInfo(
+                    includes = ['sys/time.h']
+                )
                 TIMEVAL = platform.Struct('struct timeval', [('tv_sec', rffi.LONG),
                                                              ('tv_usec', rffi.LONG)])
             config = platform.configure(CConfig)
@@ -556,10 +547,10 @@
                 # The fields of a FILETIME structure are the hi and lo parts
                 # of a 64-bit value expressed in 100 nanosecond units
                 # (of course).
-                result = (rffi.cast(lltype.Signed, pkernel.c_dwHighDateTime) * 429.4967296 +
-                          rffi.cast(lltype.Signed, pkernel.c_dwLowDateTime) * 1E-7,
-                          rffi.cast(lltype.Signed, puser.c_dwHighDateTime) * 429.4967296 +
-                          rffi.cast(lltype.Signed, puser.c_dwLowDateTime) * 1E-7,
+                result = (pkernel.c_dwHighDateTime*429.4967296 +
+                          pkernel.c_dwLowDateTime*1E-7,
+                          puser.c_dwHighDateTime*429.4967296 +
+                          puser.c_dwLowDateTime*1E-7,
                           0, 0, 0)
                 lltype.free(puser,   flavor='raw')
                 lltype.free(pkernel, flavor='raw')
@@ -817,7 +808,7 @@
                                   [traits.CCHARP, rffi.INT, rffi.MODE_T],
                                   rffi.INT)
         def os_open_llimpl(path, flags, mode):
-            result = rffi.cast(lltype.Signed, os_open(path, flags, mode))
+            result = rffi.cast(rffi.LONG, os_open(path, flags, mode))
             if result == -1:
                 raise OSError(rposix.get_errno(), "os_open failed")
             return result
@@ -1343,7 +1334,7 @@
         os_isatty = self.llexternal(underscore_on_windows+'isatty', [rffi.INT], rffi.INT)
 
         def isatty_llimpl(fd):
-            res = rffi.cast(lltype.Signed, os_isatty(rffi.cast(rffi.INT, fd)))
+            res = rffi.cast(rffi.LONG, os_isatty(rffi.cast(rffi.INT, fd)))
             return res != 0
 
         return extdef([int], bool, llimpl=isatty_llimpl,
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,7 +319,6 @@
     assert len(STAT_FIELDS) == 10    # no extra fields on Windows
 
     def attributes_to_mode(attributes):
-        attributes = lltype.r_uint(attributes)
         m = 0
         if attributes & win32traits.FILE_ATTRIBUTE_DIRECTORY:
             m |= win32traits._S_IFDIR | 0111 # IFEXEC for user,group,other
@@ -457,6 +456,6 @@
 
 def time_t_to_FILE_TIME(time, filetime):
     ft = lltype.r_longlong((time + secs_between_epochs) * 10000000)
-    filetime.c_dwHighDateTime = lltype.r_uint32(ft >> 32)
-    filetime.c_dwLowDateTime = lltype.r_uint32(ft & lltype.r_uint(-1))
+    filetime.c_dwHighDateTime = lltype.r_uint(ft >> 32)
+    filetime.c_dwLowDateTime = lltype.r_uint(ft & lltype.r_uint(-1))
 
diff --git a/pypy/rpython/module/ll_time.py b/pypy/rpython/module/ll_time.py
--- a/pypy/rpython/module/ll_time.py
+++ b/pypy/rpython/module/ll_time.py
@@ -9,7 +9,7 @@
 from pypy.rpython.lltypesystem import lltype
 from pypy.rpython.extfunc import BaseLazyRegistering, registering, extdef
 from pypy.rlib import rposix
-from pypy.rlib.rarithmetic import intmask, maxint32
+from pypy.rlib.rarithmetic import intmask
 from pypy.translator.tool.cbuild import ExternalCompilationInfo
 
 if sys.platform == 'win32':
@@ -177,7 +177,7 @@
     @registering(time.sleep)
     def register_time_sleep(self):
         if sys.platform == 'win32':
-            MAX = maxint32
+            MAX = sys.maxint
             Sleep = self.llexternal('Sleep', [rffi.ULONG], lltype.Void)
             def time_sleep_llimpl(secs):
                 millisecs = secs * 1000.0
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,12 +80,8 @@
         pwd = os.getcwd()
         import ctypes
         buf = ctypes.create_string_buffer(1000)
-        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
+        ctypes.windll.kernel32.GetEnvironmentVariableA('=%c:' % pwd[0], buf, 1000)
+        assert str(buf.value) == pwd
 
     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(os.environ['TEMP'])
+        check('c:/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
@@ -18,10 +18,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 isinstance(func, (int, long))
+        func = self.interpret(f,[])
+        assert type(func) == int
 
     def test_fstat(self):
         def fo(fi):
@@ -65,21 +65,21 @@
 
 
     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):
diff --git a/pypy/rpython/rint.py b/pypy/rpython/rint.py
--- a/pypy/rpython/rint.py
+++ b/pypy/rpython/rint.py
@@ -7,8 +7,7 @@
      SignedLongLong, build_number, Number, cast_primitive, typeOf
 from pypy.rpython.rmodel import IntegerRepr, inputconst
 from pypy.rpython.robject import PyObjRepr, pyobj_repr
-from pypy.rlib.rarithmetic import intmask, r_int, r_uint, r_ulonglong, \
-     r_longlong, is_emulated_long
+from pypy.rlib.rarithmetic import intmask, r_int, r_uint, r_ulonglong, r_longlong
 from pypy.rpython.error import TyperError, MissingRTypeOperation
 from pypy.rpython.rmodel import log
 from pypy.rlib import objectmodel
@@ -441,11 +440,6 @@
     Unsigned: ('RPyLong_AsUnsignedLong', lambda pyo: r_uint(pyo._obj.value)),
     Signed: ('PyInt_AsLong', lambda pyo: int(pyo._obj.value))
 }
-if is_emulated_long: # win64
-    py_to_ll_conversion_functions.update( {
-        Unsigned: ('RPyLong_AsUnsignedLongLong', lambda pyo: r_ulonglong(pyo._obj.value)),
-        Signed: ('RPyLong_AsLongLong', lambda pyo: r_longlong(pyo._obj.value)),
-    } )    
 
 ll_to_py_conversion_functions = {
     UnsignedLongLong: ('PyLong_FromUnsignedLongLong', lambda i: pyobjectptr(i)),
@@ -453,11 +447,6 @@
     Unsigned: ('PyLong_FromUnsignedLong', lambda i: pyobjectptr(i)),
     Signed: ('PyInt_FromLong', lambda i: pyobjectptr(i)),
 }
-if is_emulated_long: # win64
-    ll_to_py_conversion_functions.update( {
-        Unsigned: ('PyLong_FromUnsignedLongLong', lambda i: pyobjectptr(i)),
-        Signed: ('PyLong_FromLongLong', lambda i: pyobjectptr(i)),
-    } )
     
 
 class __extend__(pairtype(PyObjRepr, IntegerRepr)):
diff --git a/pypy/rpython/rmodel.py b/pypy/rpython/rmodel.py
--- a/pypy/rpython/rmodel.py
+++ b/pypy/rpython/rmodel.py
@@ -339,11 +339,11 @@
 
     def _get_opprefix(self):
         if self._opprefix is None:
-            raise TyperError("arithmetic not supported on %r, it's size is too small" %
+            raise TyperError("arithmetic not supported on %r" %
                              self.lowleveltype)
         return self._opprefix
 
-    opprefix = property(_get_opprefix)
+    opprefix =property(_get_opprefix)
     
 class BoolRepr(IntegerRepr):
     lowleveltype = Bool
diff --git a/pypy/rpython/test/test_rclass.py b/pypy/rpython/test/test_rclass.py
--- a/pypy/rpython/test/test_rclass.py
+++ b/pypy/rpython/test/test_rclass.py
@@ -457,12 +457,16 @@
                     compute_identity_hash(d))
 
         res = self.interpret(f, [])
-        # xxx this is too precise, checking the exact implementation
-        assert res.item0 == res.item1
+        # xxx the following test is too precise, checking the exact
+        # implementation.  On Python 2.7 it doesn't work anyway, because
+        # object.__hash__(x) is different from id(x).  The test is disabled
+        # for now, and nobody should rely on compute_identity_hash() returning
+        # a value that is (or was) the current_object_addr_as_int().
+        # --- disabled: assert res.item0 == res.item1
         # the following property is essential on top of the lltypesystem
         # otherwise prebuilt dictionaries are broken.  It's wrong on
         # top of the ootypesystem though.
-        if type(self) is TestLLtype:
+        if isinstance(self, LLRtypeMixin):
             assert res.item2 == h_c
             assert res.item3 == h_d
 
diff --git a/pypy/test_all.py b/pypy/test_all.py
--- a/pypy/test_all.py
+++ b/pypy/test_all.py
@@ -10,10 +10,6 @@
 For more information, use test_all.py -h.
 """
 import sys, os
-# XXX hack for win64:
-# this needs to be done without hacking maxint
-if hasattr(sys, "maxsize"):
-    sys.maxint = max(sys.maxint, sys.maxsize)
 
 if len(sys.argv) == 1 and os.path.dirname(sys.argv[0]) in '.':
     print >> sys.stderr, __doc__
diff --git a/pypy/translator/c/primitive.py b/pypy/translator/c/primitive.py
--- a/pypy/translator/c/primitive.py
+++ b/pypy/translator/c/primitive.py
@@ -1,7 +1,7 @@
 import sys
 from pypy.rlib.objectmodel import Symbolic, ComputedIntSymbolic
 from pypy.rlib.objectmodel import CDefinedIntSymbolic
-from pypy.rlib.rarithmetic import r_longlong, is_emulated_long
+from pypy.rlib.rarithmetic import r_longlong
 from pypy.rlib.rfloat import isinf, isnan
 from pypy.rpython.lltypesystem.lltype import *
 from pypy.rpython.lltypesystem import rffi, llgroup
@@ -16,15 +16,6 @@
 #
 # Primitives
 
-# win64: we need different constants, since we emulate 64 bit long.
-# this function simply replaces 'L' by 'LL' in a format string
-if is_emulated_long:
-    def lll(fmt):
-        return fmt.replace('L', 'LL')
-else:
-    def lll(fmt):
-        return fmt
-    
 def name_signed(value, db):
     if isinstance(value, Symbolic):
         if isinstance(value, FieldOffset):
@@ -70,22 +61,22 @@
         elif isinstance(value, llgroup.CombinedSymbolic):
             name = name_small_integer(value.lowpart, db)
             assert (value.rest & value.MASK) == 0
-            return lll('(%s+%dL)') % (name, value.rest)
+            return '(%s+%dL)' % (name, value.rest)
         elif isinstance(value, AddressAsInt):
-            return '((Signed)%s)' % name_address(value.adr, db)
+            return '((long)%s)' % name_address(value.adr, db)
         else:
             raise Exception("unimplemented symbolic %r"%value)
     if value is None:
         assert not db.completed
         return None
     if value == -sys.maxint-1:   # blame C
-        return lll('(-%dL-1L)') % sys.maxint
+        return '(-%dL-1L)' % sys.maxint
     else:
-        return lll('%dL') % value
+        return '%dL' % value
 
 def name_unsigned(value, db):
     assert value >= 0
-    return lll('%dUL') % value
+    return '%dUL' % value
 
 def name_unsignedlonglong(value, db):
     assert value >= 0
@@ -181,7 +172,6 @@
 
 # On 64 bit machines, SignedLongLong and Signed are the same, so the
 # order matters, because we want the Signed implementation.
-# (some entries collapse during dict creation)
 PrimitiveName = {
     SignedLongLong:   name_signedlonglong,
     Signed:   name_signed,
@@ -200,9 +190,9 @@
 
 PrimitiveType = {
     SignedLongLong:   'long long @',
-    Signed:   'Signed @',
+    Signed:   'long @',
     UnsignedLongLong: 'unsigned long long @',
-    Unsigned: 'Unsigned @',
+    Unsigned: 'unsigned long @',
     Float:    'double @',
     SingleFloat: 'float @',
     LongFloat: 'long double @',
diff --git a/pypy/translator/c/src/address.h b/pypy/translator/c/src/address.h
--- a/pypy/translator/c/src/address.h
+++ b/pypy/translator/c/src/address.h
@@ -16,5 +16,5 @@
 #define OP_ADR_LT(x,y,r)	  r = ((x) <  (y))
 #define OP_ADR_GE(x,y,r)	  r = ((x) >= (y))
 
-#define OP_CAST_ADR_TO_INT(x, mode, r)   r = ((Signed)x)
+#define OP_CAST_ADR_TO_INT(x, mode, r)   r = ((long)x)
 #define OP_CAST_INT_TO_ADR(x, r)         r = ((void *)(x))
diff --git a/pypy/translator/c/src/asm_gcc_x86_64.h b/pypy/translator/c/src/asm_gcc_x86_64.h
--- a/pypy/translator/c/src/asm_gcc_x86_64.h
+++ b/pypy/translator/c/src/asm_gcc_x86_64.h
@@ -2,7 +2,7 @@
  */
 
 #define READ_TIMESTAMP(val) do {                        \
-    Unsigned _rax, _rdx;                           \
+    unsigned long _rax, _rdx;                           \
     asm volatile("rdtsc" : "=a"(_rax), "=d"(_rdx)); \
     val = (_rdx << 32) | _rax;                          \
 } while (0)
diff --git a/pypy/translator/c/src/float.h b/pypy/translator/c/src/float.h
--- a/pypy/translator/c/src/float.h
+++ b/pypy/translator/c/src/float.h
@@ -31,8 +31,8 @@
 
 /*** conversions ***/
 
-#define OP_CAST_FLOAT_TO_INT(x,r)    r = (Signed)(x)
-#define OP_CAST_FLOAT_TO_UINT(x,r)   r = (Unsigned)(x)
+#define OP_CAST_FLOAT_TO_INT(x,r)    r = (long)(x)
+#define OP_CAST_FLOAT_TO_UINT(x,r)   r = (unsigned long)(x)
 #define OP_CAST_INT_TO_FLOAT(x,r)    r = (double)(x)
 #define OP_CAST_UINT_TO_FLOAT(x,r)   r = (double)(x)
 #define OP_CAST_LONGLONG_TO_FLOAT(x,r) r = (double)(x)
diff --git a/pypy/translator/c/src/g_prerequisite.h b/pypy/translator/c/src/g_prerequisite.h
--- a/pypy/translator/c/src/g_prerequisite.h
+++ b/pypy/translator/c/src/g_prerequisite.h
@@ -2,21 +2,13 @@
 /**************************************************************/
 /***  this is included before any code produced by genc.py  ***/
 
+
 #ifdef PYPY_STANDALONE
 #  include "src/commondefs.h"
 #else
 #  include "Python.h"
 #endif
 
-#ifdef _WIN64
-#  define Signed __int64
-#  define SIGNED_MIN LLONG_MIN 
-#else
-#  define Signed long
-#  define SIGNED_MIN LONG_MIN
-#endif
-#define Unsigned unsigned Signed
-
 #ifdef _WIN32
 #  include <io.h>   /* needed, otherwise _lseeki64 truncates to 32-bits (??) */
 #endif
diff --git a/pypy/translator/c/src/int.h b/pypy/translator/c/src/int.h
--- a/pypy/translator/c/src/int.h
+++ b/pypy/translator/c/src/int.h
@@ -5,31 +5,18 @@
 
 /*** unary operations ***/
 
-/************ win64 support:
-
-   'Signed' must be defined as
-
-       __int64          in case of win64
-       long             in all other cases
-
-   'SIGNED_MIN' must be defined as
-
-       LLONG_MIN        in case of win64
-       LONG_MIN         in all other cases
- */
-
 #define OP_INT_IS_TRUE(x,r)   r = ((x) != 0)
 #define OP_INT_INVERT(x,r)    r = ~(x)
 #define OP_INT_NEG(x,r)       r = -(x)
 
 #define OP_INT_NEG_OVF(x,r) \
-	if ((x) == SIGNED_MIN) FAIL_OVF("integer negate"); \
+	if ((x) == LONG_MIN) FAIL_OVF("integer negate"); \
 	OP_INT_NEG(x,r)
 
 #define OP_INT_ABS(x,r)    r = (x) >= 0 ? x : -(x)
 
 #define OP_INT_ABS_OVF(x,r) \
-	if ((x) == SIGNED_MIN) FAIL_OVF("integer absolute"); \
+	if ((x) == LONG_MIN) FAIL_OVF("integer absolute"); \
 	OP_INT_ABS(x,r)
 
 /***  binary operations ***/
@@ -46,8 +33,8 @@
    for the case of a == 0 (both subtractions are then constant-folded).
    Note that the following line only works if a <= c in the first place,
    which we assume is true. */
-#define OP_INT_BETWEEN(a,b,c,r)   r = (((Unsigned)b - (Unsigned)a) \
-                                     < ((Unsigned)c - (Unsigned)a))
+#define OP_INT_BETWEEN(a,b,c,r)   r = (((unsigned long)b - (unsigned long)a) \
+                                     < ((unsigned long)c - (unsigned long)a))
 
 /* addition, subtraction */
 
@@ -55,22 +42,22 @@
 
 /* cast to avoid undefined behaviour on overflow */
 #define OP_INT_ADD_OVF(x,y,r) \
-        r = (Signed)((Unsigned)x + y); \
+        r = (long)((unsigned long)x + y); \
         if ((r^x) < 0 && (r^y) < 0) FAIL_OVF("integer addition")
 
 #define OP_INT_ADD_NONNEG_OVF(x,y,r)  /* y can be assumed >= 0 */ \
-        r = (Signed)((Unsigned)x + y); \
+        r = (long)((unsigned long)x + y); \
         if ((r&~x) < 0) FAIL_OVF("integer addition")
 
 #define OP_INT_SUB(x,y,r)     r = (x) - (y)
 
 #define OP_INT_SUB_OVF(x,y,r) \
-        r = (Signed)((Unsigned)x - y); \
+        r = (long)((unsigned long)x - y); \
         if ((r^x) < 0 && (r^~y) < 0) FAIL_OVF("integer subtraction")
 
 #define OP_INT_MUL(x,y,r)     r = (x) * (y)
 
-#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG && !defined(_WIN64)
+#if SIZEOF_LONG * 2 <= SIZEOF_LONG_LONG
 #define OP_INT_MUL_OVF(x,y,r) \
 	{ \
 		long long _lr = (long long)x * y; \
@@ -91,7 +78,7 @@
 
 
 #define OP_INT_RSHIFT(x,y,r)    CHECK_SHIFT_RANGE(y, PYPY_LONG_BIT); \
-						r = Py_ARITHMETIC_RIGHT_SHIFT(Signed, x, (y))
+						r = Py_ARITHMETIC_RIGHT_SHIFT(long, x, (y))
 #define OP_UINT_RSHIFT(x,y,r)   CHECK_SHIFT_RANGE(y, PYPY_LONG_BIT); \
 						r = (x) >> (y)
 #define OP_LLONG_RSHIFT(x,y,r)  CHECK_SHIFT_RANGE(y, PYPY_LONGLONG_BIT); \
@@ -111,7 +98,7 @@
 
 #define OP_INT_LSHIFT_OVF(x,y,r) \
 	OP_INT_LSHIFT(x,y,r); \
-	if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(Signed, r, (y))) \
+	if ((x) != Py_ARITHMETIC_RIGHT_SHIFT(long, r, (y))) \
 		FAIL_OVF("x<<y losing bits or changing sign")
 
 /* floor division */
@@ -122,7 +109,7 @@
 #define OP_ULLONG_FLOORDIV(x,y,r) r = (x) / (y)
 
 #define OP_INT_FLOORDIV_OVF(x,y,r)                      \
-	if ((y) == -1 && (x) == SIGNED_MIN)               \
+	if ((y) == -1 && (x) == LONG_MIN)               \
 	    { FAIL_OVF("integer division"); r=0; }      \
 	else                                            \
 	    r = (x) / (y)
@@ -162,7 +149,7 @@
 #define OP_ULLONG_MOD(x,y,r)  r = (x) % (y)
 
 #define OP_INT_MOD_OVF(x,y,r)                           \
-	if ((y) == -1 && (x) == SIGNED_MIN)               \
+	if ((y) == -1 && (x) == LONG_MIN)               \
 	    { FAIL_OVF("integer modulo"); r=0; }        \
 	else                                            \
 	    r = (x) % (y)
@@ -201,18 +188,18 @@
 
 /*** conversions ***/
 
-#define OP_CAST_BOOL_TO_INT(x,r)    r = (Signed)(x)
-#define OP_CAST_BOOL_TO_UINT(x,r)   r = (Unsigned)(x)
-#define OP_CAST_UINT_TO_INT(x,r)    r = (Signed)(x)
-#define OP_CAST_INT_TO_UINT(x,r)    r = (Unsigned)(x)
+#define OP_CAST_BOOL_TO_INT(x,r)    r = (long)(x)
+#define OP_CAST_BOOL_TO_UINT(x,r)   r = (unsigned long)(x)
+#define OP_CAST_UINT_TO_INT(x,r)    r = (long)(x)
+#define OP_CAST_INT_TO_UINT(x,r)    r = (unsigned long)(x)
 #define OP_CAST_INT_TO_LONGLONG(x,r) r = (long long)(x)
-#define OP_CAST_CHAR_TO_INT(x,r)    r = (Signed)((unsigned char)(x))
+#define OP_CAST_CHAR_TO_INT(x,r)    r = (long)((unsigned char)(x))
 #define OP_CAST_INT_TO_CHAR(x,r)    r = (char)(x)
-#define OP_CAST_PTR_TO_INT(x,r)     r = (Signed)(x)    /* XXX */
+#define OP_CAST_PTR_TO_INT(x,r)     r = (long)(x)    /* XXX */
 
-#define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (Signed)(x)
+#define OP_TRUNCATE_LONGLONG_TO_INT(x,r) r = (long)(x)
 
-#define OP_CAST_UNICHAR_TO_INT(x,r)    r = (Signed)((Unsigned)(x)) /*?*/
+#define OP_CAST_UNICHAR_TO_INT(x,r)    r = (long)((unsigned long)(x)) /*?*/
 #define OP_CAST_INT_TO_UNICHAR(x,r)    r = (unsigned int)(x)
 
 /* bool operations */
diff --git a/pypy/translator/c/src/mem.h b/pypy/translator/c/src/mem.h
--- a/pypy/translator/c/src/mem.h
+++ b/pypy/translator/c/src/mem.h
@@ -53,7 +53,7 @@
 extern void* __gcmapstart;
 extern void* __gcmapend;
 extern char* __gccallshapes;
-extern Signed pypy_asm_stackwalk(void*, void*);
+extern long pypy_asm_stackwalk(void*, void*);
 
 /* With the msvc Microsoft Compiler, the optimizer seems free to move
    any code (even asm) that involves local memory (registers and stack).
@@ -66,7 +66,7 @@
 pypy_asm_gcroot(void* _r1)
 {
 	static volatile int _constant_always_one_ = 1;
-	(Signed)_r1 *= _constant_always_one_;
+	(long)_r1 *= _constant_always_one_;
 	_ReadWriteBarrier();
     return _r1;
 }
@@ -86,7 +86,7 @@
 
 
 /* used by pypy.rlib.rstack, but also by asmgcc */
-#define OP_STACK_CURRENT(r)  r = (Signed)&r
+#define OP_STACK_CURRENT(r)  r = (long)&r
 
 
 #define RAW_MALLOC_ZERO_FILLED 0
diff --git a/pypy/translator/c/src/obmalloc.c b/pypy/translator/c/src/obmalloc.c
--- a/pypy/translator/c/src/obmalloc.c
+++ b/pypy/translator/c/src/obmalloc.c
@@ -224,10 +224,10 @@
 #define uint			unsigned int	/* assuming >= 16 bits */
 
 #undef  ulong
-#define ulong			Unsigned	/* assuming >= 32 bits */
+#define ulong			unsigned long	/* assuming >= 32 bits */
 
 #undef uptr
-#define uptr			Unsigned
+#define uptr			unsigned long
 
 /* When you say memory, my mind reasons in terms of (pointers to) blocks */
 typedef uchar block;
diff --git a/pypy/translator/c/src/rtyper.h b/pypy/translator/c/src/rtyper.h
--- a/pypy/translator/c/src/rtyper.h
+++ b/pypy/translator/c/src/rtyper.h
@@ -30,7 +30,7 @@
 
 char *RPyString_AsCharP(RPyString *rps)
 {
-	Signed len = RPyString_Size(rps);
+	long len = RPyString_Size(rps);
 	struct _RPyString_dump_t *dump = \
 			malloc(sizeof(struct _RPyString_dump_t) + len);
 	if (!dump)
diff --git a/pypy/translator/c/src/signals.h b/pypy/translator/c/src/signals.h
--- a/pypy/translator/c/src/signals.h
+++ b/pypy/translator/c/src/signals.h
@@ -54,7 +54,7 @@
 /* When a signal is received, pypysig_counter is set to -1. */
 /* This is a struct for the JIT. See interp_signal.py. */
 struct pypysig_long_struct {
-    Signed value;
+    long value;
 };
 extern struct pypysig_long_struct pypysig_counter;
 
diff --git a/pypy/translator/c/test/test_newgc.py b/pypy/translator/c/test/test_newgc.py
--- a/pypy/translator/c/test/test_newgc.py
+++ b/pypy/translator/c/test/test_newgc.py
@@ -675,8 +675,8 @@
             gc.collect()
             p_a1 = rffi.cast(rffi.VOIDPP, ll_args[0])[0]
             p_a2 = rffi.cast(rffi.VOIDPP, ll_args[1])[0]
-            a1 = rffi.cast(rffi.SIGNEDP, p_a1)[0]
-            a2 = rffi.cast(rffi.SIGNEDP, p_a2)[0]
+            a1 = rffi.cast(rffi.LONGP, p_a1)[0]
+            a2 = rffi.cast(rffi.LONGP, p_a2)[0]
             res = rffi.cast(rffi.INTP, ll_res)
             if a1 > a2:
                 res[0] = rffi.cast(rffi.INT, 1)
@@ -1202,7 +1202,7 @@
         def f():
             from pypy.rpython.lltypesystem import lltype, rffi
             alist = [A() for i in range(50000)]
-            idarray = lltype.malloc(rffi.SIGNEDP.TO, len(alist), flavor='raw')
+            idarray = lltype.malloc(rffi.LONGP.TO, len(alist), flavor='raw')
             # Compute the id of all 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/translator/platform/windows.py b/pypy/translator/platform/windows.py
--- a/pypy/translator/platform/windows.py
+++ b/pypy/translator/platform/windows.py
@@ -90,7 +90,7 @@
     shared_only = ()
     environ = None
 
-    def __init__(self, cc=None, x64=False):
+    def __init__(self, cc=None, x64):
         if x64:
             msvc_compiler_environ = msvc_compiler_environ64
         else:


More information about the pypy-commit mailing list