Skip to content

Commit 2a05687

Browse files
use uint8_t
1 parent ef9ba7a commit 2a05687

File tree

2 files changed

+11
-14
lines changed

2 files changed

+11
-14
lines changed

Include/internal/pycore_pyatomic_ft_wrappers.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ extern "C" {
2020
#endif
2121

2222
#ifdef Py_GIL_DISABLED
23-
#define FT_ATOMIC_LOAD_INT(value) _Py_atomic_load_int(&value)
24-
#define FT_ATOMIC_STORE_INT(value, new_value) _Py_atomic_store_int(&value, new_value)
2523
#define FT_ATOMIC_LOAD_PTR(value) _Py_atomic_load_ptr(&value)
2624
#define FT_ATOMIC_STORE_PTR(value, new_value) _Py_atomic_store_ptr(&value, new_value)
2725
#define FT_ATOMIC_LOAD_SSIZE(value) _Py_atomic_load_ssize(&value)
@@ -113,8 +111,6 @@ extern "C" {
113111
_Py_atomic_load_ullong_relaxed(&value)
114112

115113
#else
116-
#define FT_ATOMIC_LOAD_INT(value) value
117-
#define FT_ATOMIC_STORE_INT(value, new_value) value = new_value
118114
#define FT_ATOMIC_LOAD_PTR(value) value
119115
#define FT_ATOMIC_STORE_PTR(value, new_value) value = new_value
120116
#define FT_ATOMIC_LOAD_SSIZE(value) value

Modules/_ctypes/ctypes.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,9 @@ typedef struct CFieldObject {
375375
*****************************************************************/
376376

377377
typedef struct {
378-
#ifdef Py_GIL_DISABLED
379-
PyMutex mutex; /* critical section mutex */
380-
#endif
381378
int initialized;
382379
Py_ssize_t size; /* number of bytes */
383-
Py_ssize_t align; /* alignment requirements */
380+
Py_ssize_t align; /* alignment reqwuirements */
384381
Py_ssize_t length; /* number of fields */
385382
ffi_type ffi_type_pointer;
386383
PyObject *proto; /* Only for Pointer/ArrayObject */
@@ -395,16 +392,20 @@ typedef struct {
395392
PyObject *checker;
396393
PyObject *module;
397394
int flags; /* calling convention and such */
398-
int dict_final;
395+
#ifdef Py_GIL_DISABLED
396+
PyMutex mutex; /* critical section mutex */
397+
#endif
398+
uint8_t dict_final;
399399

400400
/* pep3118 fields, pointers need PyMem_Free */
401401
char *format;
402402
int ndim;
403403
Py_ssize_t *shape;
404-
/* Py_ssize_t *strides; */ /* unused in ctypes */
405-
/* Py_ssize_t *suboffsets; */ /* unused in ctypes */
404+
/* Py_ssize_t *strides; */ /* unused in ctypes */
405+
/* Py_ssize_t *suboffsets; */ /* unused in ctypes */
406406
} StgInfo;
407407

408+
408409
/*
409410
To ensure thread safety in the free threading build, the `STGINFO_LOCK` and
410411
`STGINFO_UNLOCK` macros use critical sections to protect against concurrent
@@ -422,17 +423,17 @@ typedef struct {
422423
#define STGINFO_LOCK(stginfo) Py_BEGIN_CRITICAL_SECTION_MUT(&(stginfo)->mutex)
423424
#define STGINFO_UNLOCK() Py_END_CRITICAL_SECTION()
424425

425-
static inline int
426+
static inline uint8_t
426427
stginfo_get_dict_final(StgInfo *info)
427428
{
428-
return FT_ATOMIC_LOAD_INT(info->dict_final);
429+
return FT_ATOMIC_LOAD_UINT8(info->dict_final);
429430
}
430431

431432
static inline void
432433
stginfo_set_dict_final_lock_held(StgInfo *info)
433434
{
434435
_Py_CRITICAL_SECTION_ASSERT_MUTEX_LOCKED(&info->mutex);
435-
FT_ATOMIC_STORE_INT(info->dict_final, 1);
436+
FT_ATOMIC_STORE_UINT8(info->dict_final, 1);
436437
}
437438

438439

0 commit comments

Comments
 (0)