[前][次][番号順一覧][スレッド一覧]

ruby-changes:63281

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 6 Oct 2020 14:20:26 +0900 (JST)
Subject: [ruby-changes:63281] 81068b1090 (master): RB_RANDOM_DATA_INIT_PARENT: convert into an inline function

https://git.ruby-lang.org/ruby.git/commit/?id=81068b1090

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?=
 <shyouhei@r...>
Date: Tue, 6 Oct 2020 11:22:31 +0900
Subject: RB_RANDOM_DATA_INIT_PARENT: convert into an inline function

Bit readable to me.

diff --git a/include/ruby/random.h b/include/ruby/random.h
index fb4bbf3..001f67d 100644
--- a/include/ruby/random.h
+++ b/include/ruby/random.h
@@ -52,14 +52,14 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/include/ruby/random.h#L52
 #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) https://github.com/ruby/ruby/blob/trunk/include/ruby/random.h#L79
     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 */
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]