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
42a187c5
Commit
42a187c5
authored
May 25, 2011
by
Dag Sverre Seljebotn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prange: Fix NaN-initialization for mismatching external typedefs
parent
c92189e7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
13 deletions
+30
-13
Cython/Compiler/PyrexTypes.py
Cython/Compiler/PyrexTypes.py
+10
-10
tests/run/sequential_parallel.pyx
tests/run/sequential_parallel.pyx
+14
-3
tests/run/types.h
tests/run/types.h
+6
-0
No files found.
Cython/Compiler/PyrexTypes.py
View file @
42a187c5
...
...
@@ -210,6 +210,9 @@ class CTypedefType(BaseType):
self
.
typedef_base_type
=
base_type
self
.
typedef_is_external
=
is_external
def
invalid_value
(
self
):
return
self
.
typedef_base_type
.
invalid_value
()
def
resolve
(
self
):
return
self
.
typedef_base_type
.
resolve
()
...
...
@@ -913,7 +916,13 @@ class CIntType(CNumericType):
return
src_type
.
is_int
or
src_type
.
is_enum
or
src_type
is
error_type
def
invalid_value
(
self
):
return
typename_to_maxval
[
rank_to_type_name
[
self
.
rank
]][
not
self
.
signed
]
if
rank_to_type_name
[
self
.
rank
]
==
'char'
:
return
"'?'"
else
:
# We do not really know the size of the type, so return
# a 32-bit literal and rely on casting to final type. It will
# be negative for signed ints, which is good.
return
"0xbad0bad0"
;
class
CAnonEnumType
(
CIntType
):
...
...
@@ -2369,15 +2378,6 @@ rank_to_type_name = (
"long double"
,
# 7
)
typename_to_maxval
=
{
"char"
:
(
"'?'"
,
"'?'"
),
"short"
:
(
"0xbad"
,
"0xbad0"
),
"int"
:
(
"0xbad"
,
"0xbad0"
),
"long"
:
(
"0xbad0bad"
,
"0xbad0bad0"
),
"PY_LONG_LONG"
:
(
"0xbad0bad0bad0bad"
,
"0xbad0bad0bad0bad0"
),
# CFloatType overrides invalid_value
}
RANK_INT
=
list
(
rank_to_type_name
).
index
(
'int'
)
RANK_LONG
=
list
(
rank_to_type_name
).
index
(
'long'
)
UNSIGNED
=
0
...
...
tests/run/sequential_parallel.pyx
View file @
42a187c5
...
...
@@ -174,6 +174,12 @@ def test_pure_mode():
with
pure_parallel
.
parallel
():
print
pure_parallel
.
threadid
()
cdef
extern
from
"types.h"
:
ctypedef
short
actually_long_t
ctypedef
long
actually_short_t
ctypedef
int
myint_t
def
test_nan_init
():
"""
>>> test_nan_init()
...
...
@@ -192,6 +198,10 @@ def test_nan_init():
cdef
unsigned
long
d2
=
10
cdef
long
long
e1
=
10
cdef
unsigned
long
long
e2
=
10
cdef
actually_long_t
miss1
=
10
cdef
actually_short_t
miss2
=
10
cdef
myint_t
typedef1
=
10
cdef
float
f
=
10.0
cdef
double
g
=
10.0
...
...
@@ -207,6 +217,7 @@ def test_nan_init():
a1
=
a2
=
b1
=
b2
=
c1
=
c2
=
d1
=
d2
=
e1
=
e2
=
0
f
=
g
=
h
=
0.0
p
=
NULL
miss1
=
miss2
=
typedef1
=
0
if
(
a1
==
10
or
a2
==
10
or
b1
==
10
or
b2
==
10
or
...
...
@@ -214,10 +225,10 @@ def test_nan_init():
d1
==
10
or
d2
==
10
or
e1
==
10
or
e2
==
10
or
f
==
10.0
or
g
==
10.0
or
h
==
10.0
or
p
==
<
void
*>
10
):
p
==
<
void
*>
10
or
miss1
==
10
or
miss2
==
10
or
typedef1
==
10
):
errp
[
0
]
=
1
if
err
:
raise
Exception
(
"One of the values was not initiazed to a maximum "
raise
Exception
(
"One of the values was not initia
li
zed to a maximum "
"or NaN value"
)
tests/run/types.h
0 → 100644
View file @
42a187c5
/*
This header is present to test effects of misdeclaring
types Cython-side.
*/
typedef
long
actually_long_t
;
typedef
short
actually_short_t
;
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