ruby-changes:66774
From: Sutou <ko1@a...>
Date: Tue, 13 Jul 2021 19:38:28 +0900 (JST)
Subject: [ruby-changes:66774] bb868f4814 (master): [ruby/fiddle] Use have_header and have_type to detect memory view availability
https://git.ruby-lang.org/ruby.git/commit/?id=bb868f4814 From bb868f4814c09c978f20f224c5e99656bc8b9bee Mon Sep 17 00:00:00 2001 From: Sutou Kouhei <kou@c...> Date: Mon, 5 Jul 2021 10:45:48 +0900 Subject: [ruby/fiddle] Use have_header and have_type to detect memory view availability Fix https://github.com/ruby/fiddle/pull/84 It may detect ruby/memory_view.h for system Ruby that is installed in /usr. We can use RUBY_API_VERSION_MAJOR to detect memory view availability because memory view is available since Ruby 3.0. Reported by Jun Aruga. Thanks!!! https://github.com/ruby/fiddle/commit/3292929830 --- ext/fiddle/extconf.rb | 4 ---- ext/fiddle/fiddle.h | 3 ++- ext/fiddle/memory_view.c | 12 +++++------- ext/fiddle/pointer.c | 8 ++++---- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 6ca6853..8cc98fb 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -222,10 +222,6 @@ types.each do |type, signed| https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L222 end end -if have_header("ruby/memory_view.h") - have_type("rb_memory_view_t", ["ruby/memory_view.h"]) -end - if libffi $LOCAL_LIBS.prepend("./#{libffi.a} ").strip! # to exts.mk $INCFLAGS.gsub!(/-I#{libffi.dir}/, '-I$(LIBFFI_DIR)') diff --git a/ext/fiddle/fiddle.h b/ext/fiddle/fiddle.h index dbad910..c5d7fa8 100644 --- a/ext/fiddle/fiddle.h +++ b/ext/fiddle/fiddle.h @@ -2,6 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.h#L2 #define FIDDLE_H #include <ruby.h> +#include <ruby/version.h> #include <errno.h> #if defined(_WIN32) @@ -189,7 +190,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/fiddle.h#L190 #define ALIGN_INT32_T ALIGN_OF(int32_t) #define ALIGN_INT64_T ALIGN_OF(int64_t) -#ifdef HAVE_TYPE_RB_MEMORY_VIEW_T +#if RUBY_API_VERSION_MAJOR >= 3 # define FIDDLE_MEMORY_VIEW #endif diff --git a/ext/fiddle/memory_view.c b/ext/fiddle/memory_view.c index 3e260f9..c9df5fd 100644 --- a/ext/fiddle/memory_view.c +++ b/ext/fiddle/memory_view.c @@ -1,10 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/memory_view.c#L1 +#include <fiddle.h> + +#ifdef FIDDLE_MEMORY_VIEW + #include <stdbool.h> #include <ruby/ruby.h> #include <ruby/encoding.h> - -#ifdef HAVE_RUBY_MEMORY_VIEW_H -# include <ruby/memory_view.h> -#endif +#include <ruby/memory_view.h> #if SIZEOF_INTPTR_T == SIZEOF_LONG_LONG # define INTPTR2NUM LL2NUM @@ -17,9 +18,6 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/memory_view.c#L18 # define UINTPTR2NUM UINT2NUM #endif -#include <fiddle.h> - -#ifdef FIDDLE_MEMORY_VIEW VALUE rb_cMemoryView = Qnil; struct memview_data { diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c index 9336f04..ae9eb16 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -6,13 +6,13 @@ https://github.com/ruby/ruby/blob/trunk/ext/fiddle/pointer.c#L6 #include <ruby/ruby.h> #include <ruby/io.h> -#ifdef HAVE_RUBY_MEMORY_VIEW_H -# include <ruby/memory_view.h> -#endif - #include <ctype.h> #include <fiddle.h> +#ifdef FIDDLE_MEMORY_VIEW +# include <ruby/memory_view.h> +#endif + #ifdef PRIsVALUE # define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj) # define RB_OBJ_STRING(obj) (obj) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/