Skip to content

Commit b15fdf1

Browse files
committed
Work on signedness of size_t automatically
1 parent 6ab5902 commit b15fdf1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib/truffle/truffle/fiddle_backend.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ module Truffle::FiddleBackend
1616
LONG_NFI_TYPE = "SINT#{SIZEOF_LONG * 8}"
1717
ULONG_NFI_TYPE = "UINT#{SIZEOF_LONG * 8}"
1818

19+
SIZE_T_TYPEDEF = Truffle::Config.lookup('platform.typedef.size_t')
20+
21+
case SIZE_T_TYPEDEF
22+
when 'ulong'
23+
SIGNEDNESS_OF_SIZE_T = 1
24+
else
25+
raise NotImplementedError, "#{SIZE_T_TYPEDEF} not recognised"
26+
end
27+
1928
def self.type_to_nfi(type)
2029
case type
2130
when Fiddle::TYPE_VOID
@@ -96,8 +105,6 @@ def self.convert_native_to_ruby(type, val)
96105
end
97106
end
98107

99-
SIGNEDNESS_OF_SIZE_T = 1 # platform specific!
100-
101108
end
102109

103110
module Fiddle

0 commit comments

Comments
 (0)