summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2020-10-06 11:22:31 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2020-10-06 14:20:10 +0900
commit81068b10901783be6f592c55d6edcdea20e3e667 (patch)
tree61ff65d06fa4c838098bd7326d1d23f0fb569fce /include
parent78e27ced9764e1c9c82ff71467f4851e8c6bb46b (diff)
RB_RANDOM_DATA_INIT_PARENT: convert into an inline function
Bit readable to me.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3631
Diffstat (limited to 'include')
-rw-r--r--include/ruby/random.h15
1 files 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 */