[pypy-svn] r66115 - in pypy/trunk/pypy: module/posix rlib translator/goal

antocuni at codespeak.net antocuni at codespeak.net
Sat Jul 4 15:18:15 CEST 2009


Author: antocuni
Date: Sat Jul  4 15:18:15 2009
New Revision: 66115

Modified:
   pypy/trunk/pypy/module/posix/__init__.py
   pypy/trunk/pypy/rlib/streamio.py
   pypy/trunk/pypy/translator/goal/targetpypystandalone.py
Log:
(yoli, antocuni)

(sigh) evil hack to make pypy-{cli,jvm} to translate again on windows; the
problem is that streamio.py assumes that the backend is c, so it freely uses
rffi externals and win32 APIs to implement ftruncate, but of course there is
no chance to make it working on ootype.  It is really a design issue, we need
to be able to provide alternative implementations based on (platform, backend)
at some point.



Modified: pypy/trunk/pypy/module/posix/__init__.py
==============================================================================
--- pypy/trunk/pypy/module/posix/__init__.py	(original)
+++ pypy/trunk/pypy/module/posix/__init__.py	Sat Jul  4 15:18:15 2009
@@ -120,6 +120,14 @@
         if hasattr(os, name):
             interpleveldefs[name] = 'interp_posix.' + name
 
+    def __init__(self, space, w_name):
+        backend = space.config.translation.backend
+        # the Win32 urandom implementation isn't going to translate on JVM or CLI
+        # so we have to remove it
+        if backend == 'cli' or backend == 'jvm':
+            del self.interpleveldefs['urandom']
+        MixedModule.__init__(self, space, w_name)
+
     def startup(self, space):
         from pypy.module.posix import interp_posix
         interp_posix.get(space).startup(space)

Modified: pypy/trunk/pypy/rlib/streamio.py
==============================================================================
--- pypy/trunk/pypy/rlib/streamio.py	(original)
+++ pypy/trunk/pypy/rlib/streamio.py	Sat Jul  4 15:18:15 2009
@@ -176,6 +176,10 @@
                                compilation_info=_eci)
     SetEndOfFile = rffi.llexternal('SetEndOfFile', [rffi.LONG], rwin32.BOOL,
                                    compilation_info=_eci)
+
+    # HACK: These implementations are specific to MSVCRT and the C backend.
+    # When generating on CLI or JVM, these are patched out.
+    # See PyPyTarget.target() in targetpypystandalone.py
     def _setfd_binary(fd):
         _setmode(fd, os.O_BINARY)
 

Modified: pypy/trunk/pypy/translator/goal/targetpypystandalone.py
==============================================================================
--- pypy/trunk/pypy/translator/goal/targetpypystandalone.py	(original)
+++ pypy/trunk/pypy/translator/goal/targetpypystandalone.py	Sat Jul  4 15:18:15 2009
@@ -199,6 +199,16 @@
         wrapstr = 'space.wrap(%r)' % (options)
         pypy.module.sys.Module.interpleveldefs['pypy_translation_info'] = wrapstr
 
+        if config.translation.backend in ["cli", "jvm"] and sys.platform == "win32":
+            # HACK: The ftruncate implementation in streamio.py which is used for the Win32 platform
+            # is specific for the C backend and can't be generated on CLI or JVM. Because of that,
+            # we have to patch it out.
+            from pypy.rlib import streamio
+            def ftruncate_win32_dummy(fd, size): pass
+            def _setfd_binary_dummy(fd): pass
+            streamio.ftruncate_win32 = ftruncate_win32_dummy
+            streamio._setfd_binary = _setfd_binary_dummy
+
         return self.get_entry_point(config)
 
     def jitpolicy(self, driver):



More information about the Pypy-commit mailing list