[pypy-commit] pypy default: Fix test_some_integer_type on 32-bit machines. Add a more precise test.
arigo
noreply at buildbot.pypy.org
Sun May 31 09:46:34 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch:
Changeset: r77719:276f617d9007
Date: 2015-05-31 09:46 +0200
http://bitbucket.org/pypy/pypy/changeset/276f617d9007/
Log: Fix test_some_integer_type on 32-bit machines. Add a more precise
test. Turns out it was strictly a before-translation error.
diff --git a/pypy/module/_cffi_backend/ctypeobj.py b/pypy/module/_cffi_backend/ctypeobj.py
--- a/pypy/module/_cffi_backend/ctypeobj.py
+++ b/pypy/module/_cffi_backend/ctypeobj.py
@@ -1,3 +1,4 @@
+import sys
from pypy.interpreter.baseobjspace import W_Root
from pypy.interpreter.error import OperationError, oefmt
from pypy.interpreter.gateway import interp2app
@@ -131,6 +132,8 @@
# obscure hack when untranslated, maybe, approximate, don't use
if isinstance(align, llmemory.FieldOffset):
align = rffi.sizeof(align.TYPE.y)
+ if (1 << (8*align-2)) > sys.maxint:
+ align /= 2
else:
# a different hack when translated, to avoid seeing constants
# of a symbolic integer type
diff --git a/pypy/module/_cffi_backend/test/test_recompiler.py b/pypy/module/_cffi_backend/test/test_recompiler.py
--- a/pypy/module/_cffi_backend/test/test_recompiler.py
+++ b/pypy/module/_cffi_backend/test/test_recompiler.py
@@ -29,7 +29,7 @@
rdir = udir.ensure('recompiler', dir=1)
rdir.join('Python.h').write(
'#define PYPY_VERSION XX\n'
- '#define PyMODINIT_FUNC /*exported*/\n'
+ '#define PyMODINIT_FUNC /*exported*/ void\n'
)
path = module_name.replace('.', os.sep)
if '.' in module_name:
@@ -953,3 +953,16 @@
ffi.typeof('function_t*')
lib.function(ffi.NULL)
# assert did not crash
+
+ def test_alignment_of_longlong(self):
+ import _cffi_backend
+ BULongLong = _cffi_backend.new_primitive_type('unsigned long long')
+ x1 = _cffi_backend.alignof(BULongLong)
+ assert x1 in [4, 8]
+ #
+ ffi, lib = self.prepare(
+ "struct foo_s { unsigned long long x; };",
+ 'test_alignment_of_longlong',
+ "struct foo_s { unsigned long long x; };")
+ assert ffi.alignof('unsigned long long') == x1
+ assert ffi.alignof('struct foo_s') == x1
More information about the pypy-commit
mailing list