Commit 4e3bbef
committed
Move __getrandom_custom definition into an unnamed block
This supersedes #341, and makes the following changes
- All the code for implementing `__getrandom_custom` is now in an
**named** `const` block (unnamed consts require Rust 1.37)
- I found this approch [here](https://internals.rust-lang.org/t/anonymous-modules/15441)
- Nothing inside the block can be referenced outside of it
- `__getrandom_custom` is marked `unsafe`
- It can't be accessed externally, but is "logically" unsafe as it
dereferences raw pointers
- The type of the function is moved to a typedef, so we can check that
the defined type matches that of `getrandom:getrandom`.
- Use `::core::result::Result` instead of `Result`
- Similar to use use of `from_raw_parts_mut` this prevents
compilation errors if `Result` is redefined.
Signed-off-by: Joe Richey <joerichey@google.com>1 parent 93c3074 commit 4e3bbef
1 file changed
+16
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | | - | |
86 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
87 | 94 | | |
88 | | - | |
| 95 | + | |
89 | 96 | | |
90 | 97 | | |
91 | 98 | | |
| |||
0 commit comments