def test_getintegerfunctionresult(): func = 'int sum(int a, int b) {return a + b;}' value = rffi_platform.getintegerfunctionresult('sum', [6, 7], func) assert value == 13 value = rffi_platform.getintegerfunctionresult('lround', [6.7], '#include <math.h>') assert value == 7 value = rffi_platform.getintegerfunctionresult('lround', [9.1], includes=['math.h']) assert value == 9
def test_getintegerfunctionresult(): func = 'RPY_EXPORTED int sum(int a, int b) {return a + b;}' value = rffi_platform.getintegerfunctionresult('sum', [6, 7], func) assert value == 13 if not platform.name == 'msvc': # MSVC gets lround in VS2013! value = rffi_platform.getintegerfunctionresult('lround', [6.7], '#include <math.h>') assert value == 7 value = rffi_platform.getintegerfunctionresult('lround', [9.1], includes=['math.h']) assert value == 9
def test_getintegerfunctionresult(): func = 'int sum(int a, int b) {return a + b;}' if platform.name == 'msvc': func = '__declspec(dllexport) ' + func value = rffi_platform.getintegerfunctionresult('sum', [6, 7], func) assert value == 13 if not platform.name == 'msvc': # MSVC gets lround in VS2013! value = rffi_platform.getintegerfunctionresult('lround', [6.7], '#include <math.h>') assert value == 7 value = rffi_platform.getintegerfunctionresult('lround', [9.1], includes=['math.h']) assert value == 9
save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO) # 'mmap' on linux32 is a macro that calls 'mmap64' _, c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT) c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT, save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO) if has_mremap: c_mremap, _ = external('mremap', [PTR, size_t, size_t, rffi.ULONG], PTR) if has_madvise: _, c_madvise_safe = external('madvise', [PTR, size_t, rffi.INT], rffi.INT, _nowrapper=True) # this one is always safe _pagesize = rffi_platform.getintegerfunctionresult('getpagesize', includes=includes) _get_allocation_granularity = _get_page_size = lambda: _pagesize elif _MS_WINDOWS: class ComplexCConfig: _compilation_info_ = CConfig._compilation_info_ SYSINFO_STRUCT = rffi.CStruct( 'SYSINFO_STRUCT', ("wProcessorArchitecture", WORD), ("wReserved", WORD), ) SYSINFO_UNION = rffi.CStruct( 'union SYSINFO_UNION',
if _POSIX: has_mremap = cConfig['has_mremap'] c_mmap, c_mmap_safe = external('mmap', [PTR, size_t, rffi.INT, rffi.INT, rffi.INT, off_t], PTR, macro=True, save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO) # 'mmap' on linux32 is a macro that calls 'mmap64' _, c_munmap_safe = external('munmap', [PTR, size_t], rffi.INT) c_msync, _ = external('msync', [PTR, size_t, rffi.INT], rffi.INT, save_err_on_unsafe=rffi.RFFI_SAVE_ERRNO) if has_mremap: c_mremap, _ = external('mremap', [PTR, size_t, size_t, rffi.ULONG], PTR) # this one is always safe _pagesize = rffi_platform.getintegerfunctionresult('getpagesize', includes=includes) _get_allocation_granularity = _get_page_size = lambda: _pagesize elif _MS_WINDOWS: class ComplexCConfig: _compilation_info_ = CConfig._compilation_info_ SYSINFO_STRUCT = rffi.CStruct( 'SYSINFO_STRUCT', ("wProcessorArchitecture", WORD), ("wReserved", WORD), ) SYSINFO_UNION = rffi.CStruct( 'union SYSINFO_UNION',