Skip to content

Commit 829ac13

Browse files
GH-104787: use bitfields in _asyncio (#104788)
1 parent 8da9d1b commit 829ac13

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

Modules/_asynciomodule.c

+10-7
Original file line numberDiff line numberDiff line change
@@ -119,25 +119,28 @@ typedef enum {
119119
PyObject *prefix##_result; \
120120
PyObject *prefix##_source_tb; \
121121
PyObject *prefix##_cancel_msg; \
122-
fut_state prefix##_state; \
123-
int prefix##_log_tb; \
124-
int prefix##_blocking; \
125122
PyObject *prefix##_weakreflist; \
126-
PyObject *prefix##_cancelled_exc;
123+
PyObject *prefix##_cancelled_exc; \
124+
fut_state prefix##_state; \
125+
/* These bitfields need to be at the end of the struct
126+
so that these and bitfields from TaskObj are contiguous.
127+
*/ \
128+
unsigned prefix##_log_tb: 1; \
129+
unsigned prefix##_blocking: 1;
127130

128131
typedef struct {
129132
FutureObj_HEAD(fut)
130133
} FutureObj;
131134

132135
typedef struct {
133136
FutureObj_HEAD(task)
137+
unsigned task_must_cancel: 1;
138+
unsigned task_log_destroy_pending: 1;
139+
int task_num_cancels_requested;
134140
PyObject *task_fut_waiter;
135141
PyObject *task_coro;
136142
PyObject *task_name;
137143
PyObject *task_context;
138-
int task_must_cancel;
139-
int task_log_destroy_pending;
140-
int task_num_cancels_requested;
141144
} TaskObj;
142145

143146
typedef struct {

0 commit comments

Comments
 (0)