Example #1
0
def setup_module(mod):
    from pypy.rpython.tool.rffi_platform import configure_boehm
    from pypy.translator.platform import CompilationError
    try:
        configure_boehm()
    except CompilationError:
        py.test.skip("Boehm GC not present")
Example #2
0
def setup_module(mod):
    from pypy.rpython.tool.rffi_platform import configure_boehm
    from pypy.translator.platform import CompilationError
    try:
        configure_boehm()
    except CompilationError:
        py.test.skip("Boehm GC not present")
Example #3
0
 def setup_class(cls):
     import py
     if cls.gcpolicy in (None, "ref"):
         import py
         py.test.skip("stackless + refcounting doesn't work any more for now")
     elif cls.gcpolicy == "boehm":
         from pypy.rpython.tool.rffi_platform import configure_boehm
         from pypy.translator.platform import CompilationError
         try:
             configure_boehm()
         except CompilationError:
             py.test.skip("Boehm GC not present")
Example #4
0
 def setup_class(cls):
     import py
     if cls.gcpolicy in (None, "ref"):
         import py
         py.test.skip("stackless + refcounting doesn't work any more for now")
     elif cls.gcpolicy == "boehm":
         from pypy.rpython.tool.rffi_platform import configure_boehm
         from pypy.translator.platform import CompilationError
         try:
             configure_boehm()
         except CompilationError:
             py.test.skip("Boehm GC not present")
Example #5
0
    def configure_boehm_once(cls):
        """ Configure boehm only once, since we don't cache failures
        """
        if hasattr(cls, 'malloc_fn_ptr'):
            return cls.malloc_fn_ptr
        from pypy.rpython.tool import rffi_platform
        compilation_info = rffi_platform.configure_boehm()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")
        config = rffi_platform.configure(CConfig)
        if config['HAS_LOCAL_MALLOC']:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"
        malloc_fn_ptr = rffi.llexternal(GC_MALLOC,
                                        [lltype.Signed], # size_t, but good enough
                                        llmemory.GCREF,
                                        compilation_info=compilation_info,
                                        sandboxsafe=True,
                                        _nowrapper=True)
        cls.malloc_fn_ptr = malloc_fn_ptr
        cls.compilation_info = compilation_info
        return malloc_fn_ptr
Example #6
0
    def compilation_info(self):
        eci = BasicGcPolicy.compilation_info(self)

        from pypy.rpython.tool.rffi_platform import configure_boehm
        eci = eci.merge(configure_boehm())

        pre_include_bits = []
        if sys.platform.startswith('linux'):
            pre_include_bits += ["#define _REENTRANT 1",
                                 "#define GC_LINUX_THREADS 1"]
        if sys.platform != "win32" and not sys.platform.startswith("openbsd"):
            # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]

        eci = eci.merge(ExternalCompilationInfo(
            pre_include_bits=pre_include_bits,
            post_include_bits=['#define USING_BOEHM_GC'],
            ))

        return eci
Example #7
0
    def configure_boehm_once(cls):
        """ Configure boehm only once, since we don't cache failures
        """
        if hasattr(cls, 'malloc_fn_ptr'):
            return cls.malloc_fn_ptr
        from pypy.rpython.tool import rffi_platform
        compilation_info = rffi_platform.configure_boehm()

        # on some platform GC_init is required before any other
        # GC_* functions, call it here for the benefit of tests
        # XXX move this to tests
        init_fn_ptr = rffi.llexternal("GC_init", [],
                                      lltype.Void,
                                      compilation_info=compilation_info,
                                      sandboxsafe=True,
                                      _nowrapper=True)
        init_fn_ptr()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")

        config = rffi_platform.configure(CConfig)
        if config['HAS_LOCAL_MALLOC']:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"
        malloc_fn_ptr = rffi.llexternal(
            GC_MALLOC,
            [lltype.Signed],  # size_t, but good enough
            llmemory.GCREF,
            compilation_info=compilation_info,
            sandboxsafe=True,
            _nowrapper=True)
        cls.malloc_fn_ptr = malloc_fn_ptr
        return malloc_fn_ptr
Example #8
0
    def configure_boehm_once(cls):
        """ Configure boehm only once, since we don't cache failures
        """
        if hasattr(cls, "malloc_fn_ptr"):
            return cls.malloc_fn_ptr
        from pypy.rpython.tool import rffi_platform

        compilation_info = rffi_platform.configure_boehm()

        # on some platform GC_init is required before any other
        # GC_* functions, call it here for the benefit of tests
        # XXX move this to tests
        init_fn_ptr = rffi.llexternal(
            "GC_init", [], lltype.Void, compilation_info=compilation_info, sandboxsafe=True, _nowrapper=True
        )
        init_fn_ptr()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")

        config = rffi_platform.configure(CConfig)
        if config["HAS_LOCAL_MALLOC"]:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"
        malloc_fn_ptr = rffi.llexternal(
            GC_MALLOC,
            [lltype.Signed],  # size_t, but good enough
            llmemory.GCREF,
            compilation_info=compilation_info,
            sandboxsafe=True,
            _nowrapper=True,
        )
        cls.malloc_fn_ptr = malloc_fn_ptr
        return malloc_fn_ptr
Example #9
0
    def __init__(self, gcdescr, translator):
        GcLLDescription.__init__(self, gcdescr, translator)
        # grab a pointer to the Boehm 'malloc' function
        from pypy.rpython.tool import rffi_platform
        compilation_info = rffi_platform.configure_boehm()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")

        config = rffi_platform.configure(CConfig)
        if config['HAS_LOCAL_MALLOC']:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"

        malloc_fn_ptr = rffi.llexternal(
            GC_MALLOC,
            [lltype.Signed],  # size_t, but good enough
            llmemory.GCREF,
            compilation_info=compilation_info,
            sandboxsafe=True,
            _nowrapper=True)
        self.funcptr_for_new = malloc_fn_ptr

        # on some platform GC_init is required before any other
        # GC_* functions, call it here for the benefit of tests
        # XXX move this to tests
        init_fn_ptr = rffi.llexternal("GC_init", [],
                                      lltype.Void,
                                      compilation_info=compilation_info,
                                      sandboxsafe=True,
                                      _nowrapper=True)

        init_fn_ptr()
Example #10
0
    def compilation_info(self):
        eci = BasicGcPolicy.compilation_info(self)

        from pypy.rpython.tool.rffi_platform import configure_boehm
        eci = eci.merge(configure_boehm())

        pre_include_bits = []
        if sys.platform.startswith('linux'):
            pre_include_bits += [
                "#define _REENTRANT 1", "#define GC_LINUX_THREADS 1"
            ]
        if sys.platform != "win32" and not sys.platform.startswith("openbsd"):
            # GC_REDIRECT_TO_LOCAL is not supported on Win32 by gc6.8
            pre_include_bits += ["#define GC_REDIRECT_TO_LOCAL 1"]

        eci = eci.merge(
            ExternalCompilationInfo(
                pre_include_bits=pre_include_bits,
                post_include_bits=['#define USING_BOEHM_GC'],
            ))

        return eci
Example #11
0
File: gc.py Project: alkorzt/pypy
    def __init__(self, gcdescr, translator):
        GcLLDescription.__init__(self, gcdescr, translator)
        # grab a pointer to the Boehm 'malloc' function
        from pypy.rpython.tool import rffi_platform
        compilation_info = rffi_platform.configure_boehm()

        # Versions 6.x of libgc needs to use GC_local_malloc().
        # Versions 7.x of libgc removed this function; GC_malloc() has
        # the same behavior if libgc was compiled with
        # THREAD_LOCAL_ALLOC.
        class CConfig:
            _compilation_info_ = compilation_info
            HAS_LOCAL_MALLOC = rffi_platform.Has("GC_local_malloc")
        config = rffi_platform.configure(CConfig)
        if config['HAS_LOCAL_MALLOC']:
            GC_MALLOC = "GC_local_malloc"
        else:
            GC_MALLOC = "GC_malloc"

        malloc_fn_ptr = rffi.llexternal(GC_MALLOC,
                                        [lltype.Signed], # size_t, but good enough
                                        llmemory.GCREF,
                                        compilation_info=compilation_info,
                                        sandboxsafe=True,
                                        _nowrapper=True)
        self.funcptr_for_new = malloc_fn_ptr

        # on some platform GC_init is required before any other
        # GC_* functions, call it here for the benefit of tests
        # XXX move this to tests
        init_fn_ptr = rffi.llexternal("GC_init",
                                      [], lltype.Void,
                                      compilation_info=compilation_info,
                                      sandboxsafe=True,
                                      _nowrapper=True)

        init_fn_ptr()