mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[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
This commit is contained in:
parent
818c74b7f4
commit
169529a0c0
6 changed files with 16 additions and 11 deletions
|
@ -1,3 +1,5 @@
|
|||
# frozen_string_literal: false
|
||||
require "mkmf"
|
||||
|
||||
require_relative "../auto_ext.rb"
|
||||
auto_ext(inc: true)
|
||||
|
|
|
@ -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 */
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue