[pypy-commit] pypy win64_gborg: corrected the formatting of constants.

ctismer noreply at buildbot.pypy.org
Sun Nov 6 18:17:04 CET 2011


Author: Christian Tismer <tismer at stackless.com>
Branch: win64_gborg
Changeset: r48829:0525e812c2ca
Date: 2011-11-06 18:07 +0100
http://bitbucket.org/pypy/pypy/changeset/0525e812c2ca/

Log:	corrected the formatting of constants. Pretty hackish by a small
	function that replaces L with LL, but very local and obvious.

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
@@ -16,6 +16,15 @@
 #
 # 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):
@@ -61,22 +70,22 @@
         elif isinstance(value, llgroup.CombinedSymbolic):
             name = name_small_integer(value.lowpart, db)
             assert (value.rest & value.MASK) == 0
-            return '(%s+%dL)' % (name, value.rest)
+            return lll('(%s+%dL)') % (name, value.rest)
         elif isinstance(value, AddressAsInt):
-            return '((long)%s)' % name_address(value.adr, db)
+            return '((Signed)%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 '(-%dL-1L)' % sys.maxint
+        return lll('(-%dL-1L)') % sys.maxint
     else:
-        return '%dL' % value
+        return lll('%dL') % value
 
 def name_unsigned(value, db):
     assert value >= 0
-    return '%dUL' % value
+    return lll('%dUL') % value
 
 def name_unsignedlonglong(value, db):
     assert value >= 0
@@ -190,9 +199,9 @@
 
 PrimitiveType = {
     SignedLongLong:   'long long @',
-    Signed:   'long @',
+    Signed:   'long @', # but see below
     UnsignedLongLong: 'unsigned long long @',
-    Unsigned: 'unsigned long @',
+    Unsigned: 'unsigned long @', # but see below
     Float:    'double @',
     SingleFloat: 'float @',
     LongFloat: 'long double @',
@@ -228,11 +237,7 @@
 define_c_primitive(rffi.INT, 'int')
 define_c_primitive(rffi.INT_real, 'int')
 define_c_primitive(rffi.UINT, 'unsigned int')
-if is_emulated_long: # special case for win64
-    define_c_primitive(rffi.LONG, '__int64', 'LL')
-    define_c_primitive(rffi.ULONG, 'unsigned __int64', 'ULL')
-else:
-    define_c_primitive(rffi.LONG, 'long', 'L')
-    define_c_primitive(rffi.ULONG, 'unsigned long', 'UL')
+define_c_primitive(rffi.LONG, 'long', 'L')
+define_c_primitive(rffi.ULONG, 'unsigned long', 'UL')
 define_c_primitive(rffi.LONGLONG, 'long long', 'LL')
 define_c_primitive(rffi.ULONGLONG, 'unsigned long long', 'ULL')


More information about the pypy-commit mailing list