Add safety comments to public unsafe functions (#484)

- [x] Changelog updated / no changelog update needed
This commit is contained in:
Corwin 2023-09-14 14:38:45 +02:00 committed by GitHub
commit f0f58741b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 58 additions and 54 deletions

View file

@ -24,7 +24,6 @@ fn entry(gba: agb::Gba) -> ! {
fn main(mut gba: agb::Gba) -> ! {
let (mut unmanaged, _sprites) = gba.display.object.get_unmanaged();
loop {
let mut palette = [0x0; 16];
palette[1] = 0xFF_FF;
palette[2] = 0x00_FF;
@ -95,5 +94,4 @@ fn main(mut gba: agb::Gba) -> ! {
line_done
);
}
}
}

View file

@ -231,6 +231,10 @@ pub struct Gba {
impl Gba {
#[doc(hidden)]
#[must_use]
/// # Safety
///
/// May only be called a single time. It is not needed to call this due to
/// it being called internally by the [`entry`] macro.
pub unsafe fn new_in_entry() -> Self {
Self::single_new()
}

View file

@ -33,6 +33,8 @@ pub fn memory_write_hint<T>(val: *mut T) {
/// This seems to be a problem caused by Rust issue #62256:
/// <https://github.com/rust-lang/rust/issues/62256>
///
/// # Safety
///
/// **WARNING FOR ANYONE WHO FINDS THIS**: This implementation will *only* be
/// correct on the GBA, and should not be used on any other platform. The GBA
/// is very old, and has no atomics to begin with - only a main thread and