Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
cython
Commits
2985e5d0
Commit
2985e5d0
authored
Mar 16, 2012
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move 'init threads' utility code to ModuleSetupCode.c file
parent
d18be9ae
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
22 deletions
+21
-22
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+4
-6
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-14
Cython/Compiler/ParseTreeTransforms.py
Cython/Compiler/ParseTreeTransforms.py
+5
-2
Cython/Utility/ModuleSetupCode.c
Cython/Utility/ModuleSetupCode.c
+10
-0
No files found.
Cython/Compiler/Code.py
View file @
2985e5d0
...
...
@@ -1748,10 +1748,8 @@ class CCodeWriter(object):
using the Python API). Additionally, the code generated by this method
may be called recursively.
"""
from
Cython.Compiler
import
Nodes
self
.
globalstate
.
use_utility_code
(
Nodes
.
force_init_threads_utility_code
)
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"ForceInitThreads"
,
"ModuleSetupCode.c"
))
self
.
putln
(
"#ifdef WITH_THREAD"
)
if
declare_gilstate
:
self
.
put
(
"PyGILState_STATE "
)
...
...
@@ -1854,8 +1852,8 @@ class CCodeWriter(object):
def
put_setup_refcount_context
(
self
,
name
,
acquire_gil
=
False
):
if
acquire_gil
:
from
Cython.Compiler
import
Nodes
self
.
globalstate
.
use_utility_code
(
Nodes
.
force_init_threads_utility_code
)
self
.
globalstate
.
use_utility_code
(
UtilityCode
.
load_cached
(
"ForceInitThreads"
,
"ModuleSetupCode.c"
)
)
self
.
putln
(
'__Pyx_RefNannySetupContext("%s", %d);'
%
(
name
,
acquire_gil
and
1
or
0
))
def
put_finish_refcount_context
(
self
):
...
...
Cython/Compiler/Nodes.py
View file @
2985e5d0
...
...
@@ -6778,7 +6778,8 @@ class GILStatNode(NogilTryFinallyStatNode):
return
super
(
GILStatNode
,
self
).
analyse_declarations
(
env
)
def
analyse_expressions
(
self
,
env
):
env
.
use_utility_code
(
force_init_threads_utility_code
)
env
.
use_utility_code
(
UtilityCode
.
load_cached
(
"ForceInitThreads"
,
"ModuleSetupCode.c"
))
was_nogil
=
env
.
nogil
env
.
nogil
=
self
.
state
==
'nogil'
TryFinallyStatNode
.
analyse_expressions
(
self
,
env
)
...
...
@@ -9023,19 +9024,6 @@ static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
#------------------------------------------------------------------------------------
force_init_threads_utility_code
=
UtilityCode
(
proto
=
"""
#ifndef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 0
#endif
"""
)
init_threads
=
UtilityCode
(
init
=
"PyEval_InitThreads();
\
n
"
,
)
#------------------------------------------------------------------------------------
# Note that cPython ignores PyTrace_EXCEPTION,
# but maybe some other profilers don't.
...
...
Cython/Compiler/ParseTreeTransforms.py
View file @
2985e5d0
...
...
@@ -17,6 +17,7 @@ from Cython.Compiler.UtilNodes import LetNode, LetRefNode, ResultRefNode
from
Cython.Compiler.TreeFragment
import
TreeFragment
from
Cython.Compiler.StringEncoding
import
EncodedString
from
Cython.Compiler.Errors
import
error
,
warning
,
CompileError
,
InternalError
from
Cython.Compiler.Code
import
UtilityCode
import
copy
...
...
@@ -705,7 +706,8 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
directive
[
-
1
]
not
in
self
.
valid_parallel_directives
):
error
(
pos
,
"No such directive: %s"
%
full_name
)
self
.
module_scope
.
use_utility_code
(
Nodes
.
init_threads
)
self
.
module_scope
.
use_utility_code
(
UtilityCode
.
load_cached
(
"InitThreads"
,
"ModuleSetupCode.c"
))
return
result
...
...
@@ -722,7 +724,8 @@ class InterpretCompilerDirectives(CythonTransform, SkipDeclarations):
self
.
cython_module_names
.
add
(
u"cython"
)
self
.
parallel_directives
[
u"cython.parallel"
]
=
node
.
module_name
self
.
module_scope
.
use_utility_code
(
Nodes
.
init_threads
)
self
.
module_scope
.
use_utility_code
(
UtilityCode
.
load_cached
(
"InitThreads"
,
"ModuleSetupCode.c"
))
elif
node
.
as_name
:
self
.
directive_names
[
node
.
as_name
]
=
node
.
module_name
[
7
:]
else
:
...
...
Cython/Utility/ModuleSetupCode.c
View file @
2985e5d0
...
...
@@ -222,6 +222,16 @@
#define __Pyx_DOCSTR(n) (n)
#endif
/////////////// ForceInitThreads.proto ///////////////
#ifndef __PYX_FORCE_INIT_THREADS
#define __PYX_FORCE_INIT_THREADS 0
#endif
/////////////// InitThreads.init ///////////////
PyEval_InitThreads
();
/////////////// CodeObjectCache.proto ///////////////
typedef
struct
{
...
...
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