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
34b81d54
Commit
34b81d54
authored
Feb 10, 2018
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use inline function instead of macro to make sure "&arg" is always a valid lvalue.
Closes #2097.
parent
b36e1104
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
10 deletions
+36
-10
Cython/Utility/ObjectHandling.c
Cython/Utility/ObjectHandling.c
+23
-10
tests/run/fastcall.pyx
tests/run/fastcall.pyx
+13
-0
No files found.
Cython/Utility/ObjectHandling.c
View file @
34b81d54
...
@@ -1445,18 +1445,10 @@ bad:
...
@@ -1445,18 +1445,10 @@ bad:
/////////////// CallUnboundCMethod1.proto ///////////////
/////////////// CallUnboundCMethod1.proto ///////////////
static
PyObject
*
__Pyx__CallUnboundCMethod1
(
__Pyx_CachedCFunction
*
cfunc
,
PyObject
*
self
,
PyObject
*
arg
);
/*proto*/
static
PyObject
*
__Pyx__CallUnboundCMethod1
(
__Pyx_CachedCFunction
*
cfunc
,
PyObject
*
self
,
PyObject
*
arg
);
/*proto*/
#if CYTHON_COMPILING_IN_CPYTHON
#if CYTHON_COMPILING_IN_CPYTHON
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) \
static
CYTHON_INLINE
PyObject
*
__Pyx_CallUnboundCMethod1
(
__Pyx_CachedCFunction
*
cfunc
,
PyObject
*
self
,
PyObject
*
arg
);
/*proto*/
((likely((cfunc)->func && (cfunc)->flag == METH_O)) ? (*((cfunc)->func))(self, arg) : \
((PY_VERSION_HEX >= 0x030600B1 && (cfunc)->func && (cfunc)->flag == METH_FASTCALL) ? \
(PY_VERSION_HEX >= 0x030700A0 ? \
(*(__Pyx_PyCFunctionFast)(cfunc)->func)(self, &arg, 1) : \
(*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &arg, 1, NULL)) : \
(PY_VERSION_HEX >= 0x030700A0 && (cfunc)->func && (cfunc)->flag == (METH_FASTCALL | METH_KEYWORDS) ? \
(*(__Pyx_PyCFunctionFastWithKeywords)(cfunc)->func)(self, &arg, 1, NULL) : \
__Pyx__CallUnboundCMethod1(cfunc, self, arg))))
#else
#else
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#define __Pyx_CallUnboundCMethod1(cfunc, self, arg) __Pyx__CallUnboundCMethod1(cfunc, self, arg)
#endif
#endif
...
@@ -1465,6 +1457,27 @@ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObje
...
@@ -1465,6 +1457,27 @@ static PyObject* __Pyx__CallUnboundCMethod1(__Pyx_CachedCFunction* cfunc, PyObje
//@requires: UnpackUnboundCMethod
//@requires: UnpackUnboundCMethod
//@requires: PyObjectCall
//@requires: PyObjectCall
#if CYTHON_COMPILING_IN_CPYTHON
static
CYTHON_INLINE
PyObject
*
__Pyx_CallUnboundCMethod1
(
__Pyx_CachedCFunction
*
cfunc
,
PyObject
*
self
,
PyObject
*
arg
)
{
if
(
likely
(
cfunc
->
func
))
{
int
flag
=
cfunc
->
flag
;
// Not using #ifdefs for PY_VERSION_HEX to avoid C compiler warnings about unused functions.
if
(
flag
==
METH_O
)
{
return
(
*
(
cfunc
->
func
))(
self
,
arg
);
}
else
if
(
PY_VERSION_HEX
>=
0x030600B1
&&
flag
==
METH_FASTCALL
)
{
if
(
PY_VERSION_HEX
>=
0x030700A0
)
{
return
(
*
(
__Pyx_PyCFunctionFast
)
cfunc
->
func
)(
self
,
&
arg
,
1
);
}
else
{
return
(
*
(
__Pyx_PyCFunctionFastWithKeywords
)
cfunc
->
func
)(
self
,
&
arg
,
1
,
NULL
);
}
}
else
if
(
PY_VERSION_HEX
>=
0x030700A0
&&
flag
==
(
METH_FASTCALL
|
METH_KEYWORDS
))
{
return
(
*
(
__Pyx_PyCFunctionFastWithKeywords
)
cfunc
->
func
)(
self
,
&
arg
,
1
,
NULL
);
}
}
return
__Pyx__CallUnboundCMethod1
(
cfunc
,
self
,
arg
);
}
#endif
static
PyObject
*
__Pyx__CallUnboundCMethod1
(
__Pyx_CachedCFunction
*
cfunc
,
PyObject
*
self
,
PyObject
*
arg
){
static
PyObject
*
__Pyx__CallUnboundCMethod1
(
__Pyx_CachedCFunction
*
cfunc
,
PyObject
*
self
,
PyObject
*
arg
){
PyObject
*
args
,
*
result
=
NULL
;
PyObject
*
args
,
*
result
=
NULL
;
if
(
unlikely
(
!
cfunc
->
func
&&
!
cfunc
->
method
)
&&
unlikely
(
__Pyx_TryUnpackUnboundCMethod
(
cfunc
)
<
0
))
return
NULL
;
if
(
unlikely
(
!
cfunc
->
func
&&
!
cfunc
->
method
)
&&
unlikely
(
__Pyx_TryUnpackUnboundCMethod
(
cfunc
)
<
0
))
return
NULL
;
...
...
tests/run/fastcall.pyx
View file @
34b81d54
...
@@ -50,3 +50,16 @@ def struct_methods(v):
...
@@ -50,3 +50,16 @@ def struct_methods(v):
pack
(
'i'
,
v
),
pack
(
'i'
,
v
),
local_pack
(
'f'
,
v
),
local_pack
(
'f'
,
v
),
]
]
cdef
class
SelfCast
:
"""
>>> f = SelfCast()
>>> f.index_of_self([f])
0
>>> f.index_of_self([]) # doctest: +ELLIPSIS
Traceback (most recent call last):
ValueError...
"""
def
index_of_self
(
self
,
list
orbit
not
None
):
return
orbit
.
index
(
self
)
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