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

ruby-changes:66783

From: Nobuyoshi <ko1@a...>
Date: Wed, 14 Jul 2021 19:00:37 +0900 (JST)
Subject: [ruby-changes:66783] 169529a0c0 (master): [ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API version (https://github.com/ruby/fiddle/pull/86)

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

From 169529a0c0973fa925ad3b36f4427d31e802a37e Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 14 Jul 2021 15:38:55 +0900
Subject: [ruby/fiddle] Check HAVE_RUBY_MEMORY_VIEW_H rather than API version
 (https://github.com/ruby/fiddle/pull/86)

https://github.com/ruby/fiddle/commit/c5abcc3a7e
---
 ext/-test-/memory_view/extconf.rb    | 2 ++
 ext/-test-/memory_view/memory_view.c | 7 +++++++
 ext/fiddle/fiddle.c                  | 4 ++--
 ext/fiddle/fiddle.h                  | 4 ----
 ext/fiddle/memory_view.c             | 4 ++--
 ext/fiddle/pointer.c                 | 6 +++---
 6 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/ext/-test-/memory_view/extconf.rb b/ext/-test-/memory_view/extconf.rb
index d786b15..123b80b 100644
--- a/ext/-test-/memory_view/extconf.rb
+++ b/ext/-test-/memory_view/extconf.rb
@@ -1,3 +1,5 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/extconf.rb#L1
 # frozen_string_literal: false
+require "mkmf"
+
 require_relative "../auto_ext.rb"
 auto_ext(inc: true)
diff --git a/ext/-test-/memory_view/memory_view.c b/ext/-test-/memory_view/memory_view.c
index 740c52f..c1df035 100644
--- a/ext/-test-/memory_view/memory_view.c
+++ b/ext/-test-/memory_view/memory_view.c
@@ -1,4 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/memory_view.c#L1
 #include "ruby.h"
+
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
 #include "ruby/memory_view.h"
 
 #define STRUCT_ALIGNOF(T, result) do { \
@@ -373,10 +375,13 @@ mdview_aref(VALUE obj, VALUE indices_v) https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/memory_view.c#L375
     return result;
 }
 
+#endif /* HAVE_RUBY_MEMORY_VIEW_H */
+
 void
 Init_memory_view(void)
 {
     rb_ext_ractor_safe(true);
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
     VALUE mMemoryViewTestUtils = rb_define_module("MemoryViewTestUtils");
 
     rb_define_module_function(mMemoryViewTestUtils, "available?", memory_view_available_p, 1);
@@ -440,4 +445,6 @@ Init_memory_view(void) https://github.com/ruby/ruby/blob/trunk/ext/-test-/memory_view/memory_view.c#L445
     DEF_ALIGNMENT_CONST(double, DOUBLE);
 
 #undef DEF_ALIGNMENT_CONST
+
+#endif /* HAVE_RUBY_MEMORY_VIEW_H */
 }
diff --git a/ext/fiddle/fiddle.c b/ext/fiddle/fiddle.c
index dd819a2..a8b5123 100644
--- a/ext/fiddle/fiddle.c
+++ b/ext/fiddle/fiddle.c
@@ -7,7 +7,7 @@ VALUE rb_eFiddleError; https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.c#L7
 void Init_fiddle_pointer(void);
 void Init_fiddle_pinned(void);
 
-#ifdef FIDDLE_MEMORY_VIEW
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
 void Init_fiddle_memory_view(void);
 #endif
 
@@ -546,7 +546,7 @@ Init_fiddle(void) https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.c#L546
     Init_fiddle_pointer();
     Init_fiddle_pinned();
 
-#ifdef FIDDLE_MEMORY_VIEW
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
     Init_fiddle_memory_view();
 #endif
 }
diff --git a/ext/fiddle/fiddle.h b/ext/fiddle/fiddle.h
index 823689e..bf97b59 100644
--- a/ext/fiddle/fiddle.h
+++ b/ext/fiddle/fiddle.h
@@ -189,10 +189,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.h#L189
 #define ALIGN_INT32_T ALIGN_OF(int32_t)
 #define ALIGN_INT64_T ALIGN_OF(int64_t)
 
-#ifdef HAVE_RUBY_MEMORY_VIEW_H
-# define FIDDLE_MEMORY_VIEW
-#endif
-
 extern VALUE mFiddle;
 extern VALUE rb_eFiddleDLError;
 
diff --git a/ext/fiddle/memory_view.c b/ext/fiddle/memory_view.c
index c9df5fd..fa66fc2 100644
--- a/ext/fiddle/memory_view.c
+++ b/ext/fiddle/memory_view.c
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/memory_view.c#L1
 #include <fiddle.h>
 
-#ifdef FIDDLE_MEMORY_VIEW
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
 
 #include <stdbool.h>
 #include <ruby/ruby.h>
@@ -318,4 +318,4 @@ Init_fiddle_memory_view(void) https://github.com/ruby/ruby/blob/trunk/ext/fiddle/memory_view.c#L318
     rb_define_method(rb_cMemoryView, "to_s", rb_fiddle_memview_to_s, 0);
 }
 
-#endif /* FIDDLE_MEMORY_VIEW */
+#endif /* HAVE_RUBY_MEMORY_VIEW_H */
diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c
index 9d05c13..15107e3 100644
--- a/ext/fiddle/pointer.c
+++ b/ext/fiddle/pointer.c
@@ -9,7 +9,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/pointer.c#L9
 #include <ctype.h>
 #include <fiddle.h>
 
-#ifdef FIDDLE_MEMORY_VIEW
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
 # include <ruby/memory_view.h>
 #endif
 
@@ -92,7 +92,7 @@ static const rb_data_type_t fiddle_ptr_data_type = { https://github.com/ruby/ruby/blob/trunk/ext/fiddle/pointer.c#L92
     {fiddle_ptr_mark, fiddle_ptr_free, fiddle_ptr_memsize,},
 };
 
-#ifdef FIDDLE_MEMORY_VIEW
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
 static struct ptr_data *
 fiddle_ptr_check_memory_view(VALUE obj)
 {
@@ -841,7 +841,7 @@ Init_fiddle_pointer(void) https://github.com/ruby/ruby/blob/trunk/ext/fiddle/pointer.c#L841
     rb_define_method(rb_cPointer, "size", rb_fiddle_ptr_size_get, 0);
     rb_define_method(rb_cPointer, "size=", rb_fiddle_ptr_size_set, 1);
 
-#ifdef FIDDLE_MEMORY_VIEW
+#ifdef HAVE_RUBY_MEMORY_VIEW_H
     rb_memory_view_register(rb_cPointer, &fiddle_ptr_memory_view_entry);
 #endif
 
-- 
cgit v1.1


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

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