|
|
Subscribe / Log in / New account

Remote execution in the GNOME tracker

Remote execution in the GNOME tracker

Posted Oct 14, 2023 20:11 UTC (Sat) by tialaramex (subscriber, #21167)
In reply to: Remote execution in the GNOME tracker by NYKevin
Parent article: Remote execution in the GNOME tracker

feature(unchecked_math) is an unstable feature available in Rust nightly, so, if you actually do this? (Really? OK then) you can go help land https://github.com/rust-lang/rust/issues/85122

My guess is that on real hardware people actually use, Wrapping<i32> has the same performance as the unchecked math does, and likely the same results in many cases, without a scary unsafe marker. But I could be wrong.

I use Wrapping<u32> in my hand rolled implementations of MD5 and SHA1 (not for real software, just for toys) because it's true that wrapping arithmetic is nicer if you know that's what you're doing, but it's defined for i32 as well as u32 and I see no reason to imagine it's a problem on modern hardware.

In fact it reminds me of how f32::from_bits and f32::to_bits are trivial - in principle you could imagine a CPU where getting the raw bits out of a 32-bit floating point value and into a 32-bit unsigned integer is a non-trivial operation. In actuality, every computer you could buy for years now went duh, those are just bits, in the same order, same layout, different meaning, types are just in your head man... Rust reserves the right to actually do hard work to deliver these functions, but in reality on any computer you can buy they're just book-keeping changes, and so they cost zero CPU cycles.


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds