Yikes!!!
Yikes!!!
I'm waiting for OS development to start up in rust as it is clearly the better choice then C/C++ for a kernel.
> But allocating memory seemed like a fun exercise. To allocate something on the heap in Rust, you can do
> let a = ~2
> This creates a pointer to a 2 on the heap.
> let a = Box::new(2);
I believe it's an unstable feature currently to use the "box" keyword to heap-allocate a value, which can also be used in pattern matching. I saw somewhere that "box" will be made into an overloadable operator, such that you can easily create reference-counted and atomically reference-counted types.
And this is the active, in-final-comment-period one which modifies it: https://github.com/rust-lang/rfcs/pull/1228
let foo = unsafe { std::slice::from_raw_parts_mut(0xdeadbeef as *mut u8, 42) };
That gets you a slice (pointer+length that can be used as an array) that points to 0xdeadbeef. Bit more verbose than the c equivalent char* foo = 0xdeadbeef;
but arguably this is pretty rare usecase even for handling raw memoryI'm not saying Redox is the next Linux. But big things come from small beginnings, and good engineers are intensely aware of the limitations of their creations.
"I do, however, have a plan. I will make all applications run in Ring 3. I will do malloc and free through syscalls. I will move significant pieces of functionality into userspace libraries (a new libredox). I will use file numbers to identify file descriptors, and create read/write/seek/close syscalls. I will document the syscalls interface, provide more example programs, including programs that test the correctness of the implementation."
So the creator is aware of and wants correct those issues.