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
2dcd1d2d
Commit
2dcd1d2d
authored
7 years ago
by
Michael Schatzow
Committed by
Stefan Behnel
7 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BF: closes 1484 for unordered map
parent
2951e5d1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
14 deletions
+73
-14
Cython/Includes/libcpp/unordered_map.pxd
Cython/Includes/libcpp/unordered_map.pxd
+2
-2
runtests.py
runtests.py
+35
-12
tests/run/cpp_stl_cpp11.pyx
tests/run/cpp_stl_cpp11.pyx
+36
-0
No files found.
Cython/Includes/libcpp/unordered_map.pxd
View file @
2dcd1d2d
...
@@ -42,8 +42,8 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
...
@@ -42,8 +42,8 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
const_iterator
const_end
"end"
()
const_iterator
const_end
"end"
()
pair
[
iterator
,
iterator
]
equal_range
(
T
&
)
pair
[
iterator
,
iterator
]
equal_range
(
T
&
)
#pair[const_iterator, const_iterator] equal_range(key_type&)
#pair[const_iterator, const_iterator] equal_range(key_type&)
void
erase
(
iterator
)
iterator
erase
(
iterator
)
void
erase
(
iterator
,
iterator
)
iterator
erase
(
iterator
,
iterator
)
size_t
erase
(
T
&
)
size_t
erase
(
T
&
)
iterator
find
(
T
&
)
iterator
find
(
T
&
)
const_iterator
const_find
"find"
(
T
&
)
const_iterator
const_find
"find"
(
T
&
)
...
...
This diff is collapsed.
Click to expand it.
runtests.py
View file @
2dcd1d2d
...
@@ -71,7 +71,7 @@ CY3_DIR = None
...
@@ -71,7 +71,7 @@ CY3_DIR = None
from
distutils.command.build_ext
import
build_ext
as
_build_ext
from
distutils.command.build_ext
import
build_ext
as
_build_ext
from
distutils
import
sysconfig
from
distutils
import
sysconfig
from
distutils
import
ccompiler
_to_clean
=
[]
_to_clean
=
[]
@
atexit
.
register
@
atexit
.
register
...
@@ -240,7 +240,6 @@ def update_openmp_extension(ext):
...
@@ -240,7 +240,6 @@ def update_openmp_extension(ext):
if flags:
if flags:
compile_flags, link_flags = flags
compile_flags, link_flags = flags
ext.extra_compile_args.extend(compile_flags.split())
ext.extra_compile_args.extend(compile_flags.split())
ext.extra_link_args.extend(link_flags.split())
ext.extra_link_args.extend(link_flags.split())
return ext
return ext
...
@@ -249,21 +248,32 @@ def update_openmp_extension(ext):
...
@@ -249,21 +248,32 @@ def update_openmp_extension(ext):
return EXCLUDE_EXT
return EXCLUDE_EXT
def
get_openmp_compiler_flags(language
):
def
update_cpp11_extension(ext
):
"""
"""
As of gcc 4.2, it supports OpenMP 2.5. Gcc 4.4 implements 3.0. We don'
t
update cpp11 extensions that will run on versions of gcc >4.8
(
currently
)
check
for
other
compilers
.
"""
gcc_version = get_gcc_version(ext.language)
compiler_version = gcc_version.group(1)
if gcc_version is not None:
compiler_version = gcc_version.group(1)
if float(compiler_version) > 4.8:
ext.extra_compile_args.extend("-std=c++11")
return ext
return EXCLUDE_EXT
returns
a
two
-
tuple
of
(
CFLAGS
,
LDFLAGS
)
to
build
the
OpenMP
extension
def get_gcc_version(language):
"""
finds gcc version using Popen
"""
"""
if language == '
cpp
':
if language == '
cpp
':
cc = sysconfig.get_config_var('
CXX
')
cc = sysconfig.get_config_var('
CXX
')
else:
else:
cc = sysconfig.get_config_var('
CC
')
cc = sysconfig.get_config_var('
CC
')
if not cc:
cc = ccompiler.get_default_compiler()
if not cc:
if not cc:
if sys.platform == 'win32':
return '/openmp', ''
return None
return None
# For some reason, cc can be e.g. '
gcc
-
pthread
'
# For some reason, cc can be e.g. '
gcc
-
pthread
'
...
@@ -272,7 +282,6 @@ def get_openmp_compiler_flags(language):
...
@@ -272,7 +282,6 @@ def get_openmp_compiler_flags(language):
# Force english output
# Force english output
env = os.environ.copy()
env = os.environ.copy()
env['
LC_MESSAGES
'] = '
C
'
env['
LC_MESSAGES
'] = '
C
'
matcher = re.compile(r"gcc version (
\
d+
\
.
\
d+)
"
).search
matcher = re.compile(r"gcc version (
\
d+
\
.
\
d+)
"
).search
try:
try:
p = subprocess.Popen([cc, "-v"], stderr=subprocess.PIPE, env=env)
p = subprocess.Popen([cc, "-v"], stderr=subprocess.PIPE, env=env)
...
@@ -282,11 +291,24 @@ def get_openmp_compiler_flags(language):
...
@@ -282,11 +291,24 @@ def get_openmp_compiler_flags(language):
(language, os.strerror(sys.exc_info()[1].errno), cc))
(language, os.strerror(sys.exc_info()[1].errno), cc))
return None
return None
_, output = p.communicate()
_, output = p.communicate()
output = output.decode(locale.getpreferredencoding() or '
ASCII
', '
replace
')
output = output.decode(locale.getpreferredencoding() or '
ASCII
', '
replace
')
gcc_version = matcher(output)
gcc_version = matcher(output)
return gcc_version
def get_openmp_compiler_flags(language):
"""
As of gcc 4.2, it supports OpenMP 2.5. Gcc 4.4 implements 3.0. We don'
t
(
currently
)
check
for
other
compilers
.
returns
a
two
-
tuple
of
(
CFLAGS
,
LDFLAGS
)
to
build
the
OpenMP
extension
"""
gcc_version = get_gcc_version(language)
if not gcc_version:
if not gcc_version:
if sys.platform == 'win32':
return '/openmp', ''
else:
return None # not gcc - FIXME: do something about other compilers
return None # not gcc - FIXME: do something about other compilers
# gcc defines "__int128_t", assume that at least all 64 bit architectures have it
# gcc defines "__int128_t", assume that at least all 64 bit architectures have it
...
@@ -313,6 +335,7 @@ EXCLUDE_EXT = object()
...
@@ -313,6 +335,7 @@ EXCLUDE_EXT = object()
EXT_EXTRAS = {
EXT_EXTRAS = {
'tag:numpy' : update_numpy_extension,
'tag:numpy' : update_numpy_extension,
'tag:openmp': update_openmp_extension,
'tag:openmp': update_openmp_extension,
'tag:cpp11': update_cpp11_extension,
'tag:trace' : update_linetrace_extension,
'tag:trace' : update_linetrace_extension,
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/run/cpp_stl_cpp11.pyx
0 → 100644
View file @
2dcd1d2d
# mode: run
# tag: cpp, werror, cpp11
# distutils: extra_compile_args=-std=c++0x
import
sys
from
libcpp.unordered_map
cimport
unordered_map
from
libcpp.pair
cimport
pair
py_set
=
set
py_xrange
=
xrange
py_unicode
=
unicode
def
test_unordered_map_functionality
():
"""
>>> test_unordered_map_functionality()
'pass'
"""
cdef
:
unordered_map
[
int
,
int
]
int_map
=
unordered_map
[
int
,
int
]()
pair
[
int
,
int
]
pair_insert
=
pair
[
int
,
int
](
1
,
2
)
unordered_map
[
int
,
int
].
iterator
iterator
=
int_map
.
begin
()
pair
[
unordered_map
[
int
,
int
].
iterator
,
bint
]
pair_iter
=
int_map
.
insert
(
pair_insert
)
assert
int_map
[
1
]
==
2
assert
int_map
.
size
()
==
1
assert
int_map
.
erase
(
1
)
==
1
# returns number of elements erased
assert
int_map
.
size
()
==
0
int_map
[
1
]
=
2
assert
int_map
.
size
()
==
1
assert
int_map
[
1
]
==
2
iterator
=
int_map
.
find
(
1
)
assert
int_map
.
erase
(
iterator
)
==
int_map
.
end
()
return
"pass"
This diff is collapsed.
Click to expand it.
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