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

ruby-changes:63282

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Tue, 6 Oct 2020 14:20:27 +0900 (JST)
Subject: [ruby-changes:63282] ae94c5bf5d (master): STRUCT_ALIGNOF: use RUBY_ALIGNOF

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

From ae94c5bf5d53b061659f9f08e1ee1b46d1447181 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 12:05:20 +0900
Subject: STRUCT_ALIGNOF: use RUBY_ALIGNOF

This was a workaround for RUBY_ALIGNOF's glitch, which has already been
fixed.  See also https://github.com/ruby/ruby/pull/3570

diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c
index ba7cbd9..a59e7b8 100644
--- a/ext/-test-/memory_view/memory_view.c
+++ b/ext/-test-/memory_view/memory_view.c
@@ -2,8 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/memory_view.c#L2
 #include "ruby/memory_view.h"
 
 #define STRUCT_ALIGNOF(T, result) do { \
-    struct S { char _; T t; }; \
-    (result) = (int)offsetof(struct S, t); \
+    (result) = RUBY_ALIGNOF(T); \
 } while(0)
 
 static ID id_str;
diff --git a/memory_view.c b/memory_view.c
index 0b3565c..4f3d8e3 100644
--- a/memory_view.c
+++ b/memory_view.c
@@ -12,8 +12,7 @@ https://github.com/ruby/ruby/blob/trunk/memory_view.c#L12
 #include "ruby/memory_view.h"
 
 #define STRUCT_ALIGNOF(T, result) do { \
-    struct S { char _; T t; }; \
-    (result) = (int)offsetof(struct S, t); \
+    (result) = RUBY_ALIGNOF(T); \
 } while(0)
 
 static ID id_memory_view;
-- 
cgit v0.10.2


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

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