Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
c0c29dff
Kaydet (Commit)
c0c29dff
authored
Eyl 09, 2017
tarafından
Stefan Krah
Kaydeden (comit)
GitHub
Eyl 09, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-31403: Remove WITHOUT_THREADS from _decimal. (#3474)
üst
a7fbad96
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
113 deletions
+16
-113
_decimal.c
Modules/_decimal/_decimal.c
+1
-94
runall-memorydebugger.sh
Modules/_decimal/tests/runall-memorydebugger.sh
+15
-19
No files found.
Modules/_decimal/_decimal.c
Dosyayı görüntüle @
c0c29dff
...
...
@@ -80,9 +80,7 @@ typedef struct {
PyObject
*
traps
;
PyObject
*
flags
;
int
capitals
;
#ifndef WITHOUT_THREADS
PyThreadState
*
tstate
;
#endif
}
PyDecContextObject
;
typedef
struct
{
...
...
@@ -124,15 +122,10 @@ incr_false(void)
}
#ifdef WITHOUT_THREADS
/* Default module context */
static
PyObject
*
module_context
=
NULL
;
#else
/* Key for thread state dictionary */
static
PyObject
*
tls_context_key
=
NULL
;
/* Invariant: NULL or the most recently accessed thread local context */
static
PyDecContextObject
*
cached_context
=
NULL
;
#endif
/* Template for creating new thread contexts, calling Context() without
* arguments and initializing the module_context on first access. */
...
...
@@ -1219,9 +1212,7 @@ context_new(PyTypeObject *type, PyObject *args UNUSED, PyObject *kwds UNUSED)
SdFlagAddr
(
self
->
flags
)
=
&
ctx
->
status
;
CtxCaps
(
self
)
=
1
;
#ifndef WITHOUT_THREADS
self
->
tstate
=
NULL
;
#endif
return
(
PyObject
*
)
self
;
}
...
...
@@ -1229,11 +1220,10 @@ context_new(PyTypeObject *type, PyObject *args UNUSED, PyObject *kwds UNUSED)
static
void
context_dealloc
(
PyDecContextObject
*
self
)
{
#ifndef WITHOUT_THREADS
if
(
self
==
cached_context
)
{
cached_context
=
NULL
;
}
#endif
Py_XDECREF
(
self
->
traps
);
Py_XDECREF
(
self
->
flags
);
Py_TYPE
(
self
)
->
tp_free
(
self
);
...
...
@@ -1501,76 +1491,6 @@ static PyGetSetDef context_getsets [] =
/* Global, thread local and temporary contexts */
/******************************************************************************/
#ifdef WITHOUT_THREADS
/* Return borrowed reference to the current context. When compiled
* without threads, this is always the module context. */
static
int
module_context_set
=
0
;
static
PyObject
*
current_context
(
void
)
{
/* In decimal.py, the module context is automatically initialized
* from the DefaultContext when it is first accessed. This
* complicates the code and has a speed penalty of 1-2%. */
if
(
module_context_set
)
{
return
module_context
;
}
*
CTX
(
module_context
)
=
*
CTX
(
default_context_template
);
CTX
(
module_context
)
->
status
=
0
;
CTX
(
module_context
)
->
newtrap
=
0
;
CtxCaps
(
module_context
)
=
CtxCaps
(
default_context_template
);
module_context_set
=
1
;
return
module_context
;
}
/* ctxobj := borrowed reference to the current context */
#define CURRENT_CONTEXT(ctxobj) \
ctxobj = current_context()
/* ctx := pointer to the mpd_context_t struct of the current context */
#define CURRENT_CONTEXT_ADDR(ctx) \
ctx = CTX(current_context())
/* Return a new reference to the current context */
static
PyObject
*
PyDec_GetCurrentContext
(
PyObject
*
self
UNUSED
,
PyObject
*
args
UNUSED
)
{
PyObject
*
context
;
CURRENT_CONTEXT
(
context
);
Py_INCREF
(
context
);
return
context
;
}
/* Set the module context to a new context, decrement old reference */
static
PyObject
*
PyDec_SetCurrentContext
(
PyObject
*
self
UNUSED
,
PyObject
*
v
)
{
CONTEXT_CHECK
(
v
);
/* If the new context is one of the templates, make a copy.
* This is the current behavior of decimal.py. */
if
(
v
==
default_context_template
||
v
==
basic_context_template
||
v
==
extended_context_template
)
{
v
=
context_copy
(
v
,
NULL
);
if
(
v
==
NULL
)
{
return
NULL
;
}
CTX
(
v
)
->
status
=
0
;
}
else
{
Py_INCREF
(
v
);
}
Py_XDECREF
(
module_context
);
module_context
=
v
;
module_context_set
=
1
;
Py_RETURN_NONE
;
}
#else
/*
* Thread local storage currently has a speed penalty of about 4%.
* All functions that map Python's arithmetic operators to mpdecimal
...
...
@@ -1713,7 +1633,6 @@ PyDec_SetCurrentContext(PyObject *self UNUSED, PyObject *v)
Py_DECREF
(
v
);
Py_RETURN_NONE
;
}
#endif
/* Context manager object for the 'with' statement. The manager
* owns one reference to the global (outer) context and one
...
...
@@ -5840,17 +5759,9 @@ PyInit__decimal(void)
CHECK_INT
(
PyModule_AddObject
(
m
,
"DefaultContext"
,
default_context_template
));
#ifdef WITHOUT_THREADS
/* Init module context */
ASSIGN_PTR
(
module_context
,
PyObject_CallObject
((
PyObject
*
)
&
PyDecContext_Type
,
NULL
));
Py_INCREF
(
Py_False
);
CHECK_INT
(
PyModule_AddObject
(
m
,
"HAVE_THREADS"
,
Py_False
));
#else
ASSIGN_PTR
(
tls_context_key
,
PyUnicode_FromString
(
"___DECIMAL_CTX__"
));
Py_INCREF
(
Py_True
);
CHECK_INT
(
PyModule_AddObject
(
m
,
"HAVE_THREADS"
,
Py_True
));
#endif
/* Init basic context template */
ASSIGN_PTR
(
basic_context_template
,
...
...
@@ -5906,12 +5817,8 @@ error:
Py_CLEAR
(
MutableMapping
);
/* GCOV_NOT_REACHED */
Py_CLEAR
(
SignalTuple
);
/* GCOV_NOT_REACHED */
Py_CLEAR
(
DecimalTuple
);
/* GCOV_NOT_REACHED */
#ifdef WITHOUT_THREADS
Py_CLEAR
(
module_context
);
/* GCOV_NOT_REACHED */
#else
Py_CLEAR
(
default_context_template
);
/* GCOV_NOT_REACHED */
Py_CLEAR
(
tls_context_key
);
/* GCOV_NOT_REACHED */
#endif
Py_CLEAR
(
basic_context_template
);
/* GCOV_NOT_REACHED */
Py_CLEAR
(
extended_context_template
);
/* GCOV_NOT_REACHED */
Py_CLEAR
(
m
);
/* GCOV_NOT_REACHED */
...
...
Modules/_decimal/tests/runall-memorydebugger.sh
Dosyayı görüntüle @
c0c29dff
#!/bin/sh
#
# Purpose: test
with and without threads, all machine configurations, pydebug,
#
refleaks, release build
and release build with valgrind.
# Purpose: test
all machine configurations, pydebug, refleaks, release build
# and release build with valgrind.
#
# Synopsis: ./runall-memorydebugger.sh [--all-configs64 | --all-configs32]
#
...
...
@@ -57,8 +57,7 @@ print_config ()
cd
..
# test_decimal: refleak, regular and Valgrind tests
for
args
in
"--without-threads"
""
;
do
for
config
in
$CONFIGS
;
do
for
config
in
$CONFIGS
;
do
unset
PYTHON_DECIMAL_WITH_MACHINE
libmpdec_config
=
$config
...
...
@@ -70,12 +69,12 @@ for args in "--without-threads" ""; do
fi
############ refleak tests ###########
print_config
"refleak tests: config=
$config
"
$args
print_config
"refleak tests: config=
$config
"
printf
"
\n
building python ...
\n\n
"
cd
../../
$GMAKE
distclean
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--with-pydebug
$args
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--with-pydebug
>
/dev/null 2>&1
$GMAKE
|
grep
_decimal
printf
"
\n\n
# ======================== refleak tests ===========================
\n\n
"
...
...
@@ -83,11 +82,11 @@ for args in "--without-threads" ""; do
############ regular tests ###########
print_config
"regular tests: config=
$config
"
$args
print_config
"regular tests: config=
$config
"
printf
"
\n
building python ...
\n\n
"
$GMAKE
distclean
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
$args
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
>
/dev/null 2>&1
$GMAKE
|
grep
_decimal
printf
"
\n\n
# ======================== regular tests ===========================
\n\n
"
...
...
@@ -104,23 +103,21 @@ for args in "--without-threads" ""; do
esac
esac
print_config
"valgrind tests: config=
$config
"
$args
print_config
"valgrind tests: config=
$config
"
printf
"
\n
building python ...
\n\n
"
$GMAKE
distclean
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--without-pymalloc
$args
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--without-pymalloc
>
/dev/null 2>&1
$GMAKE
|
grep
_decimal
printf
"
\n\n
# ======================== valgrind tests ===========================
\n\n
"
$valgrind
./python
-m
test
-uall
test_decimal
cd
Modules/_decimal
done
done
# deccheck
cd
../../
for
config
in
$CONFIGS
;
do
for
args
in
"--without-threads"
""
;
do
unset
PYTHON_DECIMAL_WITH_MACHINE
if
[
X
"
$config
"
!=
X
"auto"
]
;
then
...
...
@@ -129,22 +126,22 @@ for config in $CONFIGS; do
fi
############ debug ############
print_config
"deccheck: config=
$config
--with-pydebug"
$args
print_config
"deccheck: config=
$config
--with-pydebug"
printf
"
\n
building python ...
\n\n
"
$GMAKE
distclean
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--with-pydebug
$args
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--with-pydebug
>
/dev/null 2>&1
$GMAKE
|
grep
_decimal
printf
"
\n\n
# ========================== debug ===========================
\n\n
"
./python Modules/_decimal/tests/deccheck.py
########### regular ###########
print_config
"deccheck: config=
$config
"
$args
print_config
"deccheck: config=
$config
"
printf
"
\n
building python ...
\n\n
"
$GMAKE
distclean
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
$args
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
>
/dev/null 2>&1
$GMAKE
|
grep
_decimal
printf
"
\n\n
# ======================== regular ===========================
\n\n
"
...
...
@@ -160,16 +157,15 @@ for config in $CONFIGS; do
esac
esac
print_config
"valgrind deccheck: config=
$config
"
$args
print_config
"valgrind deccheck: config=
$config
"
printf
"
\n
building python ...
\n\n
"
$GMAKE
distclean
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--without-pymalloc
$args
>
/dev/null 2>&1
./configure
CFLAGS
=
"
$ADD_CFLAGS
"
LDFLAGS
=
"
$ADD_LDFLAGS
"
--without-pymalloc
>
/dev/null 2>&1
$GMAKE
|
grep
_decimal
printf
"
\n\n
# ======================== valgrind ==========================
\n\n
"
$valgrind
./python Modules/_decimal/tests/deccheck.py
done
done
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment