Exemplo n.º 1
0
def try_with_lib(extralibs, **kwds):
    global most_recent_error
    # at least on Gentoo Linux, readline.h doesn't compile if stdio.h is not
    # included before
    eci = ExternalCompilationInfo(
        includes = ["stdio.h", "readline/readline.h", "readline/history.h"],
        libraries = extralibs + ['readline'],
        )
    try:
        platform.verify_eci(eci)
        return eci
    except platform.CompilationError, e:
        most_recent_error = e
        return None
Exemplo n.º 2
0
def test_external_lib():
    # XXX this one seems to be a bit too platform-specific. Check
    #     how to test it on windows correctly (using so_prefix?)
    #     and what are alternatives to LD_LIBRARY_PATH
    eci = ExternalCompilationInfo()
    c_source = """
    int f(int a, int b)
    {
        return (a + b);
    }
    """
    tmpdir = udir.join("external_lib").ensure(dir=1)
    c_file = tmpdir.join("libc_lib.c")
    c_file.write(c_source)
    l = platform.compile([c_file], eci, standalone=False)
    eci = ExternalCompilationInfo(libraries=["c_lib"], library_dirs=[str(tmpdir)])
    rffi_platform.verify_eci(eci)
Exemplo n.º 3
0
def test_external_lib():
    # XXX this one seems to be a bit too platform-specific. Check
    #     how to test it on windows correctly (using so_prefix?)
    #     and what are alternatives to LD_LIBRARY_PATH
    eci = ExternalCompilationInfo()
    c_source = """
    int f(int a, int b)
    {
        return (a + b);
    }
    """
    tmpdir = udir.join('external_lib').ensure(dir=1)
    c_file = tmpdir.join('libc_lib.c')
    c_file.write(c_source)
    l = platform.compile([c_file], eci, standalone=False)
    eci = ExternalCompilationInfo(libraries=['c_lib'],
                                  library_dirs=[str(tmpdir)])
    rffi_platform.verify_eci(eci)
Exemplo n.º 4
0
"""
Support for valgrind: tell it when we patch code in-place.
"""

from pypy.rpython.tool import rffi_platform
from pypy.rpython.lltypesystem import lltype, llmemory, rffi
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rlib.objectmodel import we_are_translated


eci = ExternalCompilationInfo(includes = ['valgrind/valgrind.h'])

try:
    rffi_platform.verify_eci(eci)
except rffi_platform.CompilationError:
    VALGRIND_DISCARD_TRANSLATIONS = None
else:
    VALGRIND_DISCARD_TRANSLATIONS = rffi.llexternal(
        "VALGRIND_DISCARD_TRANSLATIONS",
        [llmemory.Address, lltype.Signed],
        lltype.Void,
        compilation_info=eci,
        _nowrapper=True,
        sandboxsafe=True)

# ____________________________________________________________

def discard_translations(data, size):
    if we_are_translated() and VALGRIND_DISCARD_TRANSLATIONS is not None:
        VALGRIND_DISCARD_TRANSLATIONS(llmemory.cast_int_to_adr(data), size)
Exemplo n.º 5
0
def test_verify_eci():
    eci = ExternalCompilationInfo()
    rffi_platform.verify_eci(eci)
    eci = ExternalCompilationInfo(libraries=['some_name_that_doesnt_exist_'])
    py.test.raises(rffi_platform.CompilationError,
                   rffi_platform.verify_eci, eci)
Exemplo n.º 6
0
from pypy.rpython.tool import rffi_platform as platform
from pypy.rpython.extfunc import register_external


class LocaleError(Exception):
    def __init__(self, message):
        self.message = message


HAVE_LANGINFO = sys.platform != "win32"
HAVE_LIBINTL = sys.platform != "win32"
libraries = []

if HAVE_LIBINTL:
    try:
        platform.verify_eci(ExternalCompilationInfo(includes=["libintl.h"], libraries=["intl"]))
        libraries.append("intl")
    except platform.CompilationError:
        try:
            platform.verify_eci(ExternalCompilationInfo(includes=["libintl.h"]))
        except platform.CompilationError:
            HAVE_LIBINTL = False


class CConfig:
    includes = ["locale.h", "limits.h", "ctype.h", "wchar.h"]
    libraries = libraries

    if HAVE_LANGINFO:
        includes += ["langinfo.h"]
    if HAVE_LIBINTL:
Exemplo n.º 7
0
def check_sdl_installation():
    from pypy.rpython.tool import rffi_platform as platform
    platform.verify_eci(get_rsdl_compilation_info())
Exemplo n.º 8
0
    include_dirs = [cdir],
    includes = ['src/stacklet/stacklet.h'],
    separate_module_sources = ['#include "src/stacklet/stacklet.c"\n'],
)
if sys.platform == 'win32':
    eci.separate_module_files += (cdir / "src/stacklet/switch_x86_msvc.asm", )
    eci.export_symbols += (
        'stacklet_newthread',
        'stacklet_deletethread',
        'stacklet_new',
        'stacklet_switch',
        'stacklet_destroy',
        '_stacklet_translate_pointer',
        )

rffi_platform.verify_eci(eci.convert_sources_to_files())

def llexternal(name, args, result, **kwds):
    return rffi.llexternal(name, args, result, compilation_info=eci,
                           _nowrapper=True, **kwds)

# ----- types -----

handle = rffi.COpaquePtr(typedef='stacklet_handle', compilation_info=eci)
thread_handle = rffi.COpaquePtr(typedef='stacklet_thread_handle',
                                compilation_info=eci)
run_fn = lltype.Ptr(lltype.FuncType([handle, llmemory.Address], handle))

# ----- constants -----

null_handle = lltype.nullptr(handle.TO)
Exemplo n.º 9
0
Arquivo: eci.py Projeto: enyst/plexnet
def check_sdl_installation():
    from pypy.rpython.tool import rffi_platform as platform
    platform.verify_eci(get_rsdl_compilation_info())
Exemplo n.º 10
0
from pypy.rpython.lltypesystem import rffi, lltype
from pypy.translator.tool.cbuild import ExternalCompilationInfo
from pypy.rpython.tool import rffi_platform as platform
from pypy.rpython.extfunc import register_external

class LocaleError(Exception):
    def __init__(self, message):
        self.message = message

HAVE_LANGINFO = sys.platform != 'win32'
HAVE_LIBINTL  = sys.platform != 'win32'
libraries = []

if HAVE_LIBINTL:
    try:
        platform.verify_eci(ExternalCompilationInfo(includes=['libintl.h'],
                                                    libraries=['intl']))
        libraries.append('intl')
    except platform.CompilationError:
        try:
            platform.verify_eci(ExternalCompilationInfo(includes=['libintl.h']))
        except platform.CompilationError:
            HAVE_LIBINTL = False

class CConfig:
    includes = ['locale.h', 'limits.h', 'ctype.h']
    libraries = libraries

    if HAVE_LANGINFO:
        includes += ['langinfo.h']
    if HAVE_LIBINTL:
        includes += ['libintl.h']
Exemplo n.º 11
0
def test_verify_eci():
    eci = ExternalCompilationInfo()
    rffi_platform.verify_eci(eci)
    eci = ExternalCompilationInfo(libraries=['some_name_that_doesnt_exist_'])
    py.test.raises(rffi_platform.CompilationError, rffi_platform.verify_eci,
                   eci)
Exemplo n.º 12
0
if 'masm' in dir(eci.platform):  # Microsoft compiler
    if is_emulated_long:
        asmsrc = 'switch_x64_msvc.asm'
    else:
        asmsrc = 'switch_x86_msvc.asm'
    eci.separate_module_files += (cdir / 'src' / 'stacklet' / asmsrc, )
    eci.export_symbols += (
        'stacklet_newthread',
        'stacklet_deletethread',
        'stacklet_new',
        'stacklet_switch',
        'stacklet_destroy',
        '_stacklet_translate_pointer',
    )

rffi_platform.verify_eci(eci.convert_sources_to_files())


def llexternal(name, args, result, **kwds):
    return rffi.llexternal(name,
                           args,
                           result,
                           compilation_info=eci,
                           _nowrapper=True,
                           **kwds)


# ----- types -----

handle = rffi.COpaquePtr(typedef='stacklet_handle', compilation_info=eci)
thread_handle = rffi.COpaquePtr(typedef='stacklet_thread_handle',