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
Gwenaël Samain
cython
Commits
c93a2314
Commit
c93a2314
authored
Oct 30, 2012
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More warning suppression, formatting.
parent
1d552268
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
13 deletions
+37
-13
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+30
-10
Cython/Utility/Overflow.c
Cython/Utility/Overflow.c
+7
-3
No files found.
Cython/Compiler/PyrexTypes.py
View file @
c93a2314
...
...
@@ -407,13 +407,19 @@ class CTypedefType(BaseType):
type
=
self
.
declaration_code
(
""
)
name
=
self
.
specialization_name
()
if
binop
==
"lshift"
:
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"LeftShift"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"LeftShift"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'SIGNED'
:
self
.
signed
}))
else
:
if
const_rhs
:
binop
+=
"_const"
_load_overflow_base
(
env
)
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"SizeCheck"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"Binop"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"SizeCheck"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"Binop"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
return
"__Pyx_%s_%s_checking_overflow"
%
(
binop
,
name
)
def
error_condition
(
self
,
result_code
):
...
...
@@ -1567,29 +1573,43 @@ class CIntType(CNumericType):
type
=
self
.
declaration_code
(
""
)
name
=
self
.
specialization_name
()
if
binop
==
"lshift"
:
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"LeftShift"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"LeftShift"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'SIGNED'
:
not
self
.
signed
}))
else
:
if
const_rhs
:
binop
+=
"_const"
if
type
in
(
'int'
,
'long'
,
'long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseSigned"
,
"Overflow.c"
,
context
=
{
'INT'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseSigned"
,
"Overflow.c"
,
context
=
{
'INT'
:
type
,
'NAME'
:
name
}))
elif
type
in
(
'unsigned int'
,
'unsigned long'
,
'unsigned long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseUnsigned"
,
"Overflow.c"
,
context
=
{
'UINT'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseUnsigned"
,
"Overflow.c"
,
context
=
{
'UINT'
:
type
,
'NAME'
:
name
}))
elif
self
.
rank
<=
1
:
# sizeof(short) < sizeof(int)
return
"__Pyx_%s_%s_no_overflow"
%
(
binop
,
name
)
else
:
_load_overflow_base
(
env
)
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"SizeCheck"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"Binop"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"SizeCheck"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"Binop"
,
"Overflow.c"
,
context
=
{
'TYPE'
:
type
,
'NAME'
:
name
,
'BINOP'
:
binop
}))
return
"__Pyx_%s_%s_checking_overflow"
%
(
binop
,
name
)
def
_load_overflow_base
(
env
):
env
.
use_utility_code
(
UtilityCode
.
load
(
"Common"
,
"Overflow.c"
))
for
type
in
(
'int'
,
'long'
,
'long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseSigned"
,
"Overflow.c"
,
context
=
{
'INT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseSigned"
,
"Overflow.c"
,
context
=
{
'INT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
for
type
in
(
'unsigned int'
,
'unsigned long'
,
'unsigned long long'
):
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseUnsigned"
,
"Overflow.c"
,
context
=
{
'UINT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
env
.
use_utility_code
(
TempitaUtilityCode
.
load
(
"BaseCaseUnsigned"
,
"Overflow.c"
,
context
=
{
'UINT'
:
type
,
'NAME'
:
type
.
replace
(
' '
,
'_'
)}))
class
CAnonEnumType
(
CIntType
):
...
...
Cython/Utility/Overflow.c
View file @
c93a2314
...
...
@@ -40,7 +40,7 @@ static int __Pyx_check_twos_complement() {
#define __Pyx_add_no_overflow(a, b, overflow) ((a) + (b))
#define __Pyx_add_const_no_overflow(a, b, overflow) ((a) + (b))
#define __Pyx_sub_no_overflow(a, b, overflow) ((a) - (b))
#define __Pyx_sub_
no_const
_overflow(a, b, overflow) ((a) - (b))
#define __Pyx_sub_
const_no
_overflow(a, b, overflow) ((a) - (b))
#define __Pyx_mul_no_overflow(a, b, overflow) ((a) * (b))
#define __Pyx_mul_const_no_overflow(a, b, overflow) ((a) * (b))
#define __Pyx_div_no_overflow(a, b, overflow) ((a) / (b))
...
...
@@ -231,7 +231,7 @@ static int __Pyx_check_sane_{{NAME}}() {
sizeof
({{
TYPE
}})
==
sizeof
(
long
long
))
{
return
0
;
}
else
{
PyErr_Format
(
PyExc_RuntimeError
,
"Bad size for int type %s: %d"
,
"{{TYPE}}"
,
sizeof
({{
TYPE
}}));
PyErr_Format
(
PyExc_RuntimeError
,
"Bad size for int type %s: %d"
,
"{{TYPE}}"
,
(
int
)
sizeof
({{
TYPE
}}));
return
1
;
}
}
...
...
@@ -272,7 +272,11 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}
/////////////// LeftShift.proto ///////////////
static
CYTHON_INLINE
{{
TYPE
}}
__Pyx_lshift_
{{
NAME
}}
_checking_overflow
({{
TYPE
}}
a
,
{{
TYPE
}}
b
,
int
*
overflow
)
{
*
overflow
|=
(
b
<
0
)
|
(
b
>
(
8
*
sizeof
({{
TYPE
}})))
|
(
a
>
(
__PYX_MAX
({{
TYPE
}})
>>
b
));
*
overflow
|=
#if {{SIGNED}}
(
b
<
0
)
|
#endif
(
b
>
(
8
*
sizeof
({{
TYPE
}})))
|
(
a
>
(
__PYX_MAX
({{
TYPE
}})
>>
b
));
return
a
<<
b
;
}
#define __Pyx_lshift_const_{{NAME}}_checking_overflow __Pyx_lshift_{{NAME}}_checking_overflow
...
...
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