diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index 6ca685317e..8cc98fb8f6 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -222,10 +222,6 @@ types.each do |type, signed| 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 dbad910d07..c5d7fa8016 100644 --- a/ext/fiddle/fiddle.h +++ b/ext/fiddle/fiddle.h @@ -2,6 +2,7 @@ #define FIDDLE_H #include +#include #include #if defined(_WIN32) @@ -189,7 +190,7 @@ #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 3e260f94f9..c9df5fd2bd 100644 --- a/ext/fiddle/memory_view.c +++ b/ext/fiddle/memory_view.c @@ -1,10 +1,11 @@ +#include + +#ifdef FIDDLE_MEMORY_VIEW + #include #include #include - -#ifdef HAVE_RUBY_MEMORY_VIEW_H -# include -#endif +#include #if SIZEOF_INTPTR_T == SIZEOF_LONG_LONG # define INTPTR2NUM LL2NUM @@ -17,9 +18,6 @@ # define UINTPTR2NUM UINT2NUM #endif -#include - -#ifdef FIDDLE_MEMORY_VIEW VALUE rb_cMemoryView = Qnil; struct memview_data { diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c index 9336f0431c..ae9eb166ec 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -6,13 +6,13 @@ #include #include -#ifdef HAVE_RUBY_MEMORY_VIEW_H -# include -#endif - #include #include +#ifdef FIDDLE_MEMORY_VIEW +# include +#endif + #ifdef PRIsVALUE # define RB_OBJ_CLASSNAME(obj) rb_obj_class(obj) # define RB_OBJ_STRING(obj) (obj)