-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for embedded and no_std
#11
Comments
Is there someone we should cc? Maybe @shepmaster? |
I am willing to provide feedback on the things I know about, but I can't claim to know as much as might be needed. :-) I'd loop in @dylanmckay @japaric as more knowledgable people! |
FWIW, as I think you've noticed is that AVR is an 8-bit target, but it does support 16-bit integers. 32-bit and 64-bit integers are supported fine, albeit they can take up a lot of register space as arguments. It should be fine to include these kinds of functions for AVR because the linker should be able to remove any unused code, so the developer can make the choice of paying the price of a larger int type if they want. The AVR LLVM backend doesn't include bulky runtime functions to handle these types - we just emit a few consecutive additions with carry. You can generally use these types with no issue on AVR. So far as floats go, interestingly, the AVR-GCC compiler has Including |
Thanks @dylanmckay. Good point about the linker removing unused code. If AVR can handle 32-bit integers it doesn't necessarily need to use 16-bit generators, but that may still make sense for performance — so in your opinion should the |
Honestly, it wouldn't be worth 16-bit generators for anything like AVR - it's pretty cheap to convert from 32 to 16-bit, and it wouldn't be worth the overhead of adding support for it IMO. |
I think this one is solved (using the error type mentioned in #10). Only remaining part is lack of |
I can only comment on Cortex-M microcontrollers which have 32 bit cores. Some of these micros have hardware support for random number generation (through the RNG peripheral) of 32 bit integers so I do would like to mention that it would be useful to allow the implementation to be non blocking . A @pftbest is familiar with MSP430, which is a 16-bit architecture. Do you know if there's hardware support for random number generation on MSP430? I suppose that if the RNG only provides 16-bit integers you could combine two generated integers into a 32 bit integer to use the |
There is no dedicated hardware RNG on MSP430, as far as I know. But you can generate some random bits using Timer peripheral by correlating two independent clock sources, see http://www.ti.com/lit/an/slaa338/slaa338.pdf As for 16/32 bit question, I can't say much. I've never used RNG on a micro-controllers, so I don't know if it's valuable to have 16bit support. I think if someone is concerned about the RNG performance they would most probably roll their own implementation instead of including a library. |
Thanks for the comments; still appears there's little demand for @japaric #9 has ... but, so far there has been little call for allowing error-handling on integer functions, meaning the byte-sequence function |
I have a few various embedded devices, and have been following @japaric’s work a bit. If you need help testing I’m available. |
The only |
This is now part of rand 0.4 |
I am not an expert (contributions welcome), but I believe this roughly boils down to:
no_std
implies quite a lot of functionality is unavailableOsRng
is not available; some other entropy source is requiredThe above points are implied by the OS; on the hardware side:
Rng::next_u32
is not appropriate. So is it worth addingnext_u16
just for these platforms? My suspicion is that anything <=16-bit probably won't use common crates likerand
anyway because code-size is a major concern.rand
anyway (as above)? Would it matter that the crate contains FP code so long as it's not used?The text was updated successfully, but these errors were encountered: