Skip to content

Commit 154da14

Browse files
committed
[GR-19220] Support varargs in Truffle::POSIX and fix fcntl and open (#2656)
PullRequest: truffleruby/3352
2 parents 549ddab + 7907108 commit 154da14

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/main/ruby/truffleruby/core/posix.rb

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ def self.to_nfi_type(type)
8484
end
8585
end
8686

87+
def self.varargs(type)
88+
:"...#{to_nfi_type(type)}"
89+
end
90+
8791
# the actual function is looked up and attached on its first call
8892
def self.attach_function(native_name, argument_types, return_type,
8993
library = LIBC, blocking = false, method_name = native_name, on = self)
@@ -184,7 +188,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
184188
attach_function :dup2, [:int, :int], :int
185189
attach_function :fchmod, [:int, :mode_t], :int
186190
attach_function :fchown, [:int, :uid_t, :gid_t], :int
187-
attach_function :fcntl, [:int, :int, :int], :int
191+
attach_function :fcntl, [:int, :int, varargs(:int)], :int
188192
attach_function :flock, [:int, :int], :int, LIBC, true
189193
attach_function :truffleposix_fstat, [:int, :pointer], :int, LIBTRUFFLEPOSIX
190194
attach_function :truffleposix_fstat_mode, [:int], :mode_t, LIBTRUFFLEPOSIX
@@ -207,7 +211,7 @@ def self.attach_function_eagerly(native_name, argument_types, return_type,
207211
attach_function :truffleposix_minor, [:dev_t], :uint, LIBTRUFFLEPOSIX
208212
attach_function :mkdir, [:string, :mode_t], :int
209213
attach_function :mkfifo, [:string, :mode_t], :int
210-
attach_function :open, [:string, :int, :mode_t], :int
214+
attach_function :open, [:string, :int, varargs(:mode_t)], :int
211215
attach_function :opendir, [:string], :pointer
212216
attach_function :pipe, [:pointer], :int
213217
attach_function :read, [:int, :pointer, :size_t], :ssize_t, LIBC, true

0 commit comments

Comments
 (0)