Use `libc::abort` instead of `intrinsics::abort`

Despite using the `#![feature()]` attribute rustc still warns about it
being unstable. Changing it to `libc::abort` gets rid of the annoying
message.
This commit is contained in:
Martin Habovstiak 2024-07-03 06:45:23 +02:00
parent 924ba381c8
commit df0523a0a7
1 changed files with 7 additions and 5 deletions

View File

@ -28,7 +28,6 @@
//! //!
#![feature(start)] #![feature(start)]
#![feature(core_intrinsics)]
#![feature(alloc_error_handler)] #![feature(alloc_error_handler)]
#![no_std] #![no_std]
extern crate libc; extern crate libc;
@ -48,7 +47,6 @@ extern crate wee_alloc;
static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT; static ALLOC: wee_alloc::WeeAlloc = wee_alloc::WeeAlloc::INIT;
use core::fmt::{self, Write}; use core::fmt::{self, Write};
use core::intrinsics;
use core::panic::PanicInfo; use core::panic::PanicInfo;
use secp256k1::ecdh::{self, SharedSecret}; use secp256k1::ecdh::{self, SharedSecret};
@ -61,6 +59,10 @@ use serde_cbor::de;
use serde_cbor::ser::SliceWrite; use serde_cbor::ser::SliceWrite;
use serde_cbor::Serializer; use serde_cbor::Serializer;
fn abort() -> ! {
unsafe { libc::abort() }
}
struct FakeRng; struct FakeRng;
impl RngCore for FakeRng { impl RngCore for FakeRng {
fn next_u32(&mut self) -> u32 { fn next_u32(&mut self) -> u32 {
@ -157,7 +159,7 @@ impl Write for Print {
if curr + s.len() > MAX_PRINT { if curr + s.len() > MAX_PRINT {
unsafe { unsafe {
libc::printf("overflow\n\0".as_ptr() as _); libc::printf("overflow\n\0".as_ptr() as _);
intrinsics::abort(); abort();
} }
} }
self.loc += s.len(); self.loc += s.len();
@ -173,11 +175,11 @@ fn panic(info: &PanicInfo) -> ! {
let mut buf = Print::new(); let mut buf = Print::new();
write!(&mut buf, "{}", msg).unwrap(); write!(&mut buf, "{}", msg).unwrap();
buf.print(); buf.print();
intrinsics::abort() abort()
} }
#[alloc_error_handler] #[alloc_error_handler]
fn alloc_error(_layout: Layout) -> ! { fn alloc_error(_layout: Layout) -> ! {
unsafe { libc::printf("alloc shi1\n\0".as_ptr() as _) }; unsafe { libc::printf("alloc shi1\n\0".as_ptr() as _) };
intrinsics::abort() abort()
} }