Skip to content

Conversation

SidManning
Copy link

This addresses a failure in the pico-libc, test-fread-fwrite test.

Per the spec:
SYS_SEEK (0x0A)
Seeks to a specified position in a file using an offset specified from the start of the file. The file is assumed to be a byte array and the offset is given in bytes.

Entry
On entry, r1 contains a pointer to a two-word data block:

word 1
This is a handle for a seekable file object.

word 2
The absolute byte position to search to.

Change-Id: Ie3e7ea07a5623ee178a98484bbf1cdbdd3363a01

@quic-mathbern
Copy link

On a second look, I agree with the change, Sid. Only three comments/suggestions:

  • Use GDB_SEEK_SET instead of 0 for the whence
  • Rename common_semi_ftell_cb to something like common_semi_fs_reposition_cb, so that the name is generic enough for both ftell and seek.
  • Reword the commit message to mention that the fix is due to a spec divergence between arm and hexagon for SYS_SEEK. You can quote the SYS_SEEK entry on the hexagon semihosting spec which says: "Returns the newly set offset on success or -1 on error, with r1 set to the associated errno."

@androm3da
Copy link

Sorry - I rebased hex-next this weekend so you'll need to rebase your change. Or: just leave it as-is and let me know when it's ready and I'll cherry-pick it.

Fixes PicoLibc's test-fread-fwrite test.

Returns the newly set offset on success or -1 on error,
with r1 set to the associated errno.

ARM-SWI returns 0 if the request was successful, negative value
otherwise.

Change-Id: Ie3e7ea07a5623ee178a98484bbf1cdbdd3363a01
Signed-off-by: Sid Manning <[email protected]>
@quic-mathbern quic-mathbern self-requested a review October 17, 2025 14:14
@androm3da androm3da merged commit 0028f0b into hex-next Oct 17, 2025
1 check passed
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.

3 participants