Announcement

Collapse
No announcement yet.

Rust Porting Begins For Intel's "e1000" Linux Network Driver

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • oleid
    replied
    Originally posted by Volta View Post
    It's against duplication, so we can't use ternary conditional operator, but it has SIX string types same time. I can't figure out who their target developers are.
    Are you talking about these?

    I know:
    • std::ffi:OsString
    • std::ffi:CString
    • std::String


    See also std::ffi documentation

    They have their corresponding view types (c.f. std::string_view in C++). That's probably how you reached six types.

    Biggest difference to C and C++ when it comes to strings is that they aren't YOLO types, i.e. when you construct one of these types (without unsafe keyword) the standard library checks that they are valid. And their API guarantees that they stay valid.

    The first ffi type, OsString is operating system defined. It is used for interfacing with the file system (without having to pay the conversion to std::string), and CString is a null terminated string with undefined encoding. The corresponding view can be used wherever you need a char pointer in C.

    Leave a comment:


  • Alliancemd
    replied
    Originally posted by kpedersen View Post
    In this source unit: https://github.com/fujita/rust-e1000.../rust_e1000.rs

    48 unsafe keywords in 1224 lines. And that is generous because many unsafe sections span many lines. An example of a longer one is this:
    https://github.com/fujita/rust-e1000..._e1000.rs#L219

    Is that really worth it? Perhaps in future there will be more infrastructure to access the raw parts in a safer manner.

    That said, it is very fun to see drivers written in higher level languages. A cool project!
    > 48 unsafe keywords in 1224 lines

    You need unsafe to communicate with C code and as it was mentioned, it uses a lot of C bindings because there is no Rust code in the kernel itself.

    > it is very fun to see drivers written in higher level languages

    Rust is not a "high level language". There is no garbage collector or reference counting in the Kernel for example. It has more modern APIs but that does not make it a "high level language", you still manipulate data at a low level(like arrays/slices).

    Leave a comment:


  • Developer12
    replied
    Originally posted by skeevy420 View Post

    OpenZFS

    Could care less about the technical reasons, just imagine how fun that thread will be
    That thread would be downright boring. A reimplementation of ZFS would have none of the licencing issues.

    Leave a comment:


  • Quackdoc
    replied
    Pretty excited for this. though a small part of me hopes so I find it unlikely, cannot help but wonder if there could be preformance improvements come of this too.

    Leave a comment:


  • Volta
    replied
    Originally posted by bachchain View Post

    It sure is, compared to
    Code:
    SomeEnterpriseDataStructureWithAReallyStupidlyLongEnterpriseyName<ThatIsAlsoGenericOverAnotherEnterpriseStructWithAnEquallyStupidlyLongEnterpriseName<WhichItselfAlsoHasAGenericParameter<AdNauseum>>> x;
    What wasn't said in this thread (at least I didn't notice) this 'let' word is more helpful to compiler rather than humans. In this context it makes more sense.

    Leave a comment:


  • bachchain
    replied
    Originally posted by Volta View Post

    What an 'improvement' over: int x;
    It sure is, compared to
    Code:
    SomeEnterpriseDataStructureWithAReallyStupidlyLongEnterpriseyName<ThatIsAlsoGenericOverAnotherEnterpriseStructWithAnEquallyStupidlyLongEnterpriseName<WhichItselfAlsoHasAGenericParameter<AdNauseum>>> x;

    Leave a comment:


  • Volta
    replied
    Originally posted by reba View Post

    Exactly. And it is used as a declaration: "Let x be an element of the set of all natural numbers" = "let int x;"
    What an 'improvement' over: int x;

    Leave a comment:


  • Volta
    replied
    Originally posted by oleid View Post

    You mean i++. Or was it ++i. Actually it is very common in code bases to require "one operation per line", so that "++i" has to live in it's own line.
    I was thinking about for loop, but it's done differently in Rust.

    That betas were mathematicians. In mathematics it is very common to start a proof with "Let".
    Yes, but at first it didn't make any sense in conjunction with variable declaration.

    Leave a comment:


  • bachchain
    replied
    Originally posted by Volta View Post
    but it has SIX string types same time..
    Four of those exist solely to make it not a complete nightmare to interop with other systems' broken string implementations.

    Leave a comment:


  • reba
    replied
    Originally posted by oleid View Post
    That betas were mathematicians. In mathematics it is very common to start a proof with "Let".
    Exactly. And it is used as a declaration: "Let x be an element of the set of all natural numbers" = "let int x;"
    Last edited by reba; 19 September 2022, 05:23 PM.

    Leave a comment:

Working...
X