[pypy-svn] r68083 - pypy/trunk/pypy/jit/backend/llsupport

afa at codespeak.net afa at codespeak.net
Thu Oct 1 09:53:24 CEST 2009


Author: afa
Date: Thu Oct  1 09:53:24 2009
New Revision: 68083

Modified:
   pypy/trunk/pypy/jit/backend/llsupport/gc.py
Log:
Boehm version 7.x doesn't define GC_local_malloc: call GC_malloc instead.
This fixes translation with "-Ojit --gc=boehm" on Windows.


Modified: pypy/trunk/pypy/jit/backend/llsupport/gc.py
==============================================================================
--- pypy/trunk/pypy/jit/backend/llsupport/gc.py	(original)
+++ pypy/trunk/pypy/jit/backend/llsupport/gc.py	Thu Oct  1 09:53:24 2009
@@ -37,8 +37,23 @@
     def __init__(self, gcdescr, translator):
         GcLLDescription.__init__(self, gcdescr, translator)
         # grab a pointer to the Boehm 'malloc' function
-        compilation_info = ExternalCompilationInfo(libraries=['gc'])
-        malloc_fn_ptr = rffi.llexternal("GC_local_malloc",
+        from pypy.rpython.tool import rffi_platform
+        compilation_info = rffi_platform.check_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,
@@ -48,6 +63,7 @@
 
         # 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,



More information about the Pypy-commit mailing list