Get the latest tech news

Rust in the Linux kernel: part 2


In 2023, Fujita Tomonori wrote a Rust version of the existing driver for the Asix AX88796B em [...]

The as u16 part at the end is a cast, since the original uapi::BMCR_* constants being referenced are defined in C and assumed to be 32 or 64 bits by default, depending on the platform. References (written with an &) are in many ways Rust's most prominent feature; they are like pointers, but with compile-time guarantees that certain classes of bugs (such as concurrent mutable access without synchronization) can't happen. The C equivalent is a const pointer to the data section of the executable: it is never allocated, freed, or modified, and is therefore fine to dereference anywhere in the program.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Linux

Linux

Photo of linux kernel

linux kernel

Related news:

News photo

Lyon, France, joins European Exodus from Windows to Linux

News photo

Bcachefs Changes End Up Being Merged Into Linux 6.16, For 6.17: "We'll Be Parting Ways"

News photo

VirtualBox 7.2 Beta 2 Preps Linux 6.16 Support, More Windows On ARM Enhancements