Skip to content

Always cast pread, lseek etc. offsets to off_t.#1442

Merged
sunfishcode merged 2 commits into
mainfrom
sunfishcode/libc-offsets
Apr 12, 2025
Merged

Always cast pread, lseek etc. offsets to off_t.#1442
sunfishcode merged 2 commits into
mainfrom
sunfishcode/libc-offsets

Conversation

@sunfishcode
Copy link
Copy Markdown
Member

When calling libc functions that take off_t arguments, always cast to off_t. On platforms where this cast is a no-op, these casts should be optimized away. This eliminates the need for explicit cfgs for platforms which need the casts.

Fixes #1432.

When calling libc functions that take `off_t` arguments, always cast to
`off_t`. On platforms where this cast is a no-op, these casts should be
optimized away. This eliminates the need for explicit `cfg`s for
platforms which need the casts.

Fixes #1432.

// ESP-IDF and Vita don't support 64-bit offsets, for example.
let offset = offset.try_into().map_err(|_| io::Errno::OVERFLOW)?;

This comment was marked as resolved.

This comment was marked as resolved.

@kulp
Copy link
Copy Markdown

kulp commented Apr 9, 2025

Due to unrelated changes between v0.38.44 and v1.0.5, I cannot right now directly test the branch in the current MR, but I did successfully compile my project after cherry-picking 5dbcf91 plus an extra cast for len in fallocate. That is good enough for me personally.

Thanks!

@sunfishcode sunfishcode merged commit 4fbc05c into main Apr 12, 2025
51 checks passed
@sunfishcode sunfishcode deleted the sunfishcode/libc-offsets branch April 12, 2025 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Suggesting additional use of c::off_t inside seek/fallocate/pread/pwrite

2 participants