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
4920f701
Commit
4920f701
authored
Oct 24, 2017
by
sonots
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests/run/tss.pyx
parent
3c3829c5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
tests/run/tss.pyx
tests/run/tss.pyx
+51
-0
No files found.
tests/run/tss.pyx
0 → 100644
View file @
4920f701
# mode: run
from
cpython.pythread
cimport
*
def
tss_create_delete
():
"""
>>> tss_create_delete()
(True, False)
"""
cdef
Py_tss_t
tss_key
=
Py_tss_NEEDS_INIT
cdef
bint
after_create
,
after_delete
if
PyThread_tss_create
(
&
tss_key
)
>
0
:
# handle key creation failure
pass
after_create
=
PyThread_tss_is_created
(
&
tss_key
)
!=
0
PyThread_tss_delete
(
&
tss_key
)
after_delete
=
PyThread_tss_is_created
(
&
tss_key
)
!=
0
return
(
after_create
,
after_delete
)
def
tss_alloc_free
():
"""
>>> tss_alloc_free()
(True, False)
"""
cdef
Py_tss_t
*
ptr_key
cdef
bint
after_alloc
,
after_free
ptr_key
=
PyThread_tss_alloc
()
if
ptr_key
==
NULL
:
# handle key allocation failure
pass
after_alloc
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
PyThread_tss_free
(
ptr_key
)
after_free
=
PyThread_tss_is_created
(
ptr_key
)
!=
0
return
(
after_alloc
,
after_free
)
def
tss_set_get
():
"""
>>> tss_set_get()
1
"""
cdef
Py_tss_t
tss_key
=
Py_tss_NEEDS_INIT
cdef
int
the_value
=
1
cdef
int
ret_value
if
PyThread_tss_create
(
&
tss_key
)
>
0
:
# handle key creation failure
pass
if
PyThread_tss_get
(
&
tss_key
)
==
NULL
:
PyThread_tss_set
(
&
tss_key
,
<
void
*>&
the_value
)
ret_value
=
(
<
int
*>
PyThread_tss_get
(
&
tss_key
))[
0
]
PyThread_tss_delete
(
&
tss_key
)
return
ret_value
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