[pypy-svn] r15652 - in pypy/dist/pypy: module/posix rpython translator/c translator/c/src

arigo at codespeak.net arigo at codespeak.net
Fri Aug 5 01:46:35 CEST 2005


Author: arigo
Date: Fri Aug  5 01:46:32 2005
New Revision: 15652

Modified:
   pypy/dist/pypy/module/posix/__init__.py
   pypy/dist/pypy/rpython/extfunctable.py
   pypy/dist/pypy/translator/c/primitive.py
   pypy/dist/pypy/translator/c/src/g_include.h
   pypy/dist/pypy/translator/c/src/ll_os.h
   pypy/dist/pypy/translator/c/src/ll_time.h
   pypy/dist/pypy/translator/c/src/standalone.h
Log:
Tentative Windows compatibility (thanks xorAxAx):
* remove all references to os.ftruncate() for Windows
* disabled (for now) complicated code in time.sleep()
* pragma to disable the most common warnings
* #including Python.h is enough to pull in libraries,
    needs to be more careful (#define Py_BUILD_CORE)
* infinite floats: literal 1E9999999 is not accepted,
    the IEEE-only expression (1E200*1E200) works.


Modified: pypy/dist/pypy/module/posix/__init__.py
==============================================================================
--- pypy/dist/pypy/module/posix/__init__.py	(original)
+++ pypy/dist/pypy/module/posix/__init__.py	Fri Aug  5 01:46:32 2005
@@ -21,11 +21,13 @@
     'isatty'    : 'interp_posix.isatty',
     'read'      : 'interp_posix.read',
     'close'     : 'interp_posix.close',
-    'ftruncate' : 'interp_posix.ftruncate',
     'fstat'     : 'interp_posix.fstat',
     'stat'      : 'interp_posix.stat',
     'dup'       : 'interp_posix.dup',
     }
+    if hasattr(os, 'ftruncate'):
+        interpleveldefs['ftruncate'] = 'interp_posix.ftruncate'
+
 
 for constant in ['EX_CANTCREAT', 'EX_CONFIG', 'EX_DATAERR', 'EX_IOERR',
                  'EX_NOHOST', 'EX_NOINPUT', 'EX_NOPERM', 'EX_NOUSER',

Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py	(original)
+++ pypy/dist/pypy/rpython/extfunctable.py	Fri Aug  5 01:46:32 2005
@@ -75,11 +75,8 @@
 declare(os.dup      , int           , 'll_os/dup')
 declare(os.lseek    , int           , 'll_os/lseek')
 declare(os.isatty   , bool          , 'll_os/isatty')
-try:
-    os.ftruncate # yes, this is a hack for windows, please make it better
-except AttributeError:
-    os.ftruncate = lambda f: None
-declare(os.ftruncate, noneannotation, 'll_os/ftruncate')
+if hasattr(os, 'ftruncate'):
+    declare(os.ftruncate, noneannotation, 'll_os/ftruncate')
 declare(os.fstat    , statannotation, 'll_os/fstat')
 declare(os.stat     , statannotation, 'll_os/stat')
 declare(os.strerror , str           , 'll_os/strerror')           

Modified: pypy/dist/pypy/translator/c/primitive.py
==============================================================================
--- pypy/dist/pypy/translator/c/primitive.py	(original)
+++ pypy/dist/pypy/translator/c/primitive.py	Fri Aug  5 01:46:32 2005
@@ -20,10 +20,13 @@
 
 def name_float(value):
     if isinf(value):
+        # the following seems to produce an inf both on gcc and MS compilers
+        # XXX but it depends on the size of the doubles
+        assert isinf(1E200*1E200)
         if value > 0:
-            return '1E9999999'
+            return '(1E200*1E200)'
         else:
-            return '-1E9999999'
+            return '(-1E200*1E200)'
     else:
         return repr(value)
 

Modified: pypy/dist/pypy/translator/c/src/g_include.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/g_include.h	(original)
+++ pypy/dist/pypy/translator/c/src/g_include.h	Fri Aug  5 01:46:32 2005
@@ -2,12 +2,8 @@
 /************************************************************/
 /***  C header file for code produced by genc.py          ***/
 
-/* XXX for now we always include Python.h even to produce stand-alone
- * executables (which are *not* linked against CPython then),
- * to get the convenient macro definitions
- */
-#include "Python.h"
 #ifndef PYPY_STANDALONE
+#  include "Python.h"
 #  include "compile.h"
 #  include "frameobject.h"
 #  include "structmember.h"

Modified: pypy/dist/pypy/translator/c/src/ll_os.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_os.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_os.h	Fri Aug  5 01:46:32 2005
@@ -164,6 +164,7 @@
     return (int)isatty((int)fd);
 }
 
+#ifdef HAVE_FTRUNCATE
 void LL_os_ftruncate(long fd, long length) { /*XXX add longfile support */
     int res;
     res = ftruncate((int)fd, (off_t)length);
@@ -171,6 +172,7 @@
 	RAISE_OSERROR(errno);
     }
 }
+#endif
 
 RPyString *LL_os_strerror(int errnum)
 {

Modified: pypy/dist/pypy/translator/c/src/ll_time.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/ll_time.h	(original)
+++ pypy/dist/pypy/translator/c/src/ll_time.h	Fri Aug  5 01:46:32 2005
@@ -63,21 +63,22 @@
 		return;
 	}
 	ul_millis = (unsigned long)millisecs;
-	if (ul_millis == 0)
+        /* XXX copy CPython to make this interruptible again */
+	/*if (ul_millis == 0)*/
 		Sleep(ul_millis);
-	else {
+	/*else {
 		DWORD rc;
 		ResetEvent(hInterruptEvent);
 		rc = WaitForSingleObject(hInterruptEvent, ul_millis);
 		if (rc == WAIT_OBJECT_0) {
-				/* Yield to make sure real Python signal
+				 * Yield to make sure real Python signal
 				 * handler called.
-				 */
+				 *
 			Sleep(1);
 			RaiseSimpleException(Exc_IOError, "interrupted");
 			return;
 		}
-	}
+	}*/
 #else
 	struct timeval t;
 	double frac;

Modified: pypy/dist/pypy/translator/c/src/standalone.h
==============================================================================
--- pypy/dist/pypy/translator/c/src/standalone.h	(original)
+++ pypy/dist/pypy/translator/c/src/standalone.h	Fri Aug  5 01:46:32 2005
@@ -1,3 +1,10 @@
+/* XXX for now we always include Python.h even to produce stand-alone
+ * executables (which are *not* linked against CPython then),
+ * to get the convenient macro definitions
+ */
+#define Py_BUILD_CORE  /* for Windows: avoid pulling libs in */
+#include "Python.h"
+
 #include <stdlib.h>
 #include <limits.h>
 #include <assert.h>
@@ -6,3 +13,8 @@
 #define PyObject_Malloc malloc
 #define PyObject_Free   free
 
+#ifdef MS_WINDOWS
+#  ifdef _MSC_VER
+#    pragma warning(disable: 4033 4102 4101 4716) /*suppress a few warnings*/
+#  endif
+#endif



More information about the Pypy-commit mailing list