Skip to content

os: fix swap_bytes_u64#24033

Merged
spytheman merged 3 commits into
vlang:masterfrom
tankf33der:swapbytes
Mar 25, 2025
Merged

os: fix swap_bytes_u64#24033
spytheman merged 3 commits into
vlang:masterfrom
tankf33der:swapbytes

Conversation

@tankf33der

Copy link
Copy Markdown
Contributor

Found via s390x port.

@huly-for-github

Copy link
Copy Markdown

Connected to Huly®: V_0.6-22426

@spytheman

Copy link
Copy Markdown
Contributor

Please add a test case too in file_le_be_test.v, to prevent future regressions.

@spytheman

spytheman commented Mar 24, 2025

Copy link
Copy Markdown
Contributor

I should have probably used the same approach as in reverse_bytes_u64 in vlib/net/conv/conv.v 🤔 , using vfmt off/vfmt on to keep the stair aligned (and easy to inspect/check):

    // vfmt off
    return ((a >> 56) & 0x00000000_000000FF) |
           ((a >> 40) & 0x00000000_0000FF00) |
           ((a >> 24) & 0x00000000_00FF0000) |
           ((a >> 8)  & 0x00000000_FF000000) |
           ((a << 8)  & 0x000000FF_00000000) |
           ((a << 24) & 0x0000FF00_00000000) |
           ((a << 40) & 0x00FF0000_00000000) |
           ((a << 56) & 0xFF000000_00000000)
    // vfmt on

@spytheman spytheman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Excellent work. Thank you 🙇🏻‍♂️.

@spytheman spytheman merged commit d6c3e6f into vlang:master Mar 25, 2025
blackshirt pushed a commit to blackshirt/v that referenced this pull request Mar 25, 2025
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.

2 participants