[pypy-commit] pypy stdlib-2.7.6: fix translation for 32bit

bdkearns noreply at buildbot.pypy.org
Mon Mar 3 07:04:26 CET 2014


Author: Brian Kearns <bdkearns at gmail.com>
Branch: stdlib-2.7.6
Changeset: r69633:50a62210462c
Date: 2014-03-03 01:03 -0500
http://bitbucket.org/pypy/pypy/changeset/50a62210462c/

Log:	fix translation for 32bit

diff --git a/rpython/rlib/rarithmetic.py b/rpython/rlib/rarithmetic.py
--- a/rpython/rlib/rarithmetic.py
+++ b/rpython/rlib/rarithmetic.py
@@ -75,12 +75,6 @@
 # to handle the win64 special case:
 is_emulated_long = _long_typecode != 'l'
 
-SHRT_MIN = -2**(_get_bitsize('h') - 1)
-SHRT_MAX = 2**(_get_bitsize('h') - 1) - 1
-INT_MIN = -2**(_get_bitsize('i') - 1)
-INT_MAX = 2**(_get_bitsize('i') - 1) - 1
-UINT_MAX = 2**_get_bitsize('i') - 1
-
 LONG_BIT = _get_long_bit()
 LONG_MASK = (2**LONG_BIT)-1
 LONG_TEST = 2**(LONG_BIT-1)
@@ -298,7 +292,6 @@
 class base_int(long):
     """ fake unsigned integer implementation """
 
-
     def _widen(self, other, value):
         """
         if one argument is int or long, the other type wins.
@@ -544,8 +537,11 @@
 # needed for ll_os_stat.time_t_to_FILE_TIME in the 64 bit case
 r_uint32 = build_int('r_uint32', False, 32)
 
-# needed for ll_time.time_sleep_llimpl
-maxint32 = int((1 << 31) -1)
+SHRT_MIN = -2**(_get_bitsize('h') - 1)
+SHRT_MAX = 2**(_get_bitsize('h') - 1) - 1
+INT_MIN = -2**(_get_bitsize('i') - 1)
+INT_MAX = 2**(_get_bitsize('i') - 1) - 1
+UINT_MAX = r_uint(2**_get_bitsize('i') - 1)
 
 # the 'float' C type
 
diff --git a/rpython/rtyper/module/ll_time.py b/rpython/rtyper/module/ll_time.py
--- a/rpython/rtyper/module/ll_time.py
+++ b/rpython/rtyper/module/ll_time.py
@@ -9,7 +9,7 @@
 from rpython.rtyper.lltypesystem import lltype
 from rpython.rtyper.extfunc import BaseLazyRegistering, registering, extdef
 from rpython.rlib import rposix
-from rpython.rlib.rarithmetic import intmask, maxint32
+from rpython.rlib.rarithmetic import intmask, UINT_MAX
 from rpython.translator.tool.cbuild import ExternalCompilationInfo
 
 if sys.platform == 'win32':
@@ -183,19 +183,17 @@
     @registering(time.sleep)
     def register_time_sleep(self):
         if sys.platform == 'win32':
-            MAX = maxint32
             Sleep = self.llexternal('Sleep', [rffi.ULONG], lltype.Void)
             def time_sleep_llimpl(secs):
                 millisecs = secs * 1000.0
-                while millisecs > MAX:
-                    Sleep(MAX)
-                    millisecs -= MAX
+                while millisecs > UINT_MAX:
+                    Sleep(UINT_MAX)
+                    millisecs -= UINT_MAX
                 Sleep(rffi.cast(rffi.ULONG, int(millisecs)))
         else:
             c_select = self.llexternal('select', [rffi.INT, rffi.VOIDP,
                                                   rffi.VOIDP, rffi.VOIDP,
                                                   self.TIMEVALP], rffi.INT)
-            
             def time_sleep_llimpl(secs):
                 void = lltype.nullptr(rffi.VOIDP.TO)
                 t = lltype.malloc(self.TIMEVAL, flavor='raw')


More information about the pypy-commit mailing list