diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-07-14 15:38:55 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-07-14 18:55:59 +0900 |
commit | 169529a0c0973fa925ad3b36f4427d31e802a37e (patch) | |
tree | 12d70a5d6bf41b5dc781e4148d2ce9a7b6f75f4b /ext | |
parent | 818c74b7f4d5b88833af26226fc81e563b5d11b9 (diff) | |
download | ruby-169529a0c0973fa925ad3b36f4427d31e802a37e.tar.gz |
[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
Diffstat (limited to 'ext')
-rw-r--r-- | ext/-test-/memory_view/extconf.rb | 2 | ||||
-rw-r--r-- | ext/-test-/memory_view/memory_view.c | 7 | ||||
-rw-r--r-- | ext/fiddle/fiddle.c | 4 | ||||
-rw-r--r-- | ext/fiddle/fiddle.h | 4 | ||||
-rw-r--r-- | ext/fiddle/memory_view.c | 4 | ||||
-rw-r--r-- | 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 d786b15db9..123b80b8d0 100644 --- a/ext/-test-/memory_view/extconf.rb +++ b/ext/-test-/memory_view/extconf.rb @@ -1,3 +1,5 @@ # 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 740c52f0ef..c1df0353cf 100644 --- a/ext/-test-/memory_view/memory_view.c +++ b/ext/-test-/memory_view/memory_view.c @@ -1,4 +1,6 @@ #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) 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) 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 dd819a298c..a8b5123269 100644 --- a/ext/fiddle/fiddle.c +++ b/ext/fiddle/fiddle.c @@ -7,7 +7,7 @@ VALUE rb_eFiddleError; 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) 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 823689e091..bf97b59d53 100644 --- a/ext/fiddle/fiddle.h +++ b/ext/fiddle/fiddle.h @@ -189,10 +189,6 @@ #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 c9df5fd2bd..fa66fc2c7b 100644 --- a/ext/fiddle/memory_view.c +++ b/ext/fiddle/memory_view.c @@ -1,6 +1,6 @@ #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) 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 9d05c137b0..15107e3862 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -9,7 +9,7 @@ #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 = { {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) 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 |