Rust kernel modules
Rust kernel modules
Posted May 19, 2015 21:38 UTC (Tue) by Cyberax (✭ supporter ✭, #52523)In reply to: Rust kernel modules by cesarb
Parent article: Rust 1.0 released
That's not a problem, any realistic project to integrate with the kernel infrastructure would use bindgen to automatically generate bindings for structure definitions and functions based on C source.
The trickiest part would be inline functions. And I think Rust is also missing a simple way to wrap unions.
> Really, the only sane way to do it would be to either use a C stub to wrap all calls to macros or inline functions, or to somehow autogenerate the Rust equivalent from the kernel C structures, inline functions, and macros.
It should be possible to eventually create something like Go's "import C" feature, that allows to automatically wrap C code in native bindings. Perhaps even preserving inline qualifiers by using Clang to compile C blocks within Rust code.
That's a sizable amount of work, but it's _possible_. And in extreme, Rust can be used just like pure "C" - simply slap 'unsafe' qualifier on your code and go mad with raw pointers.
From what I see, right now Rust is the only major language capable of replacing pure C/C++ even for the most low-level tasks.
Posted May 19, 2015 23:22 UTC (Tue)
by cesarb (subscriber, #6266)
[Link]
Yes! That's what makes me so interested in it. IMO, it sits between C and C++, and adds a few very interesting new features of its own (like the borrow checker). And it has a gradual series of "escape valves" in case it feels limiting: unsafe blocks, inline assembly (in a future version or in unstable nightly), and as a last resort near-seamless linking to C (and indirectly to C++).
Rust kernel modules
