diff --git a/bench/bench_time.rb b/bench/bench_time.rb index aaec64f36..099ec3086 100644 --- a/bench/bench_time.rb +++ b/bench/bench_time.rb @@ -4,7 +4,7 @@ module BenchTime module Posix extend FFI::Library ffi_lib FFI::Library::LIBC - if RUBY_PLATFORM =~ /mswin/ + if FFI::Library::LIBC =~ /ucrtbase/ attach_function :time, :_time64, [ :buffer_out ], :uint64, ignore_error: true else attach_function :time, [ :buffer_out ], :ulong, ignore_error: true diff --git a/lib/ffi/platform.rb b/lib/ffi/platform.rb index 0f0639e48..bf01a27ad 100644 --- a/lib/ffi/platform.rb +++ b/lib/ffi/platform.rb @@ -132,11 +132,8 @@ def self.is_os(os) end LIBC = if IS_WINDOWS - if RbConfig::CONFIG['host_os'] =~ /mingw/i - RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll' - else - "ucrtbase.dll" - end + crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase' + "#{crtname}.dll" elsif IS_GNU GNU_LIBC elsif OS == 'cygwin'