summaryrefslogtreecommitdiff
path: root/include/ruby/random.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/ruby/random.h')
-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 */