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

[GR-59866] Follow up for PR "Add IO#pread and IO#pwrite methods" #3764

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions src/main/ruby/truffleruby/core/posix.rb
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def self.read_string_polyglot(io, length)
end
end

def self.pread_string_native(io, length, offset)
def self.pread_string(io, length, offset)
fd = io.fileno
buffer = Primitive.io_thread_buffer_allocate(length)

Expand All @@ -508,10 +508,6 @@ def self.pread_string_native(io, length, offset)
end
end

def self.pread_string_polyglot(io, length, offset)
raise 'Not implemented' # there is not way to read starting from a specific position
end

# #write_string (either #write_string_native or #write_string_polyglot) is
# called by IO#syswrite, IO#write, and IO::InternalBuffer#empty_to

Expand Down Expand Up @@ -604,7 +600,7 @@ def self.write_string_nonblock_polyglot(io, string)
end
end

def self.pwrite_string_native(io, string, offset)
def self.pwrite_string(io, string, offset)
fd = io.fileno
length = string.bytesize
buffer = Primitive.io_thread_buffer_allocate(length)
Expand All @@ -621,30 +617,22 @@ def self.pwrite_string_native(io, string, offset)
end
end

def self.pwrite_string_polyglot(io, length, offset)
raise 'Not implemented' # there is not way to write starting from a specific position
end

# Select between native and polyglot variants

Truffle::Boot.delay do
if Truffle::Boot.get_option('polyglot-stdio')
class << self
alias_method :read_string, :read_string_polyglot
alias_method :read_to_buffer, :read_to_buffer_polyglot
alias_method :pread_string, :pread_string_polyglot
alias_method :write_string, :write_string_polyglot
alias_method :write_string_nonblock, :write_string_nonblock_polyglot
alias_method :pwrite_string, :pwrite_string_polyglot
end
else
class << self
alias_method :read_string, :read_string_native
alias_method :read_to_buffer, :read_to_buffer_native
alias_method :pread_string, :pread_string_native
alias_method :write_string, :write_string_native
alias_method :write_string_nonblock, :write_string_nonblock_native
alias_method :pwrite_string, :pwrite_string_native
end
end
end
Expand Down
Loading