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

rust: Consider whether we want long names for types #315

Open
ojeda opened this issue May 28, 2021 · 1 comment
Open

rust: Consider whether we want long names for types #315

ojeda opened this issue May 28, 2021 · 1 comment
Labels
• lib Related to the `rust/` library.

Comments

@ojeda
Copy link
Member

ojeda commented May 28, 2021

The kernel uses short names for some things, e.g. chrdev, mm, fs, pr_info, etc. On the other hand, we have common functions like platform_device_unregister, not to mention private functions like jornada720_pcmcia_configure_socket.

Rust also employs short names for very common things (e.g. i32, str, Rc, Vec, std, sync...), which makes a lot of sense. On the other hand, namespacing is very common in Rust -- but Rust projects typically avoid fully-qualifying names unless it is ambiguous.

Thus, for commonly used things, it is clear we want short names. However, the question is whether we want to shorten names that are not used too much (or, when used, they do not need to be repeated more than once or twice).

For instance, some may complain FileDescriptorReservation is overly verbose, thus suggesting FileDescReservation or FdReservation (see #313).

Of course, if some name is well-established in the C side, we should go with that. This is more about new names that we will need, e.g. for wrapper types etc.

@ojeda ojeda added • lib Related to the `rust/` library. prio: normal labels May 28, 2021
@ojeda
Copy link
Member Author

ojeda commented May 28, 2021

Personally, I find long names clearer, especially when dealing with unknown APIs, as long as they are not too common or repetitive.

So e.g. I do not mind things functions like GetLongPathNameW or types like VkCommandBufferBeginInfo, and I prefer them vs. things like getlpathw or VkCmdBgnInfo.

@ojeda ojeda changed the title Consider whether we want long names for types rust: Consider whether we want long names for types Jun 3, 2021
metaspace pushed a commit to metaspace/linux that referenced this issue Apr 16, 2024
In case when is64 == 1 in emit(A64_REV32(is64, dst, dst), ctx) the
generated insn reverses byte order for both high and low 32-bit words,
resuling in an incorrect swap as indicated by the jit test:

[ 9757.262607] test_bpf: Rust-for-Linux#312 BSWAP 16: 0x0123456789abcdef -> 0xefcd jited:1 8 PASS
[ 9757.264435] test_bpf: Rust-for-Linux#313 BSWAP 32: 0x0123456789abcdef -> 0xefcdab89 jited:1 ret 1460850314 != -271733879 (0x5712ce8a != 0xefcdab89)FAIL (1 times)
[ 9757.266260] test_bpf: Rust-for-Linux#314 BSWAP 64: 0x0123456789abcdef -> 0x67452301 jited:1 8 PASS
[ 9757.268000] test_bpf: Rust-for-Linux#315 BSWAP 64: 0x0123456789abcdef >> 32 -> 0xefcdab89 jited:1 8 PASS
[ 9757.269686] test_bpf: Rust-for-Linux#316 BSWAP 16: 0xfedcba9876543210 -> 0x1032 jited:1 8 PASS
[ 9757.271380] test_bpf: Rust-for-Linux#317 BSWAP 32: 0xfedcba9876543210 -> 0x10325476 jited:1 ret -1460850316 != 271733878 (0xa8ed3174 != 0x10325476)FAIL (1 times)
[ 9757.273022] test_bpf: Rust-for-Linux#318 BSWAP 64: 0xfedcba9876543210 -> 0x98badcfe jited:1 7 PASS
[ 9757.274721] test_bpf: Rust-for-Linux#319 BSWAP 64: 0xfedcba9876543210 >> 32 -> 0x10325476 jited:1 9 PASS

Fix this by forcing 32bit variant of rev32.

Fixes: 1104247 ("bpf, arm64: Support unconditional bswap")
Signed-off-by: Artem Savkov <[email protected]>
Tested-by: Puranjay Mohan <[email protected]>
Acked-by: Puranjay Mohan <[email protected]>
Acked-by: Xu Kuohai <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
• lib Related to the `rust/` library.
Development

No branches or pull requests

1 participant