summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-01-20 20:24:49 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-01-21 00:30:34 +0900
commitf0f2535c4daad91872c9f133f8812c421edf0dbb (patch)
treef8bc69db884cbbc32bae53e8f00f9202cf78513d
parent056e7a0154fe4c71eca3726c878bb3da7e4138f8 (diff)
Add `queue_list` and `szqueue_list` macros
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/7161
-rw-r--r--thread_sync.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/thread_sync.c b/thread_sync.c
index 9b51dc55e2..74a26bd0ac 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -651,6 +651,7 @@ rb_mutex_allow_trap(VALUE self, int val)
/* Queue */
#define queue_waitq(q) UNALIGNED_MEMBER_PTR(q, waitq)
+#define queue_list(q) UNALIGNED_MEMBER_PTR(q, que)
PACKED_STRUCT_UNALIGNED(struct rb_queue {
struct ccan_list_head waitq;
rb_serial_t fork_gen;
@@ -659,6 +660,7 @@ PACKED_STRUCT_UNALIGNED(struct rb_queue {
});
#define szqueue_waitq(sq) UNALIGNED_MEMBER_PTR(sq, q.waitq)
+#define szqueue_list(sq) UNALIGNED_MEMBER_PTR(sq, q.que)
#define szqueue_pushq(sq) UNALIGNED_MEMBER_PTR(sq, pushq)
PACKED_STRUCT_UNALIGNED(struct rb_szqueue {
struct rb_queue q;
@@ -905,7 +907,7 @@ rb_queue_initialize(int argc, VALUE *argv, VALUE self)
if ((argc = rb_scan_args(argc, argv, "01", &initial)) == 1) {
initial = rb_to_array(initial);
}
- RB_OBJ_WRITE(self, UNALIGNED_MEMBER_ACCESS((void *)&q->que), ary_buf_new());
+ RB_OBJ_WRITE(self, queue_list(q), ary_buf_new());
ccan_list_head_init(queue_waitq(q));
if (argc == 1) {
rb_ary_concat(q->que, initial);
@@ -1178,7 +1180,7 @@ rb_szqueue_initialize(VALUE self, VALUE vmax)
rb_raise(rb_eArgError, "queue size must be positive");
}
- RB_OBJ_WRITE(self, UNALIGNED_MEMBER_ACCESS((void *)&sq->q.que), ary_buf_new());
+ RB_OBJ_WRITE(self, szqueue_list(sq), ary_buf_new());
ccan_list_head_init(szqueue_waitq(sq));
ccan_list_head_init(szqueue_pushq(sq));
sq->max = max;