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?= Date: Tue, 6 Oct 2020 12:05:20 +0900 Subject: [PATCH] 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 --- ext/-test-/memory_view/memory_view.c | 3 +-- memory_view.c | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c index ba7cbd9825..a59e7b872b 100644 --- a/ext/-test-/memory_view/memory_view.c +++ b/ext/-test-/memory_view/memory_view.c @@ -2,8 +2,7 @@ #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 0b3565caa3..4f3d8e3c55 100644 --- a/memory_view.c +++ b/memory_view.c @@ -12,8 +12,7 @@ #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;