production. For example, it controls the behavior of the standard library's
`debug_assert!` macro.
* `target_arch = "..."` - Target CPU architecture, such as `"x86"`, `"x86_64"`
- `"mips"`, `"powerpc"`, `"arm"`, or `"aarch64"`.
+ `"mips"`, `"powerpc"`, `"powerpc64"`, `"powerpc64le"`, `"arm"`, or `"aarch64"`.
* `target_endian = "..."` - Endianness of the target CPU, either `"little"` or
`"big"`.
* `target_env = ".."` - An option provided by the compiler by default
* `let` statements where an explicit type is given.
- For example, `128` is coerced to have type `i8` in the following:
+ For example, `42` is coerced to have type `i8` in the following:
```rust
- let _: i8 = 128;
+ let _: i8 = 42;
```
* `static` and `const` statements (similar to `let` statements).
The value being coerced is the actual parameter, and it is coerced to
the type of the formal parameter.
- For example, `128` is coerced to have type `i8` in the following:
+ For example, `42` is coerced to have type `i8` in the following:
```rust
fn bar(_: i8) { }
fn main() {
- bar(128);
+ bar(42);
}
```
* Instantiations of struct or variant fields
- For example, `128` is coerced to have type `i8` in the following:
+ For example, `42` is coerced to have type `i8` in the following:
```rust
struct Foo { x: i8 }
fn main() {
- Foo { x: 128 };
+ Foo { x: 42 };
}
```
* Function results, either the final line of a block if it is not
semicolon-terminated or any expression in a `return` statement
- For example, `128` is coerced to have type `i8` in the following:
+ For example, `42` is coerced to have type `i8` in the following:
```rust
fn foo() -> i8 {
- 128
+ 42
}
```
target_arch = "x86",
target_arch = "arm",
target_arch = "aarch64",
- target_arch = "powerpc")))]
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "powerpc64le")))]
fn getrandom(buf: &mut [u8]) -> libc::c_long {
#[cfg(target_arch = "x86_64")]
const NR_GETRANDOM: libc::c_long = 318;
#[cfg(target_arch = "x86")]
const NR_GETRANDOM: libc::c_long = 355;
- #[cfg(any(target_arch = "arm", target_arch = "powerpc"))]
+ #[cfg(target_arch = "arm")]
const NR_GETRANDOM: libc::c_long = 384;
+ #[cfg(any(target_arch = "powerpc", target_arch = "powerpc64",
+ target_arch = "powerpc64le"))]
+ const NR_GETRANDOM: libc::c_long = 359;
#[cfg(target_arch = "aarch64")]
const NR_GETRANDOM: libc::c_long = 278;
target_arch = "x86",
target_arch = "arm",
target_arch = "aarch64",
- target_arch = "powerpc"))))]
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "powerpc64le"))))]
fn getrandom(_buf: &mut [u8]) -> libc::c_long { -1 }
fn getrandom_fill_bytes(v: &mut [u8]) {
target_arch = "x86",
target_arch = "arm",
target_arch = "aarch64",
- target_arch = "powerpc")))]
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "powerpc64le")))]
fn is_getrandom_available() -> bool {
use sync::atomic::{AtomicBool, Ordering};
use sync::Once;
target_arch = "x86",
target_arch = "arm",
target_arch = "aarch64",
- target_arch = "powerpc"))))]
+ target_arch = "powerpc",
+ target_arch = "powerpc64",
+ target_arch = "powerpc64le"))))]
fn is_getrandom_available() -> bool { false }
/// A random number generator that retrieves randomness straight from
// getentropy(2) permits a maximum buffer size of 256 bytes
for s in v.chunks_mut(256) {
let ret = unsafe {
- libc::syscall(libc::NR_GETENTROPY, s.as_mut_ptr(), s.len())
+ libc::getentropy(s.as_mut_ptr() as *mut libc::c_void, s.len())
};
if ret == -1 {
panic!("unexpected getentropy error: {}", errno());