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
3e5baefe
Commit
3e5baefe
authored
Mar 20, 2015
by
Stefan Behnel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
safely handle SIGFPE in optimised float adding code
parent
08474c9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
Cython/Utility/Optimize.c
Cython/Utility/Optimize.c
+11
-3
No files found.
Cython/Utility/Optimize.c
View file @
3e5baefe
...
@@ -524,8 +524,12 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, long
...
@@ -524,8 +524,12 @@ static PyObject* __Pyx_PyInt_{{op}}{{order}}(PyObject *op1, PyObject *op2, long
#endif
#endif
if
(
PyFloat_CheckExact
({{
pyval
}}))
{
if
(
PyFloat_CheckExact
({{
pyval
}}))
{
double
result
;
double
{{
ival
}}
=
PyFloat_AS_DOUBLE
({{
pyval
}});
double
{{
ival
}}
=
PyFloat_AS_DOUBLE
({{
pyval
}});
return
PyFloat_FromDouble
(((
double
)
a
)
{{
'+'
if
op
==
'
Add
'
else
'-'
}}
(
double
)
b
);
PyFPE_START_PROTECT
(
"{{op.lower()}}"
,
return
NULL
)
result
=
((
double
)
a
)
{{
'+'
if
op
==
'
Add
'
else
'-'
}}
(
double
)
b
;
PyFPE_END_PROTECT
(
result
)
return
PyFloat_FromDouble
(
result
);
}
}
return
(
inplace
?
PyNumber_InPlace
{{
op
}}
:
PyNumber_
{{
op
}})(
op1
,
op2
);
return
(
inplace
?
PyNumber_InPlace
{{
op
}}
:
PyNumber_
{{
op
}})(
op1
,
op2
);
}
}
...
@@ -548,7 +552,7 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou
...
@@ -548,7 +552,7 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou
static
PyObject
*
__Pyx_PyFloat_
{{
op
}}{{
order
}}(
PyObject
*
op1
,
PyObject
*
op2
,
double
floatval
,
int
inplace
)
{
static
PyObject
*
__Pyx_PyFloat_
{{
op
}}{{
order
}}(
PyObject
*
op1
,
PyObject
*
op2
,
double
floatval
,
int
inplace
)
{
const
double
{{
'a'
if
order
==
'
CObj
'
else
'b'
}}
=
floatval
;
const
double
{{
'a'
if
order
==
'
CObj
'
else
'b'
}}
=
floatval
;
double
{{
fval
}};
double
result
,
{{
fval
}};
if
(
likely
(
PyFloat_CheckExact
({{
pyval
}})))
{
if
(
likely
(
PyFloat_CheckExact
({{
pyval
}})))
{
{{
fval
}}
=
PyFloat_AS_DOUBLE
({{
pyval
}});
{{
fval
}}
=
PyFloat_AS_DOUBLE
({{
pyval
}});
...
@@ -576,6 +580,10 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou
...
@@ -576,6 +580,10 @@ static PyObject* __Pyx_PyFloat_{{op}}{{order}}(PyObject *op1, PyObject *op2, dou
#endif
#endif
}
else
}
else
return
(
inplace
?
PyNumber_InPlace
{{
op
}}
:
PyNumber_
{{
op
}})(
op1
,
op2
);
return
(
inplace
?
PyNumber_InPlace
{{
op
}}
:
PyNumber_
{{
op
}})(
op1
,
op2
);
return
PyFloat_FromDouble
(
a
{{
'+'
if
op
==
'
Add
'
else
'-'
}}
b
);
PyFPE_START_PROTECT
(
"{{op.lower()}}"
,
return
NULL
)
result
=
a
{{
'+'
if
op
==
'
Add
'
else
'-'
}}
b
;
PyFPE_END_PROTECT
(
result
)
return
PyFloat_FromDouble
(
result
);
}
}
#endif
#endif
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