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

rollup: fixup CI and endianness conversion improvements #197

Merged
merged 9 commits into from
Oct 6, 2023

Conversation

BurntSushi
Copy link
Owner

Closes #189

mina86 and others added 7 commits October 5, 2023 17:27
Add read/write into benchmark for u16 to test how the code behaves if
the type is smaller than the native register size and for i64 to test
that there’s nothing weird going on with signedness conversion.
Replace unsafe_read_slice macro which first copies data to destination
buffer and then swaps endianess if necessary with a read_slice macro
which does the swapping in a single pass while the data is read.

This is done with `[T]:chunks_exact` which splits source into chunks
which can be converted into integer of desired type with from_xx_bytes
method.

Closes #189, Closes #196
The compiler is smart enough that it notices when endianess conversion
is not necessary and it simplifies copying with a conversion into
plain memcpy.  This means there’s no need to check target_endian and
use unsafe_write_slice_native macro.
Firstly, get rid of $size argument.  The size can be determined from
$ty so there’s no need to pass it as a separate argument.  Secondly,
change it to use to_xx_bytes methods instead of Self::write_uxx so
that it resembles read_slice.
unsafe_write_num_bytes macro can be replaced by a perfectly safe code
which uses `n::to_xx_bytes()` to convert given number to desired
representation and `buf[..N].copy_from_slice(...)` which writes that
into the buffer.

Closes #193
Rewrite read_uint and read_uint128 methods such that they no longer
use unsafe code.  Rather than casting pointers and doing unsafe
copies, declare output byte buffer for the read number and use
from_xx_bytes method to convert those read bytes to a number.

Closes #192
This is seemingly needed for the soundness fix for #194. I spent zero
time trying to find what the real MSRV was or to find another way to fix
the soundness bug while maintaining the 1.41 MSRV because I didn't care
to. Rust 1.60 is conservative enough as it is.
@BurntSushi BurntSushi merged commit dd41ee2 into master Oct 6, 2023
@BurntSushi BurntSushi deleted the ag/rollup branch October 6, 2023 00:41
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