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

IO#write multiple arguments #2501

Closed
carlhoerberg opened this issue Oct 15, 2021 · 2 comments
Closed

IO#write multiple arguments #2501

carlhoerberg opened this issue Oct 15, 2021 · 2 comments
Assignees
Milestone

Comments

@carlhoerberg
Copy link

Cruby/jruby supports multiple arguments to IO#write, and is then using writev instead of write (for IO's who support writev, not all does, eg. openssl sockets). Truffleruby only supports a single argument.

File.open("/tmp/a", "w") do |f|
  f.write("foo", "bar", "\n")
end
<internal:core> core/io.rb:2378:in `write': wrong number of arguments (given 3, expected 1) (ArgumentError)
        from wv.rb:2:in `block in <main>'
        from <internal:core> core/io.rb:695:in `open'
        from wv.rb:1:in `<main>'
@eregon
Copy link
Member

eregon commented Oct 15, 2021

Thank you for the report, IO#write supports multiple arguments since Ruby 2.5 but it seems that was not yet implemented on TruffleRuby.

Given the Strings are typically in managed memory and need to be copied to native memory (at least on JVM, on SVM we could pin the byte[]), it's probably good enough to just add all strings together initially, copy them to native and do the write syscall.

@bjfish Could you implement it?

@bjfish
Copy link
Contributor

bjfish commented Oct 21, 2021

This has been fixed at: 37c7070.

@bjfish bjfish closed this as completed Oct 21, 2021
@bjfish bjfish added this to the 22.0.0 milestone Oct 21, 2021
carlhoerberg added a commit to cloudamqp/amqp-client.rb that referenced this issue Sep 13, 2022
not needed anymore as fixed by:
oracle/truffleruby#2501

included in truffleruby 22.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants