Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
26449079
Unverified
Kaydet (Commit)
26449079
authored
Nis 22, 2019
tarafından
Steve Dower
Kaydeden (comit)
GitHub
Nis 22, 2019
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-33608: Normalize atomic macros so that they all expect an atomic struct (GH-12877)
üst
34366b7f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
24 deletions
+36
-24
pycore_atomic.h
Include/internal/pycore_atomic.h
+36
-24
No files found.
Include/internal/pycore_atomic.h
Dosyayı görüntüle @
26449079
...
@@ -261,13 +261,13 @@ typedef struct _Py_atomic_int {
...
@@ -261,13 +261,13 @@ typedef struct _Py_atomic_int {
#define _Py_atomic_store_64bit(ATOMIC_VAL, NEW_VAL, ORDER) \
#define _Py_atomic_store_64bit(ATOMIC_VAL, NEW_VAL, ORDER) \
switch (ORDER) { \
switch (ORDER) { \
case _Py_memory_order_acquire: \
case _Py_memory_order_acquire: \
_InterlockedExchange64_HLEAcquire((__int64 volatile*)
ATOMIC_VAL, (__int64)NEW_VAL
); \
_InterlockedExchange64_HLEAcquire((__int64 volatile*)
&((ATOMIC_VAL)->_value), (__int64)(NEW_VAL)
); \
break; \
break; \
case _Py_memory_order_release: \
case _Py_memory_order_release: \
_InterlockedExchange64_HLERelease((__int64 volatile*)
ATOMIC_VAL, (__int64)NEW_VAL
); \
_InterlockedExchange64_HLERelease((__int64 volatile*)
&((ATOMIC_VAL)->_value), (__int64)(NEW_VAL)
); \
break; \
break; \
default: \
default: \
_InterlockedExchange64((__int64 volatile*)
ATOMIC_VAL, (__int64)NEW_VAL
); \
_InterlockedExchange64((__int64 volatile*)
&((ATOMIC_VAL)->_value), (__int64)(NEW_VAL)
); \
break; \
break; \
}
}
#else
#else
...
@@ -277,13 +277,13 @@ typedef struct _Py_atomic_int {
...
@@ -277,13 +277,13 @@ typedef struct _Py_atomic_int {
#define _Py_atomic_store_32bit(ATOMIC_VAL, NEW_VAL, ORDER) \
#define _Py_atomic_store_32bit(ATOMIC_VAL, NEW_VAL, ORDER) \
switch (ORDER) { \
switch (ORDER) { \
case _Py_memory_order_acquire: \
case _Py_memory_order_acquire: \
_InterlockedExchange_HLEAcquire((volatile long*)
ATOMIC_VAL, (int)NEW_VAL
); \
_InterlockedExchange_HLEAcquire((volatile long*)
&((ATOMIC_VAL)->_value), (int)(NEW_VAL)
); \
break; \
break; \
case _Py_memory_order_release: \
case _Py_memory_order_release: \
_InterlockedExchange_HLERelease((volatile long*)
ATOMIC_VAL, (int)NEW_VAL
); \
_InterlockedExchange_HLERelease((volatile long*)
&((ATOMIC_VAL)->_value), (int)(NEW_VAL)
); \
break; \
break; \
default: \
default: \
_InterlockedExchange((volatile long*)
ATOMIC_VAL, (int)NEW_VAL
); \
_InterlockedExchange((volatile long*)
&((ATOMIC_VAL)->_value), (int)(NEW_VAL)
); \
break; \
break; \
}
}
...
@@ -292,7 +292,7 @@ typedef struct _Py_atomic_int {
...
@@ -292,7 +292,7 @@ typedef struct _Py_atomic_int {
gil_created() uses -1 as a sentinel value, if this returns
gil_created() uses -1 as a sentinel value, if this returns
a uintptr_t it will do an unsigned compare and crash
a uintptr_t it will do an unsigned compare and crash
*/
*/
inline
intptr_t
_Py_atomic_load_64bit
(
volatile
uintptr_t
*
value
,
int
order
)
{
inline
intptr_t
_Py_atomic_load_64bit
_impl
(
volatile
uintptr_t
*
value
,
int
order
)
{
__int64
old
;
__int64
old
;
switch
(
order
)
{
switch
(
order
)
{
case
_Py_memory_order_acquire
:
case
_Py_memory_order_acquire
:
...
@@ -323,11 +323,14 @@ inline intptr_t _Py_atomic_load_64bit(volatile uintptr_t* value, int order) {
...
@@ -323,11 +323,14 @@ inline intptr_t _Py_atomic_load_64bit(volatile uintptr_t* value, int order) {
return
old
;
return
old
;
}
}
#define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER) \
_Py_atomic_load_64bit_impl((volatile uintptr_t*)&((ATOMIC_VAL)->_value), (ORDER))
#else
#else
#define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER)
*(ATOMIC_VAL
)
#define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER)
((ATOMIC_VAL)->_value
)
#endif
#endif
inline
int
_Py_atomic_load_32bit
(
volatile
int
*
value
,
int
order
)
{
inline
int
_Py_atomic_load_32bit
_impl
(
volatile
int
*
value
,
int
order
)
{
long
old
;
long
old
;
switch
(
order
)
{
switch
(
order
)
{
case
_Py_memory_order_acquire
:
case
_Py_memory_order_acquire
:
...
@@ -358,16 +361,19 @@ inline int _Py_atomic_load_32bit(volatile int* value, int order) {
...
@@ -358,16 +361,19 @@ inline int _Py_atomic_load_32bit(volatile int* value, int order) {
return
old
;
return
old
;
}
}
#define _Py_atomic_load_32bit(ATOMIC_VAL, ORDER) \
_Py_atomic_load_32bit_impl((volatile int*)&((ATOMIC_VAL)->_value), (ORDER))
#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
if (sizeof((ATOMIC_VAL)->_value) == 8) { \
if (sizeof((ATOMIC_VAL)->_value) == 8) { \
_Py_atomic_store_64bit((
volatile long long*)&((ATOMIC_VAL)->_value
), NEW_VAL, ORDER) } else { \
_Py_atomic_store_64bit((
ATOMIC_VAL
), NEW_VAL, ORDER) } else { \
_Py_atomic_store_32bit((
volatile long*)&((ATOMIC_VAL)->_value
), NEW_VAL, ORDER) }
_Py_atomic_store_32bit((
ATOMIC_VAL
), NEW_VAL, ORDER) }
#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
( \
( \
sizeof((ATOMIC_VAL)->_value) == 8 ? \
sizeof((ATOMIC_VAL)->_value) == 8 ? \
_Py_atomic_load_64bit((
volatile long long*)&((ATOMIC_VAL)->_value
), ORDER) : \
_Py_atomic_load_64bit((
ATOMIC_VAL
), ORDER) : \
_Py_atomic_load_32bit((
volatile long*)&((ATOMIC_VAL)->_value
), ORDER) \
_Py_atomic_load_32bit((
ATOMIC_VAL
), ORDER) \
)
)
#elif defined(_M_ARM) || defined(_M_ARM64)
#elif defined(_M_ARM) || defined(_M_ARM64)
typedef
enum
_Py_memory_order
{
typedef
enum
_Py_memory_order
{
...
@@ -422,7 +428,7 @@ typedef struct _Py_atomic_int {
...
@@ -422,7 +428,7 @@ typedef struct _Py_atomic_int {
gil_created() uses -1 as a sentinel value, if this returns
gil_created() uses -1 as a sentinel value, if this returns
a uintptr_t it will do an unsigned compare and crash
a uintptr_t it will do an unsigned compare and crash
*/
*/
inline
intptr_t
_Py_atomic_load_64bit
(
volatile
uintptr_t
*
value
,
int
order
)
{
inline
intptr_t
_Py_atomic_load_64bit
_impl
(
volatile
uintptr_t
*
value
,
int
order
)
{
uintptr_t
old
;
uintptr_t
old
;
switch
(
order
)
{
switch
(
order
)
{
case
_Py_memory_order_acquire
:
case
_Py_memory_order_acquire
:
...
@@ -453,11 +459,14 @@ inline intptr_t _Py_atomic_load_64bit(volatile uintptr_t* value, int order) {
...
@@ -453,11 +459,14 @@ inline intptr_t _Py_atomic_load_64bit(volatile uintptr_t* value, int order) {
return
old
;
return
old
;
}
}
#define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER) \
_Py_atomic_load_64bit_impl((volatile uintptr_t*)&((ATOMIC_VAL)->_value), (ORDER))
#else
#else
#define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER)
*(ATOMIC_VAL
)
#define _Py_atomic_load_64bit(ATOMIC_VAL, ORDER)
((ATOMIC_VAL)->_value
)
#endif
#endif
inline
int
_Py_atomic_load_32bit
(
volatile
int
*
value
,
int
order
)
{
inline
int
_Py_atomic_load_32bit
_impl
(
volatile
int
*
value
,
int
order
)
{
int
old
;
int
old
;
switch
(
order
)
{
switch
(
order
)
{
case
_Py_memory_order_acquire
:
case
_Py_memory_order_acquire
:
...
@@ -488,16 +497,19 @@ inline int _Py_atomic_load_32bit(volatile int* value, int order) {
...
@@ -488,16 +497,19 @@ inline int _Py_atomic_load_32bit(volatile int* value, int order) {
return
old
;
return
old
;
}
}
#define _Py_atomic_load_32bit(ATOMIC_VAL, ORDER) \
_Py_atomic_load_32bit_impl((volatile int*)&((ATOMIC_VAL)->_value), (ORDER))
#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
#define _Py_atomic_store_explicit(ATOMIC_VAL, NEW_VAL, ORDER) \
if (sizeof((ATOMIC_VAL)->_value) == 8) { \
if (sizeof((ATOMIC_VAL)->_value) == 8) { \
_Py_atomic_store_64bit(
&((ATOMIC_VAL)->_value), NEW_VAL, ORDER
) } else { \
_Py_atomic_store_64bit(
(ATOMIC_VAL), (NEW_VAL), (ORDER)
) } else { \
_Py_atomic_store_32bit(
&((ATOMIC_VAL)->_value), NEW_VAL, ORDER
) }
_Py_atomic_store_32bit(
(ATOMIC_VAL), (NEW_VAL), (ORDER)
) }
#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
#define _Py_atomic_load_explicit(ATOMIC_VAL, ORDER) \
( \
( \
sizeof((ATOMIC_VAL)->_value) == 8 ? \
sizeof((ATOMIC_VAL)->_value) == 8 ? \
_Py_atomic_load_64bit(
&((ATOMIC_VAL)->_value), ORDER
) : \
_Py_atomic_load_64bit(
(ATOMIC_VAL), (ORDER)
) : \
_Py_atomic_load_32bit(
&((ATOMIC_VAL)->_value), ORDER
) \
_Py_atomic_load_32bit(
(ATOMIC_VAL), (ORDER)
) \
)
)
#endif
#endif
#else
/* !gcc x86 !_msc_ver */
#else
/* !gcc x86 !_msc_ver */
...
@@ -529,16 +541,16 @@ typedef struct _Py_atomic_int {
...
@@ -529,16 +541,16 @@ typedef struct _Py_atomic_int {
/* Standardized shortcuts. */
/* Standardized shortcuts. */
#define _Py_atomic_store(ATOMIC_VAL, NEW_VAL) \
#define _Py_atomic_store(ATOMIC_VAL, NEW_VAL) \
_Py_atomic_store_explicit(
ATOMIC_VAL, NEW_VAL
, _Py_memory_order_seq_cst)
_Py_atomic_store_explicit(
(ATOMIC_VAL), (NEW_VAL)
, _Py_memory_order_seq_cst)
#define _Py_atomic_load(ATOMIC_VAL) \
#define _Py_atomic_load(ATOMIC_VAL) \
_Py_atomic_load_explicit(
ATOMIC_VAL
, _Py_memory_order_seq_cst)
_Py_atomic_load_explicit(
(ATOMIC_VAL)
, _Py_memory_order_seq_cst)
/* Python-local extensions */
/* Python-local extensions */
#define _Py_atomic_store_relaxed(ATOMIC_VAL, NEW_VAL) \
#define _Py_atomic_store_relaxed(ATOMIC_VAL, NEW_VAL) \
_Py_atomic_store_explicit(
ATOMIC_VAL, NEW_VAL
, _Py_memory_order_relaxed)
_Py_atomic_store_explicit(
(ATOMIC_VAL), (NEW_VAL)
, _Py_memory_order_relaxed)
#define _Py_atomic_load_relaxed(ATOMIC_VAL) \
#define _Py_atomic_load_relaxed(ATOMIC_VAL) \
_Py_atomic_load_explicit(
ATOMIC_VAL
, _Py_memory_order_relaxed)
_Py_atomic_load_explicit(
(ATOMIC_VAL)
, _Py_memory_order_relaxed)
#ifdef __cplusplus
#ifdef __cplusplus
}
}
...
...
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