[pypy-svn] r70082 - in pypy/trunk/pypy: rpython/lltypesystem translator/c
arigo at codespeak.net
arigo at codespeak.net
Sun Dec 13 12:53:08 CET 2009
Author: arigo
Date: Sun Dec 13 12:53:07 2009
New Revision: 70082
Modified:
pypy/trunk/pypy/rpython/lltypesystem/rffi.py
pypy/trunk/pypy/translator/c/genc.py
Log:
Check the 32-bit-versus-64-bit configuration:
* in rffi, verify that we are not trying to run on a 32-bit CPython
with a 64-bit C compiler or vice-versa;
* in genc, produce in the C code a check that will give a compile-time
error if the C compiler uses a different word size.
Modified: pypy/trunk/pypy/rpython/lltypesystem/rffi.py
==============================================================================
--- pypy/trunk/pypy/rpython/lltypesystem/rffi.py (original)
+++ pypy/trunk/pypy/rpython/lltypesystem/rffi.py Sun Dec 13 12:53:07 2009
@@ -801,6 +801,13 @@
return llmemory.offsetof(STRUCT, fieldname)
offsetof._annspecialcase_ = 'specialize:memo'
+# check that we have a sane configuration
+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" % (
+ sys.maxint, sizeof(lltype.Signed)))
+
# ********************** some helpers *******************
def make(STRUCT, **fields):
Modified: pypy/trunk/pypy/translator/c/genc.py
==============================================================================
--- pypy/trunk/pypy/translator/c/genc.py (original)
+++ pypy/trunk/pypy/translator/c/genc.py Sun Dec 13 12:53:07 2009
@@ -729,7 +729,16 @@
print >> f
+def gen_size_check(f):
+ from pypy.rlib.rarithmetic import LONG_BIT
+ print >> f, '#if 8 * SIZEOF_LONG != %d' % (LONG_BIT,)
+ print >> f, '# error "C files are generated for a %d-bit platform"' % (
+ LONG_BIT,)
+ print >> f, '#endif'
+ print >> f
+
def gen_structdef(f, database):
+ gen_size_check(f)
structdeflist = database.getstructdeflist()
print >> f, '/***********************************************************/'
print >> f, '/*** Structure definitions ***/'
More information about the Pypy-commit
mailing list