Skip to content

Commit

Permalink
Add workaround for "l!" on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Oct 2, 2024
1 parent c688bea commit b809583
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
6 changes: 6 additions & 0 deletions lib/fiddle/pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ module PackInfo # :nodoc: all
when SIZEOF_LONG
PACK_MAP[TYPE_BOOL] = PACK_MAP[TYPE_ULONG]
end
if RUBY_ENGINE == "jruby" and WINDOWS and [0].pack("l!").size == 8
# JRuby's 'l!' pack string doesn't use 32-bit on Windows.
# See https://github.com/jruby/jruby/issues/8357 for details
PACK_MAP[TYPE_LONG] = PACK_MAP[TYPE_INT]
PACK_MAP[TYPE_ULONG] = PACK_MAP[TYPE_UINT]
end

SIZE_MAP = {
TYPE_VOIDP => SIZEOF_VOIDP,
Expand Down
5 changes: 0 additions & 5 deletions test/fiddle/test_c_struct_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ def test_class_size_with_count
end

def test_set_ctypes
if RUBY_ENGINE == "jruby" and Fiddle::WINDOWS
omit("JRuby's 'l!' pack string is buggy. " +
"See https://github.com/jruby/jruby/issues/8357 for details")
end

CStructEntity.malloc([TYPE_INT, TYPE_LONG], Fiddle::RUBY_FREE) do |struct|
struct.assign_names %w[int long]

Expand Down
5 changes: 0 additions & 5 deletions test/fiddle/test_c_union_entity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ def test_class_size_with_count
end

def test_set_ctypes
if RUBY_ENGINE == "jruby" and Fiddle::WINDOWS
omit("JRuby's 'l!' pack string is buggy. " +
"See https://github.com/jruby/jruby/issues/8357 for details")
end

CUnionEntity.malloc([TYPE_INT, TYPE_LONG], Fiddle::RUBY_FREE) do |union|
union.assign_names %w[int long]

Expand Down

0 comments on commit b809583

Please sign in to comment.