ruby-changes:60290
From: Nobuyoshi <ko1@a...>
Date: Wed, 4 Mar 2020 18:14:49 +0900 (JST)
Subject: [ruby-changes:60290] 633a1f15d8 (master): [ruby/fiddle] Use ffi_closure_free if available
https://git.ruby-lang.org/ruby.git/commit/?id=633a1f15d8 From 633a1f15d8228236094ddee12e4e169d655ec49e Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Wed, 4 Mar 2020 18:13:03 +0900 Subject: [ruby/fiddle] Use ffi_closure_free if available diff --git a/ext/fiddle/closure.c b/ext/fiddle/closure.c index 1a80b2b..2044c83 100644 --- a/ext/fiddle/closure.c +++ b/ext/fiddle/closure.c @@ -14,10 +14,7 @@ typedef struct { https://github.com/ruby/ruby/blob/trunk/ext/fiddle/closure.c#L14 } fiddle_closure; #if defined(USE_FFI_CLOSURE_ALLOC) -#elif defined(__OpenBSD__) || defined(__APPLE__) || defined(__linux__) -# define USE_FFI_CLOSURE_ALLOC 0 -#elif defined(RUBY_LIBFFI_MODVERSION) && RUBY_LIBFFI_MODVERSION < 3000005 && \ - (defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_AMD64)) +#elif !defined(HAVE_FFI_CLOSURE_ALLOC) # define USE_FFI_CLOSURE_ALLOC 0 #else # define USE_FFI_CLOSURE_ALLOC 1 diff --git a/ext/fiddle/extconf.rb b/ext/fiddle/extconf.rb index fce0cb4..915afb9 100644 --- a/ext/fiddle/extconf.rb +++ b/ext/fiddle/extconf.rb @@ -13,7 +13,7 @@ if ! bundle https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L13 if have_header(ffi_header = 'ffi.h') true elsif have_header(ffi_header = 'ffi/ffi.h') - $defs.push(format('-DUSE_HEADER_HACKS')) + $defs.push('-DUSE_HEADER_HACKS') true end and (have_library('ffi') || have_library('libffi')) end or @@ -135,6 +135,7 @@ elsif have_header "windows.h" https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L135 end have_const('FFI_STDCALL', ffi_header) +have_func('ffi_closure_alloc', ffi_header) config = File.read(RbConfig.expand(File.join($arch_hdrdir, "ruby/config.h"))) types = {"SIZE_T"=>"SSIZE_T", "PTRDIFF_T"=>nil, "INTPTR_T"=>nil} @@ -142,7 +143,7 @@ types.each do |type, signed| https://github.com/ruby/ruby/blob/trunk/ext/fiddle/extconf.rb#L143 if /^\#define\s+SIZEOF_#{type}\s+(SIZEOF_(.+)|\d+)/ =~ config if size = $2 and size != 'VOIDP' size = types.fetch(size) {size} - $defs << format("-DTYPE_%s=TYPE_%s", signed||type, size) + $defs << "-DTYPE_#{signed||type}=TYPE_#{size}" end if signed check_signedness(type.downcase, "stddef.h") -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/