1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[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
This commit is contained in:
Sutou Kouhei 2021-07-05 10:45:48 +09:00 committed by Nobuyoshi Nakada
parent 5c0d8c6369
commit bb868f4814
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
4 changed files with 11 additions and 16 deletions

View file

@ -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)')

View file

@ -2,6 +2,7 @@
#define FIDDLE_H
#include <ruby.h>
#include <ruby/version.h>
#include <errno.h>
#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

View file

@ -1,10 +1,11 @@
#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 @@
# define UINTPTR2NUM UINT2NUM
#endif
#include <fiddle.h>
#ifdef FIDDLE_MEMORY_VIEW
VALUE rb_cMemoryView = Qnil;
struct memview_data {

View file

@ -6,13 +6,13 @@
#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)