diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2016-01-22 13:09:55 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2016-01-22 13:09:55 (GMT) |
commit | b02ef715a303ab09a39ef994d8f5acc4eb572376 (patch) | |
tree | da38e1ff9c638c0dec0bb682bc18b5b6b2d93d93 /Python/ceval_gil.h | |
parent | efb2413ce82acaa5dec43a8cb14aa7cdf2352fb1 (diff) | |
download | cpython-b02ef715a303ab09a39ef994d8f5acc4eb572376.zip cpython-b02ef715a303ab09a39ef994d8f5acc4eb572376.tar.gz cpython-b02ef715a303ab09a39ef994d8f5acc4eb572376.tar.bz2 |
Use Py_uintptr_t for atomic pointers
Issue #26161: Use Py_uintptr_t instead of void* for atomic pointers in
pyatomic.h. Use atomic_uintptr_t when <stdatomic.h> is used.
Using void* causes compilation warnings depending on which implementation of
atomic types is used.
Diffstat (limited to 'Python/ceval_gil.h')
-rw-r--r-- | Python/ceval_gil.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Python/ceval_gil.h b/Python/ceval_gil.h index aafcbc2..8d38ee9 100644 --- a/Python/ceval_gil.h +++ b/Python/ceval_gil.h @@ -111,7 +111,7 @@ static _Py_atomic_int gil_locked = {-1}; static unsigned long gil_switch_number = 0; /* Last PyThreadState holding / having held the GIL. This helps us know whether anyone else was scheduled after we dropped the GIL. */ -static _Py_atomic_address gil_last_holder = {NULL}; +static _Py_atomic_address gil_last_holder = {0}; /* This condition variable allows one or several threads to wait until the GIL is released. In addition, the mutex also protects the above @@ -142,7 +142,7 @@ static void create_gil(void) #ifdef FORCE_SWITCHING COND_INIT(switch_cond); #endif - _Py_atomic_store_relaxed(&gil_last_holder, NULL); + _Py_atomic_store_relaxed(&gil_last_holder, 0); _Py_ANNOTATE_RWLOCK_CREATE(&gil_locked); _Py_atomic_store_explicit(&gil_locked, 0, _Py_memory_order_release); } @@ -178,7 +178,7 @@ static void drop_gil(PyThreadState *tstate) /* Sub-interpreter support: threads might have been switched under our feet using PyThreadState_Swap(). Fix the GIL last holder variable so that our heuristics work. */ - _Py_atomic_store_relaxed(&gil_last_holder, tstate); + _Py_atomic_store_relaxed(&gil_last_holder, (Py_uintptr_t)tstate); } MUTEX_LOCK(gil_mutex); @@ -240,7 +240,7 @@ _ready: _Py_ANNOTATE_RWLOCK_ACQUIRED(&gil_locked, /*is_write=*/1); if (tstate != (PyThreadState*)_Py_atomic_load_relaxed(&gil_last_holder)) { - _Py_atomic_store_relaxed(&gil_last_holder, tstate); + _Py_atomic_store_relaxed(&gil_last_holder, (Py_uintptr_t)tstate); ++gil_switch_number; } |