Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert to msvcrt.dll as LIBC on MINGW #790

Merged
merged 3 commits into from Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bench/bench_time.rb
Expand Up @@ -4,7 +4,7 @@ module BenchTime
module Posix
extend FFI::Library
ffi_lib FFI::Library::LIBC
if FFI::Platform.windows?
if RUBY_PLATFORM =~ /mswin/
attach_function :time, :_time64, [ :buffer_out ], :uint64, ignore_error: true
else
attach_function :time, [ :buffer_out ], :ulong, ignore_error: true
Expand Down
6 changes: 5 additions & 1 deletion lib/ffi/platform.rb
Expand Up @@ -129,7 +129,11 @@ def self.is_os(os)
end

LIBC = if IS_WINDOWS
"ucrtbase.dll"
if RbConfig::CONFIG['host_os'] =~ /mingw/i
RbConfig::CONFIG['RUBY_SO_NAME'].split('-')[-2] + '.dll'
else
"ucrtbase.dll"
end
elsif IS_GNU
GNU_LIBC
elsif OS == 'cygwin'
Expand Down
14 changes: 14 additions & 0 deletions spec/ffi/library_spec.rb
Expand Up @@ -64,6 +64,20 @@ class StructUCDP < FFI::Struct
end
end

if RbConfig::CONFIG['host_os'] =~ /mingw/
# See https://github.com/ffi/ffi/issues/788
it "libc functions shouldn't call an invalid parameter handler" do
mod = Module.new do
extend FFI::Library
ffi_lib 'c'
attach_function(:get_osfhandle, :_get_osfhandle, [:int], :intptr_t)
end

expect( mod.get_osfhandle(42) ).to eq(-1)
end
end


describe "ffi_lib" do
it "empty name list should raise error" do
expect {
Expand Down