[pypy-commit] cffi cffi-1.0: hg merge default
arigo
noreply at buildbot.pypy.org
Sun Apr 26 18:39:59 CEST 2015
Author: Armin Rigo <arigo at tunes.org>
Branch: cffi-1.0
Changeset: r1854:b20650f90e1c
Date: 2015-04-26 18:40 +0200
http://bitbucket.org/cffi/cffi/changeset/b20650f90e1c/
Log: hg merge default
diff --git a/_cffi1/test_new_ffi_1.py b/_cffi1/test_new_ffi_1.py
--- a/_cffi1/test_new_ffi_1.py
+++ b/_cffi1/test_new_ffi_1.py
@@ -60,6 +60,10 @@
struct { int a, b; };
union { int c, d; };
};
+ struct nested_field_ofs_s {
+ struct { int a; char b; };
+ union { char c; };
+ };
union nested_anon_u {
struct { int a, b; };
union { int c, d; };
@@ -81,7 +85,7 @@
ffi = module.ffi
-class TestOldFFI1:
+class TestNewFFI1:
def test_integer_ranges(self):
for (c_type, size) in [('char', 1),
@@ -1328,6 +1332,14 @@
assert p.c == 14
assert p.d == 14
+ def test_nested_field_offset_align(self):
+ # struct nested_field_ofs_s {
+ # struct { int a; char b; };
+ # union { char c; };
+ # };
+ assert ffi.offsetof("struct nested_field_ofs_s", "c") == 2 * SIZE_OF_INT
+ assert ffi.sizeof("struct nested_field_ofs_s") == 3 * SIZE_OF_INT
+
def test_nested_anonymous_union(self):
# union nested_anon_u {
# struct { int a, b; };
diff --git a/cffi/ffiplatform.py b/cffi/ffiplatform.py
--- a/cffi/ffiplatform.py
+++ b/cffi/ffiplatform.py
@@ -1,4 +1,4 @@
-import os
+import sys, os
class VerificationError(Exception):
@@ -14,6 +14,15 @@
LIST_OF_FILE_NAMES = ['sources', 'include_dirs', 'library_dirs',
'extra_objects', 'depends']
+def _hack_at_distutils():
+ # Windows-only workaround for some configurations: see
+ # https://bugs.python.org/issue23246 (Python 2.7.9)
+ if sys.platform == "win32":
+ try:
+ import setuptools # for side-effects, patches distutils
+ except ImportError:
+ pass
+
def get_extension(srcfilename, modname, sources=(), **kwds):
from distutils.core import Extension
allsources = [srcfilename]
@@ -37,6 +46,7 @@
def _build(tmpdir, ext):
# XXX compact but horrible :-(
+ _hack_at_distutils()
from distutils.core import Distribution
import distutils.errors
#
diff --git a/testing/backend_tests.py b/testing/backend_tests.py
--- a/testing/backend_tests.py
+++ b/testing/backend_tests.py
@@ -1388,6 +1388,17 @@
assert p.c == 14
assert p.d == 14
+ def test_nested_field_offset_align(self):
+ ffi = FFI(backend=self.Backend())
+ ffi.cdef("""
+ struct foo_s {
+ struct { int a; char b; };
+ union { char c; };
+ };
+ """)
+ assert ffi.offsetof("struct foo_s", "c") == 2 * SIZE_OF_INT
+ assert ffi.sizeof("struct foo_s") == 3 * SIZE_OF_INT
+
def test_nested_anonymous_union(self):
ffi = FFI(backend=self.Backend())
ffi.cdef("""
diff --git a/testing/test_ctypes.py b/testing/test_ctypes.py
--- a/testing/test_ctypes.py
+++ b/testing/test_ctypes.py
@@ -28,6 +28,9 @@
def test_nested_anonymous_struct(self):
py.test.skip("ctypes backend: not supported: nested anonymous struct")
+ def test_nested_field_offset_align(self):
+ py.test.skip("ctypes backend: not supported: nested anonymous struct")
+
def test_nested_anonymous_union(self):
py.test.skip("ctypes backend: not supported: nested anonymous union")
diff --git a/testing/test_verify.py b/testing/test_verify.py
--- a/testing/test_verify.py
+++ b/testing/test_verify.py
@@ -1229,11 +1229,11 @@
xxx
def test_opaque_integer_as_function_result():
- import platform
- if platform.machine().startswith('sparc'):
- py.test.skip('Breaks horribly on sparc (SIGILL + corrupted stack)')
- elif platform.machine() == 'mips64' and sys.maxsize > 2**32:
- py.test.skip('Segfaults on mips64el')
+ #import platform
+ #if platform.machine().startswith('sparc'):
+ # py.test.skip('Breaks horribly on sparc (SIGILL + corrupted stack)')
+ #elif platform.machine() == 'mips64' and sys.maxsize > 2**32:
+ # py.test.skip('Segfaults on mips64el')
# XXX bad abuse of "struct { ...; }". It only works a bit by chance
# anyway. XXX think about something better :-(
ffi = FFI()
More information about the pypy-commit
mailing list