bolts: initial haiku support (#1643)

This commit is contained in:
David CARLIER 2023-11-03 16:18:53 +00:00 committed by GitHub
parent 745326ee26
commit 2e980ca08d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 82 additions and 10 deletions

View File

@ -346,6 +346,21 @@ mod linux {
} }
} }
// Haiku
// FIXME: no sense of cpu granularity (yet ?)
#[cfg(target_os = "haiku")]
#[inline]
fn get_core_ids_helper() -> Result<Vec<CoreId>, Error> {
Ok(Vec::new())
}
#[cfg(target_os = "haiku")]
#[inline]
fn set_for_current_helper(_core_id: CoreId) -> Result<(), Error> {
Ok(())
}
// Windows Section // Windows Section
#[cfg(target_os = "windows")] #[cfg(target_os = "windows")]

View File

@ -393,6 +393,35 @@ pub fn dump_registers<W: Write>(
Ok(()) Ok(())
} }
/// Write the content of all important registers
#[cfg(all(target_os = "haiku", target_arch = "x86_64"))]
#[allow(clippy::similar_names)]
pub fn dump_registers<W: Write>(
writer: &mut BufWriter<W>,
ucontext: &ucontext_t,
) -> Result<(), std::io::Error> {
let mcontext = &ucontext.uc_mcontext;
write!(writer, "r8 : {:#016x}, ", mcontext.r8)?;
write!(writer, "r9 : {:#016x}, ", mcontext.r9)?;
write!(writer, "r10 : {:#016x}, ", mcontext.r10)?;
write!(writer, "r11 : {:#016x}, ", mcontext.r11)?;
write!(writer, "r12 : {:#016x}, ", mcontext.r12)?;
write!(writer, "r13 : {:#016x}, ", mcontext.r13)?;
write!(writer, "r14 : {:#016x}, ", mcontext.r14)?;
write!(writer, "r15 : {:#016x}, ", mcontext.r15)?;
write!(writer, "rdi : {:#016x}, ", mcontext.rdi)?;
write!(writer, "rsi : {:#016x}, ", mcontext.rsi)?;
write!(writer, "rbp : {:#016x}, ", mcontext.rbp)?;
write!(writer, "rbx : {:#016x}, ", mcontext.rbx)?;
write!(writer, "rdx : {:#016x}, ", mcontext.rdx)?;
write!(writer, "rax : {:#016x}, ", mcontext.rax)?;
write!(writer, "rcx : {:#016x}, ", mcontext.rcx)?;
write!(writer, "rsp : {:#016x}, ", mcontext.rsp)?;
write!(writer, "rflags : {:#016x}, ", mcontext.rflags)?;
Ok(())
}
#[allow(clippy::unnecessary_wraps)] #[allow(clippy::unnecessary_wraps)]
#[cfg(not(any( #[cfg(not(any(
target_vendor = "apple", target_vendor = "apple",
@ -402,6 +431,7 @@ pub fn dump_registers<W: Write>(
target_os = "dragonfly", target_os = "dragonfly",
target_os = "netbsd", target_os = "netbsd",
target_os = "openbsd", target_os = "openbsd",
target_os = "haiku",
any(target_os = "solaris", target_os = "illumos"), any(target_os = "solaris", target_os = "illumos"),
)))] )))]
fn dump_registers<W: Write>( fn dump_registers<W: Write>(
@ -816,10 +846,33 @@ fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Er
Ok(()) Ok(())
} }
#[cfg(target_os = "haiku")]
fn write_minibsod<W: Write>(writer: &mut BufWriter<W>) -> Result<(), std::io::Error> {
let mut info: libc::image_info = unsafe { std::mem::zeroed() };
let mut c: i32 = 0;
loop {
if unsafe { libc::get_next_image_info(0, &mut c, &mut info) } == libc::B_OK {
let i = format!(
"{}-{} {:?}\n",
info.text as u64,
info.text as u64 + info.text_size as u64,
info.name
);
writer.write_all(&i.into_bytes())?;
} else {
break;
}
}
Ok(())
}
#[cfg(not(any( #[cfg(not(any(
target_os = "freebsd", target_os = "freebsd",
target_os = "openbsd", target_os = "openbsd",
target_os = "netbsd", target_os = "netbsd",
target_os = "haiku",
target_env = "apple", target_env = "apple",
any(target_os = "linux", target_os = "android"), any(target_os = "linux", target_os = "android"),
any(target_os = "solaris", target_os = "illumos"), any(target_os = "solaris", target_os = "illumos"),

View File

@ -16,16 +16,20 @@ use std::io::Read;
use std::io::Write; use std::io::Write;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(all(feature = "std", unix, not(target_os = "android")))] #[cfg(all(
feature = "std",
unix,
not(any(target_os = "android", target_os = "haiku"))
))]
pub use unix_shmem::{MmapShMem, MmapShMemProvider}; pub use unix_shmem::{MmapShMem, MmapShMemProvider};
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix, not(target_os = "haiku")))]
pub use unix_shmem::{UnixShMem, UnixShMemProvider}; pub use unix_shmem::{UnixShMem, UnixShMemProvider};
#[cfg(all(windows, feature = "std"))] #[cfg(all(windows, feature = "std"))]
pub use win32_shmem::{Win32ShMem, Win32ShMemProvider}; pub use win32_shmem::{Win32ShMem, Win32ShMemProvider};
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std"))]
use crate::os::pipes::Pipe; use crate::os::pipes::Pipe;
#[cfg(all(feature = "std", unix))] #[cfg(all(feature = "std", unix, not(target_os = "haiku")))]
pub use crate::os::unix_shmem_server::{ServedShMemProvider, ShMemService}; pub use crate::os::unix_shmem_server::{ServedShMemProvider, ShMemService};
use crate::{AsMutSlice, AsSlice, Error}; use crate::{AsMutSlice, AsSlice, Error};
@ -49,12 +53,12 @@ pub type StdShMemService = ShMemService<MmapShMemProvider>;
#[cfg(all( #[cfg(all(
feature = "std", feature = "std",
unix, unix,
not(any(target_os = "android", target_vendor = "apple")) not(any(target_os = "android", target_vendor = "apple", target_os = "haiku"))
))] ))]
pub type StdShMemProvider = UnixShMemProvider; pub type StdShMemProvider = UnixShMemProvider;
/// The standard sharedmem service /// The standard sharedmem service
#[cfg(any( #[cfg(any(
not(any(target_os = "android", target_vendor = "apple")), not(any(target_os = "android", target_vendor = "apple", target_os = "haiku")),
not(feature = "std") not(feature = "std")
))] ))]
pub type StdShMemService = DummyShMemService; pub type StdShMemService = DummyShMemService;
@ -71,7 +75,7 @@ pub type StdServedShMemProvider = RcShMemProvider<ServedShMemProvider<MmapShMemP
#[cfg(all( #[cfg(all(
feature = "std", feature = "std",
unix, unix,
not(any(target_os = "android", target_vendor = "apple")) not(any(target_os = "android", target_vendor = "apple", target_os = "haiku"))
))] ))]
pub type StdServedShMemProvider = RcShMemProvider<ServedShMemProvider<MmapShMemProvider>>; pub type StdServedShMemProvider = RcShMemProvider<ServedShMemProvider<MmapShMemProvider>>;
@ -427,7 +431,7 @@ where
//#[cfg(all(unix, feature = "std"))] //#[cfg(all(unix, feature = "std"))]
//unsafe impl<SP: ShMemProvider> Send for RcShMemProvider<SP> {} //unsafe impl<SP: ShMemProvider> Send for RcShMemProvider<SP> {}
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
impl<SP> ShMemProvider for RcShMemProvider<SP> impl<SP> ShMemProvider for RcShMemProvider<SP>
where where
SP: ShMemProvider + Debug, SP: ShMemProvider + Debug,
@ -563,7 +567,7 @@ where
} }
} }
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
impl<SP> Default for RcShMemProvider<SP> impl<SP> Default for RcShMemProvider<SP>
where where
SP: ShMemProvider + Debug, SP: ShMemProvider + Debug,
@ -573,7 +577,7 @@ where
} }
} }
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
impl<SP> RcShMemProvider<ServedShMemProvider<SP>> impl<SP> RcShMemProvider<ServedShMemProvider<SP>>
where where
SP: ShMemProvider + Debug, SP: ShMemProvider + Debug,
@ -589,7 +593,7 @@ where
/// On Android, this is partially reused to wrap [`unix_shmem::ashmem::AshmemShMem`], /// On Android, this is partially reused to wrap [`unix_shmem::ashmem::AshmemShMem`],
/// Although for an [`ServedShMemProvider`] using a unix domain socket /// Although for an [`ServedShMemProvider`] using a unix domain socket
/// Is needed on top. /// Is needed on top.
#[cfg(all(unix, feature = "std"))] #[cfg(all(unix, feature = "std", not(target_os = "haiku")))]
pub mod unix_shmem { pub mod unix_shmem {
#[cfg(doc)] #[cfg(doc)]
use crate::shmem::{ShMem, ShMemProvider}; use crate::shmem::{ShMem, ShMemProvider};