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

os: fix swap_bytes_u64 #24033

Merged
merged 3 commits into from
Mar 25, 2025
Merged

os: fix swap_bytes_u64 #24033

merged 3 commits into from
Mar 25, 2025

Conversation

tankf33der
Copy link
Contributor

Found via s390x port.

Copy link

Connected to Huly®: V_0.6-22426

@spytheman
Copy link
Member

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

@spytheman
Copy link
Member

spytheman commented Mar 24, 2025

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

Copy link
Member

@spytheman spytheman left a comment

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
68 of 69 checks passed
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