From a56d959ed5d99e602f2bb05bbeb46a1b1b146cd9 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Wed, 8 Feb 2023 12:21:58 +0900 Subject: [PATCH] Replace `PACKED_STRUCT` and `PACKED_STRUCT_UNALIGNED` --- iseq.h | 5 +++-- thread_sync.c | 10 ++++++---- time.c | 5 +++-- timev.h | 8 +++----- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/iseq.h b/iseq.h index 5e26ea3589..5ddbf8df7d 100644 --- a/iseq.h +++ b/iseq.h @@ -270,10 +270,11 @@ struct iseq_catch_table_entry { unsigned int sp; }; -PACKED_STRUCT_UNALIGNED(struct iseq_catch_table { +RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() +struct iseq_catch_table { unsigned int size; struct iseq_catch_table_entry entries[FLEX_ARY_LEN]; -}); +} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END(); static inline int iseq_catch_table_bytes(int n) diff --git a/thread_sync.c b/thread_sync.c index 74a26bd0ac..9a3a6c1ba7 100644 --- a/thread_sync.c +++ b/thread_sync.c @@ -652,22 +652,24 @@ rb_mutex_allow_trap(VALUE self, int val) #define queue_waitq(q) UNALIGNED_MEMBER_PTR(q, waitq) #define queue_list(q) UNALIGNED_MEMBER_PTR(q, que) -PACKED_STRUCT_UNALIGNED(struct rb_queue { +RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() +struct rb_queue { struct ccan_list_head waitq; rb_serial_t fork_gen; const VALUE que; int num_waiting; -}); +} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END(); #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 { +RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() +struct rb_szqueue { struct rb_queue q; int num_waiting_push; struct ccan_list_head pushq; long max; -}); +} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END(); static void queue_mark(void *ptr) diff --git a/time.c b/time.c index 66c33f0f61..ff441232e2 100644 --- a/time.c +++ b/time.c @@ -1754,12 +1754,13 @@ localtimew(wideval_t timew, struct vtm *result) #define TIME_TZMODE_FIXOFF 2 #define TIME_TZMODE_UNINITIALIZED 3 -PACKED_STRUCT_UNALIGNED(struct time_object { +RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() +struct time_object { wideval_t timew; /* time_t value * TIME_SCALE. possibly Rational. */ struct vtm vtm; unsigned int tzmode:3; /* 0:localtime 1:utc 2:fixoff 3:uninitialized */ unsigned int tm_got:1; -}); +} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END(); #define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj)) #define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj)) diff --git a/timev.h b/timev.h index af97ed95b5..d667b60b14 100644 --- a/timev.h +++ b/timev.h @@ -2,10 +2,8 @@ #define RUBY_TIMEV_H #include "ruby/ruby.h" -#if 0 -struct vtm {/* dummy for TAGS */}; -#endif -PACKED_STRUCT_UNALIGNED(struct vtm { +RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN() +struct vtm { VALUE year; /* 2000 for example. Integer. */ VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */ VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */ @@ -18,7 +16,7 @@ PACKED_STRUCT_UNALIGNED(struct vtm { unsigned int sec:6; /* 0..60 */ unsigned int wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */ unsigned int isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */ -}); +} RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END(); #define TIME_SCALE 1000000000