Esempio n. 1
0
def test_constant_integer():
    value = rffi_platform.getconstantinteger("BLAH", "#define BLAH (6*7)")
    assert value == 42
    value = rffi_platform.getconstantinteger("BLAH", "#define BLAH (-2147483648LL)")
    assert value == -2147483648
    value = rffi_platform.getconstantinteger("BLAH", "#define BLAH (3333333333ULL)")
    assert value == 3333333333
Esempio n. 2
0
def test_constant_integer():
    value = rffi_platform.getconstantinteger('BLAH', '#define BLAH (6*7)')
    assert value == 42
    value = rffi_platform.getconstantinteger('BLAH',
                                             '#define BLAH (-2147483648LL)')
    assert value == -2147483648
    value = rffi_platform.getconstantinteger('BLAH',
                                             '#define BLAH (3333333333ULL)')
    assert value == 3333333333
Esempio n. 3
0
from pypy.rpython.extfunc import register_external
from pypy.rlib.objectmodel import CDefinedIntSymbolic

if sys.platform == 'linux2':
    # This only works with linux's madvise(), which is really not a memory
    # usage hint but a real command.  It guarantees that after MADV_DONTNEED
    # the pages are cleared again.

    # Note that the trick of the general 'posix' section below, i.e.
    # reading /dev/zero, does not seem to have the correct effect of
    # lazily-allocating pages on all Linux systems.

    from pypy.rpython.tool import rffi_platform
    from pypy.translator.tool.cbuild import ExternalCompilationInfo
    _eci = ExternalCompilationInfo(includes=['sys/mman.h'])
    MADV_DONTNEED = rffi_platform.getconstantinteger('MADV_DONTNEED',
                                                     '#include <sys/mman.h>')
    linux_madvise = rffi.llexternal('madvise',
                                    [llmemory.Address, rffi.SIZE_T, rffi.INT],
                                    rffi.INT,
                                    sandboxsafe=True, _nowrapper=True,
                                    compilation_info=_eci)
    linux_getpagesize = rffi.llexternal('getpagesize', [], rffi.INT,
                                        sandboxsafe=True, _nowrapper=True)

    class LinuxPageSize:
        def __init__(self):
            self.pagesize = 0
        _freeze_ = __init__
    linuxpagesize = LinuxPageSize()

    def clear_large_memory_chunk(baseaddr, size):
Esempio n. 4
0
from pypy.rpython.extfunc import register_external
from pypy.rlib.objectmodel import CDefinedIntSymbolic

if sys.platform.startswith('linux'):
    # This only works with linux's madvise(), which is really not a memory
    # usage hint but a real command.  It guarantees that after MADV_DONTNEED
    # the pages are cleared again.

    # Note that the trick of the general 'posix' section below, i.e.
    # reading /dev/zero, does not seem to have the correct effect of
    # lazily-allocating pages on all Linux systems.

    from pypy.rpython.tool import rffi_platform
    from pypy.translator.tool.cbuild import ExternalCompilationInfo
    _eci = ExternalCompilationInfo(includes=['sys/mman.h'])
    MADV_DONTNEED = rffi_platform.getconstantinteger('MADV_DONTNEED',
                                                     '#include <sys/mman.h>')
    linux_madvise = rffi.llexternal('madvise',
                                    [llmemory.Address, rffi.SIZE_T, rffi.INT],
                                    rffi.INT,
                                    sandboxsafe=True,
                                    _nowrapper=True,
                                    compilation_info=_eci)
    linux_getpagesize = rffi.llexternal('getpagesize', [],
                                        rffi.INT,
                                        sandboxsafe=True,
                                        _nowrapper=True)

    class LinuxPageSize:
        def __init__(self):
            self.pagesize = 0