From 81068b10901783be6f592c55d6edcdea20e3e667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?= Date: Tue, 6 Oct 2020 11:22:31 +0900 Subject: [PATCH] RB_RANDOM_DATA_INIT_PARENT: convert into an inline function Bit readable to me. --- include/ruby/random.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/include/ruby/random.h b/include/ruby/random.h index fb4bbf341e..001f67df86 100644 --- a/include/ruby/random.h +++ b/include/ruby/random.h @@ -52,14 +52,14 @@ typedef struct { #if defined _WIN32 && !defined __CYGWIN__ typedef rb_data_type_t rb_random_data_type_t; # define RB_RANDOM_PARENT 0 -# define RB_RANDOM_DATA_INIT_PARENT(random_data) \ - (random_data.parent = &rb_random_data_type) #else typedef const rb_data_type_t rb_random_data_type_t; # define RB_RANDOM_PARENT &rb_random_data_type -# define RB_RANDOM_DATA_INIT_PARENT(random_data) ((void)0) #endif +#define RB_RANDOM_DATA_INIT_PARENT(random_data) \ + rbimpl_random_data_init_parent(&random_data) + void rb_random_mark(void *ptr); void rb_random_base_init(rb_random_t *rnd); double rb_int_pair_to_real(uint32_t a, uint32_t b, int excl); @@ -79,4 +79,13 @@ rb_rand_if(VALUE obj) return RBIMPL_CAST((const rb_random_interface_t *)ret); } +RBIMPL_ATTR_NOALIAS() +static inline void +rbimpl_random_data_init_parent(rb_random_data_type_t *random_data) +{ +#if defined _WIN32 && !defined __CYGWIN__ + random_data->parent = &rb_random_data_type; +#endif +} + #endif /* RUBY_RANDOM_H */