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

Fix FileDescriptor#pos return Int64 on armv6 #10845

Merged
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/crystal/dwarf/info.cr
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ module Crystal
property! abbreviations : Array(Abbrev)

property dwarf64 : Bool
@offset : LibC::OffT
@ref_offset : LibC::OffT
@offset : Int64
@ref_offset : Int64

def initialize(@io : IO::FileDescriptor, @offset)
@ref_offset = offset
Expand Down
4 changes: 2 additions & 2 deletions src/crystal/dwarf/line_numbers.cr
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ module Crystal
#
# An individual compressed sequence.
struct Sequence
property! offset : LibC::OffT
property! offset : Int64
property! unit_length : UInt32
property! version : UInt16
property! header_length : UInt32 # FIXME: UInt64 for DWARF64 (uncommon)
Expand Down Expand Up @@ -166,7 +166,7 @@ module Crystal
# reduce the memory usage of repeating a String many times.
getter matrix : Array(Array(Row))

@offset : LibC::OffT
@offset : Int64

def initialize(@io : IO::FileDescriptor, size, @base_address : LibC::SizeT = 0)
@offset = @io.tell
Expand Down
4 changes: 2 additions & 2 deletions src/crystal/system/unix/file_descriptor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ module Crystal::System::FileDescriptor
end

private def system_pos
pos = LibC.lseek(fd, 0, IO::Seek::Current)
pos = LibC.lseek(fd, 0, IO::Seek::Current).to_i64
raise IO::Error.from_errno "Unable to tell" if pos == -1
pos
end
Expand Down Expand Up @@ -153,7 +153,7 @@ module Crystal::System::FileDescriptor
end

def self.pread(fd, buffer, offset)
bytes_read = LibC.pread(fd, buffer, buffer.size, offset)
bytes_read = LibC.pread(fd, buffer, buffer.size, offset).to_i64

if bytes_read == -1
raise IO::Error.from_errno "Error reading file"
Expand Down
4 changes: 2 additions & 2 deletions src/crystal/system/win32/file_descriptor.cr
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,11 @@ module Crystal::System::FileDescriptor
overlapped.union.offset.offsetHigh = LibC::DWORD.new(offset >> 32)
if LibC.ReadFile(handle, buffer, buffer.size, out bytes_read, pointerof(overlapped)) == 0
error = WinError.value
return 0 if error == WinError::ERROR_HANDLE_EOF
return 0_i64 if error == WinError::ERROR_HANDLE_EOF
raise IO::Error.from_winerror "Error reading file", error
end

bytes_read
bytes_read.to_i64
end

def self.from_stdio(fd)
Expand Down
3 changes: 2 additions & 1 deletion src/file/preader.cr
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ class File::PReader < IO

@offset : Int64
@bytesize : Int64
@pos : Int64

def initialize(@file : File, offset : Int, bytesize : Int)
@offset = offset.to_i64
@bytesize = bytesize.to_i64
@pos = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related, but pos really should be Int64

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added it anyways. It's in a similar mood.

end

def unbuffered_read(slice : Bytes)
def unbuffered_read(slice : Bytes) : Int64
check_open

count = slice.size
Expand Down