def memcpy(target, source, n): impl = libffi.CDLL(libffi.get_libc_name()).getpointer( "memcpy", [ libffi.ffi_type_pointer, libffi.ffi_type_pointer, libffi.ffi_type_uint ], libffi.ffi_type_void) impl.push_arg(target) impl.push_arg(source) impl.push_arg(n) impl.call(lltype.Void)
def setup_class(cls): from pypy.rpython.lltypesystem import rffi from pypy.rlib.libffi import get_libc_name, CDLL, types from pypy.rlib.test.test_libffi import get_libm_name space = gettestobjspace(usemodules=('_ffi', '_rawffi')) cls.space = space cls.w_iswin32 = space.wrap(sys.platform == 'win32') cls.w_libfoo_name = space.wrap(cls.prepare_c_example()) cls.w_libc_name = space.wrap(get_libc_name()) libm_name = get_libm_name(sys.platform) cls.w_libm_name = space.wrap(libm_name) libm = CDLL(libm_name) pow = libm.getpointer('pow', [], types.void) pow_addr = rffi.cast(rffi.LONG, pow.funcsym) cls.w_pow_addr = space.wrap(pow_addr)
def setup_class(cls): from pypy.rlib.libffi import get_libc_name space = gettestobjspace(usemodules=('_rawffi', 'struct')) cls.space = space cls.w_lib_name = space.wrap(cls.prepare_c_example()) cls.w_libc_name = space.wrap(get_libc_name()) if sys.platform == 'win32': cls.w_iswin32 = space.wrap(True) cls.w_libm_name = space.wrap('msvcrt') else: cls.w_iswin32 = space.wrap(False) cls.w_libm_name = space.wrap('libm.so') if sys.platform == "darwin": cls.w_libm_name = space.wrap('libm.dylib') import platform cls.w_isx86_64 = space.wrap(platform.machine() == 'x86_64') cls.w_sizes_and_alignments = space.wrap(dict( [(k, (v.c_size, v.c_alignment)) for k,v in TYPEMAP.iteritems()]))
def setup_class(cls): from pypy.rlib.libffi import get_libc_name space = gettestobjspace(usemodules=('_rawffi', 'struct')) cls.space = space cls.w_lib_name = space.wrap(cls.prepare_c_example()) cls.w_libc_name = space.wrap(get_libc_name()) if sys.platform == 'win32': cls.w_iswin32 = space.wrap(True) cls.w_libm_name = space.wrap('msvcrt') else: cls.w_iswin32 = space.wrap(False) cls.w_libm_name = space.wrap('libm.so') if sys.platform == "darwin": cls.w_libm_name = space.wrap('libm.dylib') import platform cls.w_isx86_64 = space.wrap(platform.machine() == 'x86_64') cls.w_sizes_and_alignments = space.wrap( dict([(k, (v.c_size, v.c_alignment)) for k, v in TYPEMAP.iteritems()]))
def setup_class(cls): from pypy.rpython.lltypesystem import rffi from pypy.rlib.libffi import get_libc_name, CDLL, types from pypy.rlib.test.test_libffi import get_libm_name space = gettestobjspace(usemodules=('_ffi', '_rawffi')) cls.space = space cls.w_iswin32 = space.wrap(sys.platform == 'win32') cls.w_libfoo_name = space.wrap(cls.prepare_c_example()) cls.w_libc_name = space.wrap(get_libc_name()) libm_name = get_libm_name(sys.platform) cls.w_libm_name = space.wrap(libm_name) libm = CDLL(libm_name) pow = libm.getpointer('pow', [], types.void) pow_addr = rffi.cast(rffi.LONG, pow.funcsym) cls.w_pow_addr = space.wrap(pow_addr) # # these are needed for test_single_float_args from ctypes import c_float f_12_34 = c_float(12.34).value f_56_78 = c_float(56.78).value f_result = c_float(f_12_34 + f_56_78).value cls.w_f_12_34_plus_56_78 = space.wrap(f_result)
def f(): libc = CDLL(get_libc_name()) qsort = libc.getpointer('qsort', [ffi_type_pointer, slong, slong, ffi_type_pointer], ffi_type_void) ptr = CallbackFuncPtr([ffi_type_pointer, ffi_type_pointer], ffi_type_sint, callback) TP = rffi.CArray(rffi.INT) to_sort = lltype.malloc(TP, 4, flavor='raw') to_sort[0] = 4 to_sort[1] = 3 to_sort[2] = 1 to_sort[3] = 2 qsort.push_arg(rffi.cast(rffi.VOIDP, to_sort)) qsort.push_arg(rffi.sizeof(rffi.INT)) qsort.push_arg(4) qsort.push_arg(rffi.cast(rffi.VOIDP, ptr.ll_closure)) qsort.call(lltype.Void) result = [to_sort[i] for i in range(4)] == [1,2,3,4] lltype.free(to_sort, flavor='raw') keepalive_until_here(ptr) return int(result)
def f(): libc = CDLL(get_libc_name()) qsort = libc.getpointer( 'qsort', [ffi_type_pointer, slong, slong, ffi_type_pointer], ffi_type_void) ptr = CallbackFuncPtr([ffi_type_pointer, ffi_type_pointer], ffi_type_sint, callback) TP = rffi.CArray(rffi.INT) to_sort = lltype.malloc(TP, 4, flavor='raw') to_sort[0] = 4 to_sort[1] = 3 to_sort[2] = 1 to_sort[3] = 2 qsort.push_arg(rffi.cast(rffi.VOIDP, to_sort)) qsort.push_arg(rffi.sizeof(rffi.INT)) qsort.push_arg(4) qsort.push_arg(rffi.cast(rffi.VOIDP, ptr.ll_closure)) qsort.call(lltype.Void) result = [to_sort[i] for i in range(4)] == [1, 2, 3, 4] lltype.free(to_sort, flavor='raw') keepalive_until_here(ptr) return int(result)
def memcpy(target,source,n): impl = libffi.CDLL(libffi.get_libc_name()).getpointer("memcpy",[libffi.ffi_type_pointer,libffi.ffi_type_pointer,libffi.ffi_type_uint],libffi.ffi_type_void) impl.push_arg(target) impl.push_arg(source) impl.push_arg(n) impl.call(lltype.Void)
def setup_class(cls): cls.space = gettestobjspace(usemodules=["cpyext", "thread", "_rawffi", "array"]) from pypy.rlib.libffi import get_libc_name cls.w_libc = cls.space.wrap(get_libc_name())
def setup_class(cls): cls.space = gettestobjspace(usemodules=['cpyext', 'thread', '_rawffi']) from pypy.rlib.libffi import get_libc_name cls.w_libc = cls.space.wrap(get_libc_name())
def __init__(self,library_path): self.lib = libffi.CDLL(library_path) self._libc = libffi.CDLL(libffi.get_libc_name())
def __init__(self, library_path): self.lib = libffi.CDLL(library_path) self._libc = libffi.CDLL(libffi.get_libc_name())