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
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
cython
Commits
5a845c3e
Commit
5a845c3e
authored
Mar 23, 2012
by
Mark Florisson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move undef/redef (un)likely to CCodeWriter
parent
b947c556
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
12 deletions
+22
-12
Cython/Compiler/Code.py
Cython/Compiler/Code.py
+20
-0
Cython/Compiler/Nodes.py
Cython/Compiler/Nodes.py
+2
-12
No files found.
Cython/Compiler/Code.py
View file @
5a845c3e
...
...
@@ -1903,6 +1903,26 @@ class CCodeWriter(object):
self
.
putln
(
string
)
self
.
putln
(
"#endif /* _OPENMP */"
)
def
undef_builtin_expect
(
self
,
cond
):
"""
Redefine the macros likely() and unlikely to no-ops, depending on
condition 'cond'
"""
self
.
putln
(
"#if %s"
%
cond
)
self
.
putln
(
" #undef likely"
)
self
.
putln
(
" #undef unlikely"
)
self
.
putln
(
" #define likely(x) (x)"
)
self
.
putln
(
" #define unlikely(x) (x)"
)
self
.
putln
(
"#endif"
)
def
redef_builtin_expect
(
self
,
cond
):
self
.
putln
(
"#if %s"
%
cond
)
self
.
putln
(
" #undef likely"
)
self
.
putln
(
" #undef unlikely"
)
self
.
putln
(
" #define likely(x) __builtin_expect(!!(x), 1)"
)
self
.
putln
(
" #define unlikely(x) __builtin_expect(!!(x), 0)"
)
self
.
putln
(
"#endif"
)
class
PyrexCodeWriter
(
object
):
# f file output file
# level int indentation level
...
...
Cython/Compiler/Nodes.py
View file @
5a845c3e
...
...
@@ -7737,21 +7737,11 @@ class ParallelStatNode(StatNode, ParallelNode):
A bug on OS X Lion disallows __builtin_expect macros. This code avoids them
"""
if
not
self
.
parent
:
code
.
putln
(
"#if %s"
%
self
.
redef_condition
)
code
.
putln
(
" #undef likely"
)
code
.
putln
(
" #undef unlikely"
)
code
.
putln
(
" #define likely(x) (x)"
)
code
.
putln
(
" #define unlikely(x) (x)"
)
code
.
putln
(
"#endif"
)
code
.
undef_builtin_expect
(
self
.
redef_condition
)
def
redef_builtin_expect_apple_gcc_bug
(
self
,
code
):
if
not
self
.
parent
:
code
.
putln
(
"#if %s"
%
self
.
redef_condition
)
code
.
putln
(
" #undef likely"
)
code
.
putln
(
" #undef unlikely"
)
code
.
putln
(
" #define likely(x) __builtin_expect(!!(x), 1)"
)
code
.
putln
(
" #define unlikely(x) __builtin_expect(!!(x), 0)"
)
code
.
putln
(
"#endif"
)
code
.
redef_builtin_expect
(
self
.
redef_condition
)
class
ParallelWithBlockNode
(
ParallelStatNode
):
...
...
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