[pypy-commit] pypy null_byte_after_str: Hack hack hack to disable the ll2ctypes path of get_nonmovingbuffer()
arigo
pypy.commits at gmail.com
Sun Jul 31 05:41:25 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: null_byte_after_str
Changeset: r85948:529f8f3a4c48
Date: 2016-07-31 11:37 +0200
http://bitbucket.org/pypy/pypy/changeset/529f8f3a4c48/
Log: Hack hack hack to disable the ll2ctypes path of
get_nonmovingbuffer() everywhere. Now it should only be used by real
C code.
diff --git a/rpython/rlib/objectmodel.py b/rpython/rlib/objectmodel.py
--- a/rpython/rlib/objectmodel.py
+++ b/rpython/rlib/objectmodel.py
@@ -281,6 +281,7 @@
return lltype.Signed
malloc_zero_filled = CDefinedIntSymbolic('MALLOC_ZERO_FILLED', default=0)
+translated_to_c = CDefinedIntSymbolic('1 /* translated_to_c */', default=0)
# ____________________________________________________________
diff --git a/rpython/rtyper/lltypesystem/rffi.py b/rpython/rtyper/lltypesystem/rffi.py
--- a/rpython/rtyper/lltypesystem/rffi.py
+++ b/rpython/rtyper/lltypesystem/rffi.py
@@ -15,7 +15,7 @@
from rpython.rtyper.tool.rfficache import platform, sizeof_c_type
from rpython.translator.tool.cbuild import ExternalCompilationInfo
from rpython.rtyper.annlowlevel import llhelper
-from rpython.rlib.objectmodel import we_are_translated
+from rpython.rlib.objectmodel import we_are_translated, translated_to_c
from rpython.rlib.rstring import StringBuilder, UnicodeBuilder, assert_str0
from rpython.rlib import jit
from rpython.rtyper.lltypesystem import llmemory
@@ -837,10 +837,10 @@
lldata = llstrtype(data)
count = len(data)
- if not rgc.can_move(data):
+ if translated_to_c and not rgc.can_move(data):
flag = '\x04'
else:
- if we_are_translated() and rgc.pin(data):
+ if translated_to_c and rgc.pin(data):
flag = '\x05'
else:
buf = lltype.malloc(TYPEP.TO, count + (TYPEP is CCHARP),
@@ -849,7 +849,7 @@
return buf, '\x06'
# ^^^ raw malloc used to get a nonmovable copy
#
- # following code is executed if:
+ # following code is executed after we're translated to C, if:
# - rgc.can_move(data) and rgc.pin(data) both returned true
# - rgc.can_move(data) returned false
data_start = cast_ptr_to_adr(lldata) + \
More information about the pypy-commit
mailing list