Author: Armin Rigo <ar...@tunes.org> Branch: Changeset: r59770:9b45d96d5a09 Date: 2013-01-05 19:57 +0100 http://bitbucket.org/pypy/pypy/changeset/9b45d96d5a09/
Log: merge heads diff --git a/pypy/jit/metainterp/test/test_fficall.py b/pypy/jit/metainterp/test/test_fficall.py --- a/pypy/jit/metainterp/test/test_fficall.py +++ b/pypy/jit/metainterp/test/test_fficall.py @@ -1,9 +1,11 @@ -import py + +import ctypes, math from pypy.rpython.lltypesystem import lltype, rffi from pypy.jit.metainterp.test.support import LLJitMixin from pypy.rlib import jit from pypy.rlib.jit_libffi import types, CIF_DESCRIPTION, FFI_TYPE_PP from pypy.rlib.unroll import unrolling_iterable +from pypy.rlib.rarithmetic import intmask def get_description(atypes, rtype): @@ -103,4 +105,40 @@ class TestFfiCall(FfiCallTests, LLJitMixin): - pass + def test_jit_fii_vref(self): + from pypy.rlib import clibffi + from pypy.rlib.jit_libffi import jit_ffi_prep_cif, jit_ffi_call + + math_sin = intmask(ctypes.cast(ctypes.CDLL(None).sin, + ctypes.c_void_p).value) + math_sin = rffi.cast(rffi.VOIDP, math_sin) + + cd = lltype.malloc(CIF_DESCRIPTION, 1, flavor='raw') + cd.abi = clibffi.FFI_DEFAULT_ABI + cd.nargs = 1 + cd.rtype = clibffi.cast_type_to_ffitype(rffi.DOUBLE) + atypes = lltype.malloc(clibffi.FFI_TYPE_PP.TO, 1, flavor='raw') + atypes[0] = clibffi.cast_type_to_ffitype(rffi.DOUBLE) + cd.atypes = atypes + cd.exchange_size = 64 # 64 bytes of exchange data + cd.exchange_result = 24 + cd.exchange_result_libffi = 24 + cd.exchange_args[0] = 16 + + def f(): + # + jit_ffi_prep_cif(cd) + # + assert rffi.sizeof(rffi.DOUBLE) == 8 + exb = lltype.malloc(rffi.DOUBLEP.TO, 8, flavor='raw') + exb[2] = 1.23 + jit_ffi_call(cd, math_sin, rffi.cast(rffi.CCHARP, exb)) + res = exb[3] + lltype.free(exb, flavor='raw') + # + lltype.free(atypes, flavor='raw') + return res + # + res = self.interp_operations(f, []) + lltype.free(cd, flavor='raw') + assert res == math.sin(1.23) diff --git a/pypy/rlib/jit_libffi.py b/pypy/rlib/jit_libffi.py --- a/pypy/rlib/jit_libffi.py +++ b/pypy/rlib/jit_libffi.py @@ -1,4 +1,4 @@ -import sys + from pypy.rpython.lltypesystem import lltype, rffi from pypy.rlib import clibffi, jit _______________________________________________ pypy-commit mailing list pypy-commit@python.org http://mail.python.org/mailman/listinfo/pypy-commit