1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

RB_RANDOM_DATA_INIT_PARENT: convert into an inline function

Bit readable to me.
This commit is contained in:
卜部昌平 2020-10-06 11:22:31 +09:00
parent 78e27ced97
commit 81068b1090
Notes: git 2020-10-06 14:20:35 +09:00

View file

@ -52,14 +52,14 @@ typedef struct {
#if defined _WIN32 && !defined __CYGWIN__ #if defined _WIN32 && !defined __CYGWIN__
typedef rb_data_type_t rb_random_data_type_t; typedef rb_data_type_t rb_random_data_type_t;
# define RB_RANDOM_PARENT 0 # define RB_RANDOM_PARENT 0
# define RB_RANDOM_DATA_INIT_PARENT(random_data) \
(random_data.parent = &rb_random_data_type)
#else #else
typedef const rb_data_type_t rb_random_data_type_t; typedef const rb_data_type_t rb_random_data_type_t;
# define RB_RANDOM_PARENT &rb_random_data_type # define RB_RANDOM_PARENT &rb_random_data_type
# define RB_RANDOM_DATA_INIT_PARENT(random_data) ((void)0)
#endif #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_mark(void *ptr);
void rb_random_base_init(rb_random_t *rnd); void rb_random_base_init(rb_random_t *rnd);
double rb_int_pair_to_real(uint32_t a, uint32_t b, int excl); 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); 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 */ #endif /* RUBY_RANDOM_H */