Skip to content

Commit

Permalink
RB_RANDOM_DATA_INIT_PARENT: convert into an inline function
Browse files Browse the repository at this point in the history
Bit readable to me.
  • Loading branch information
shyouhei committed Oct 6, 2020
1 parent 78e27ce commit 81068b1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions include/ruby/random.h
Expand Up @@ -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);
Expand All @@ -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 */

0 comments on commit 81068b1

Please sign in to comment.