Skip to content

Commit 6bf6d22

Browse files
committed
Fix and spec against issue with loading Fiddle after the FFI
1 parent f10a548 commit 6bf6d22

File tree

4 files changed

+31
-15
lines changed

4 files changed

+31
-15
lines changed

lib/truffle/truffle/fiddle_backend.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
module Truffle::FiddleBackend
1010

11-
SIZEOF_INT = Truffle::FFI::Pointer.find_type_size(:int)
12-
SIZEOF_LONG = Truffle::FFI::Pointer.find_type_size(:long)
11+
SIZEOF_INT = Truffle.invoke_primitive(:pointer_find_type_size, :int)
12+
SIZEOF_LONG = Truffle.invoke_primitive(:pointer_find_type_size, :long)
1313

1414
INT_NFI_TYPE = "SINT#{SIZEOF_INT * 8}"
1515
UINT_NFI_TYPE = "UINT#{SIZEOF_INT * 8}"
@@ -122,20 +122,20 @@ class DLError < StandardError
122122
TYPE_FLOAT = 7
123123
TYPE_DOUBLE = 8
124124

125-
SIZEOF_VOIDP = Truffle::FFI::Pointer.find_type_size(:pointer)
126-
SIZEOF_CHAR = Truffle::FFI::Pointer.find_type_size(:char)
127-
SIZEOF_SHORT = Truffle::FFI::Pointer.find_type_size(:short)
125+
SIZEOF_VOIDP = Truffle.invoke_primitive(:pointer_find_type_size, :pointer)
126+
SIZEOF_CHAR = Truffle.invoke_primitive(:pointer_find_type_size, :char)
127+
SIZEOF_SHORT = Truffle.invoke_primitive(:pointer_find_type_size, :short)
128128
SIZEOF_INT = Truffle::FiddleBackend::SIZEOF_INT
129129
SIZEOF_LONG = Truffle::FiddleBackend::SIZEOF_LONG
130-
SIZEOF_LONG_LONG = Truffle::FFI::Pointer.find_type_size(:long_long)
131-
SIZEOF_FLOAT = Truffle::FFI::Pointer.find_type_size(:float)
132-
SIZEOF_DOUBLE = Truffle::FFI::Pointer.find_type_size(:double)
133-
134-
SIZEOF_SIZE_T = Truffle::FFI::Pointer.find_type_size(:size_t)
135-
SIZEOF_SSIZE_T = Truffle::FFI::Pointer.find_type_size(:ssize_t)
136-
SIZEOF_PTRDIFF_T = Truffle::FFI::Pointer.find_type_size(:ptrdiff_t)
137-
SIZEOF_INTPTR_T = Truffle::FFI::Pointer.find_type_size(:intptr_t)
138-
SIZEOF_UINTPTR_T = Truffle::FFI::Pointer.find_type_size(:uintptr_t)
130+
SIZEOF_LONG_LONG = Truffle.invoke_primitive(:pointer_find_type_size, :long_long)
131+
SIZEOF_FLOAT = Truffle.invoke_primitive(:pointer_find_type_size, :float)
132+
SIZEOF_DOUBLE = Truffle.invoke_primitive(:pointer_find_type_size, :double)
133+
134+
SIZEOF_SIZE_T = Truffle.invoke_primitive(:pointer_find_type_size, :size_t)
135+
SIZEOF_SSIZE_T = Truffle.invoke_primitive(:pointer_find_type_size, :ssize_t)
136+
SIZEOF_PTRDIFF_T = Truffle.invoke_primitive(:pointer_find_type_size, :ptrdiff_t)
137+
SIZEOF_INTPTR_T = Truffle.invoke_primitive(:pointer_find_type_size, :intptr_t)
138+
SIZEOF_UINTPTR_T = Truffle.invoke_primitive(:pointer_find_type_size, :uintptr_t)
139139

140140
TYPE_SSIZE_T = Truffle::FiddleBackend.int_type(SIZEOF_SIZE_T)
141141
TYPE_SIZE_T = -1 * Truffle::FiddleBackend::SIGNEDNESS_OF_SIZE_T * TYPE_SSIZE_T

spec/tags/truffle/fiddle_tags.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
slow:Fiddle can be loaded after the FFI

spec/truffle/fiddle_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved. This
2+
# code is released under a tri EPL/GPL/LGPL license. You can use it,
3+
# redistribute it and/or modify it under the terms of the:
4+
#
5+
# Eclipse Public License version 1.0, or
6+
# GNU General Public License version 2, or
7+
# GNU Lesser General Public License version 2.1.
8+
9+
require_relative '../ruby/spec_helper'
10+
11+
describe "Fiddle" do
12+
it "can be loaded after the FFI" do
13+
ruby_exe("require 'ffi'; require 'fiddle'; puts 14", args: "2>&1").should == "14\n"
14+
end
15+
end

src/main/ruby/truffleruby/core/truffle/ffi/pointer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class Pointer < AbstractMemory
4848

4949
# NOTE: redefined in lib/truffle/ffi.rb for full FFI
5050
def self.find_type_size(type)
51-
Truffle.invoke_primitive :pointer_find_type_size, type
51+
Truffle.invoke_primitive(:pointer_find_type_size, type)
5252
end
5353

5454
def self.size

0 commit comments

Comments
 (0)