Author: Armin Rigo <[email protected]>
Branch: stmgc-c4
Changeset: r66909:4f180feddf69
Date: 2013-09-11 19:57 +0200
http://bitbucket.org/pypy/pypy/changeset/4f180feddf69/
Log: Fix dtoa.c to use stm_call_on_abort(), which makes the code
transactionsafe again.
diff --git a/rpython/rlib/rdtoa.py b/rpython/rlib/rdtoa.py
--- a/rpython/rlib/rdtoa.py
+++ b/rpython/rlib/rdtoa.py
@@ -40,17 +40,16 @@
dg_strtod = rffi.llexternal(
'_PyPy_dg_strtod', [rffi.CCHARP, rffi.CCHARPP], rffi.DOUBLE,
- compilation_info=eci, sandboxsafe=True,
- transactionsafe=True)
+ compilation_info=eci, sandboxsafe=True, transactionsafe=True)
dg_dtoa = rffi.llexternal(
'_PyPy_dg_dtoa', [rffi.DOUBLE, rffi.INT, rffi.INT,
rffi.INTP, rffi.INTP, rffi.CCHARPP], rffi.CCHARP,
- compilation_info=eci, sandboxsafe=True)
+ compilation_info=eci, sandboxsafe=True, transactionsafe=True)
dg_freedtoa = rffi.llexternal(
'_PyPy_dg_freedtoa', [rffi.CCHARP], lltype.Void,
- compilation_info=eci, sandboxsafe=True)
+ compilation_info=eci, sandboxsafe=True, transactionsafe=True)
def strtod(input):
ll_input = rffi.str2charp(input)
diff --git a/rpython/translator/c/src/dtoa.c b/rpython/translator/c/src/dtoa.c
--- a/rpython/translator/c/src/dtoa.c
+++ b/rpython/translator/c/src/dtoa.c
@@ -325,11 +325,13 @@
typedef struct Bigint Bigint;
+#ifdef RPY_STM
#define Py_USING_MEMORY_DEBUGGER /* Set to use thread-safe malloc, free */
#undef MALLOC
#undef FREE
#define MALLOC malloc /* use thread-safe malloc/free */
#define FREE free
+#endif
#ifndef Py_USING_MEMORY_DEBUGGER
@@ -2966,11 +2968,17 @@
_PyPy_SET_53BIT_PRECISION_START;
result = __Py_dg_dtoa(dd, mode, ndigits, decpt, sign, rve);
_PyPy_SET_53BIT_PRECISION_END;
+#ifdef RPY_STM
+ stm_call_on_abort(result, _PyPy_dg_freedtoa);
+#endif
return result;
}
void _PyPy_dg_freedtoa(char *s)
{
+#ifdef RPY_STM
+ stm_call_on_abort(s, NULL);
+#endif
__Py_dg_freedtoa(s);
}
/* End PYPY hacks */
diff --git a/rpython/translator/stm/test/test_ztranslated.py
b/rpython/translator/stm/test/test_ztranslated.py
--- a/rpython/translator/stm/test/test_ztranslated.py
+++ b/rpython/translator/stm/test/test_ztranslated.py
@@ -376,3 +376,17 @@
data, dataerr = cbuilder.cmdexec('', err=True)
lines = dataerr.split('\n')
assert lines[0] == lines[1]
+
+ def test_dtoa(self):
+ def main(argv):
+ a = len(argv) * 0.2
+ b = len(argv) * 0.6
+ debug_print(str(a))
+ debug_print(str(b))
+ return 0
+
+ t, cbuilder = self.compile(main)
+ data, dataerr = cbuilder.cmdexec('a', err=True)
+ lines = dataerr.split('\n')
+ assert lines[0] == ' 0.400000'
+ assert lines[1] == ' 1.200000'
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit