Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
2a78abff
Unverified
Commit
2a78abff
authored
Sep 23, 2021
by
Jeremy Maitin-Shepard
Committed by
GitHub
Sep 23, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure PYBIND11_TLS_REPLACE_VALUE evaluates its arguments only once (#3290)
parent
5f46e47d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
include/pybind11/detail/internals.h
+5
-4
No files found.
include/pybind11/detail/internals.h
View file @
2a78abff
...
@@ -84,12 +84,13 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
...
@@ -84,12 +84,13 @@ inline PyObject *make_object_base_type(PyTypeObject *metaclass);
// On CPython < 3.4 and on PyPy, `PyThread_set_key_value` strangely does not set
// On CPython < 3.4 and on PyPy, `PyThread_set_key_value` strangely does not set
// the value if it has already been set. Instead, it must first be deleted and
// the value if it has already been set. Instead, it must first be deleted and
// then set again.
// then set again.
inline
void
tls_replace_value
(
PYBIND11_TLS_KEY_REF
key
,
void
*
value
)
{
PyThread_delete_key_value
(
key
);
PyThread_set_key_value
(
key
,
value
);
}
# define PYBIND11_TLS_DELETE_VALUE(key) PyThread_delete_key_value(key)
# define PYBIND11_TLS_DELETE_VALUE(key) PyThread_delete_key_value(key)
# define PYBIND11_TLS_REPLACE_VALUE(key, value) \
# define PYBIND11_TLS_REPLACE_VALUE(key, value) \
do { \
::pybind11::detail::tls_replace_value((key), (value))
PyThread_delete_key_value((key)); \
PyThread_set_key_value((key), (value)); \
} while (false)
# else
# else
# define PYBIND11_TLS_DELETE_VALUE(key) PyThread_set_key_value((key), nullptr)
# define PYBIND11_TLS_DELETE_VALUE(key) PyThread_set_key_value((key), nullptr)
# define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_set_key_value((key), (value))
# define PYBIND11_TLS_REPLACE_VALUE(key, value) PyThread_set_key_value((key), (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