Replace PACKED_STRUCT and PACKED_STRUCT_UNALIGNED

This commit is contained in:
Nobuyoshi Nakada 2023-02-08 12:21:58 +09:00
parent fefe37f98d
commit a56d959ed5
No known key found for this signature in database
GPG Key ID: 7CD2805BFA3770C6
Notes: git 2023-02-08 06:21:27 +00:00
4 changed files with 15 additions and 13 deletions

5
iseq.h
View File

@ -270,10 +270,11 @@ struct iseq_catch_table_entry {
unsigned int sp; unsigned int sp;
}; };
PACKED_STRUCT_UNALIGNED(struct iseq_catch_table { RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
struct iseq_catch_table {
unsigned int size; unsigned int size;
struct iseq_catch_table_entry entries[FLEX_ARY_LEN]; struct iseq_catch_table_entry entries[FLEX_ARY_LEN];
}); } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
static inline int static inline int
iseq_catch_table_bytes(int n) iseq_catch_table_bytes(int n)

View File

@ -652,22 +652,24 @@ rb_mutex_allow_trap(VALUE self, int val)
#define queue_waitq(q) UNALIGNED_MEMBER_PTR(q, waitq) #define queue_waitq(q) UNALIGNED_MEMBER_PTR(q, waitq)
#define queue_list(q) UNALIGNED_MEMBER_PTR(q, que) #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; struct ccan_list_head waitq;
rb_serial_t fork_gen; rb_serial_t fork_gen;
const VALUE que; const VALUE que;
int num_waiting; int num_waiting;
}); } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
#define szqueue_waitq(sq) UNALIGNED_MEMBER_PTR(sq, q.waitq) #define szqueue_waitq(sq) UNALIGNED_MEMBER_PTR(sq, q.waitq)
#define szqueue_list(sq) UNALIGNED_MEMBER_PTR(sq, q.que) #define szqueue_list(sq) UNALIGNED_MEMBER_PTR(sq, q.que)
#define szqueue_pushq(sq) UNALIGNED_MEMBER_PTR(sq, pushq) #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; struct rb_queue q;
int num_waiting_push; int num_waiting_push;
struct ccan_list_head pushq; struct ccan_list_head pushq;
long max; long max;
}); } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
static void static void
queue_mark(void *ptr) queue_mark(void *ptr)

5
time.c
View File

@ -1754,12 +1754,13 @@ localtimew(wideval_t timew, struct vtm *result)
#define TIME_TZMODE_FIXOFF 2 #define TIME_TZMODE_FIXOFF 2
#define TIME_TZMODE_UNINITIALIZED 3 #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. */ wideval_t timew; /* time_t value * TIME_SCALE. possibly Rational. */
struct vtm vtm; struct vtm vtm;
unsigned int tzmode:3; /* 0:localtime 1:utc 2:fixoff 3:uninitialized */ unsigned int tzmode:3; /* 0:localtime 1:utc 2:fixoff 3:uninitialized */
unsigned int tm_got:1; unsigned int tm_got:1;
}); } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
#define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj)) #define GetTimeval(obj, tobj) ((tobj) = get_timeval(obj))
#define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj)) #define GetNewTimeval(obj, tobj) ((tobj) = get_new_timeval(obj))

View File

@ -2,10 +2,8 @@
#define RUBY_TIMEV_H #define RUBY_TIMEV_H
#include "ruby/ruby.h" #include "ruby/ruby.h"
#if 0 RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN()
struct vtm {/* dummy for TAGS */}; struct vtm {
#endif
PACKED_STRUCT_UNALIGNED(struct vtm {
VALUE year; /* 2000 for example. Integer. */ VALUE year; /* 2000 for example. Integer. */
VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */ VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
VALUE utc_offset; /* -3600 as -01:00 for example. 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 sec:6; /* 0..60 */
unsigned int wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */ unsigned int wday:3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */
unsigned int isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */ unsigned int isdst:2; /* 0:StandardTime 1:DayLightSavingTime 3:init */
}); } RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END();
#define TIME_SCALE 1000000000 #define TIME_SCALE 1000000000