Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 45 additions & 8 deletions lib/osi/src/ffi/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! to get a native Rust experience. This is suitable if foreign data access
//! is not needed.
//!
//! [`auto`] is an alias of one of the other ABIs and represents the target
//! [`target`] is an alias of one of the other ABIs and represents the target
//! platform. Unlike [`native`], this does not necessarily use native Rust
//! data-types, but is a real alias to one of the other fixed definitions of
//! platform ABIs.
Expand Down Expand Up @@ -44,7 +44,8 @@ type Le<Native, Alignment> = crate::ffi::Integer<

// This module is imported by all ABIs and provides default symbols valid on
// all targets.
mod shared {
#[doc(hidden)]
pub mod shared {
/// Creates a number by converting the input value from native
/// representation into the representation of the target type.
///
Expand Down Expand Up @@ -96,6 +97,36 @@ pub mod native {
pub use super::shared::*;
}

/// # System-V aarch64 ABI
///
/// This ABI represents the 64-bit ABI of System-V for aarch64 systems. It is
/// used by most UNIX compatible systems, including Linux.
pub mod aarch64_sysv {
use crate::align;

pub type I8 = super::Le<i8, align::AlignAs<1>>;
pub type I16 = super::Le<i16, align::AlignAs<2>>;
pub type I32 = super::Le<i32, align::AlignAs<4>>;
pub type I64 = super::Le<i64, align::AlignAs<8>>;
pub type I128 = super::Le<i128, align::AlignAs<16>>;
pub type Isize = super::Le<i64, align::AlignAs<8>>;

pub type U8 = super::Le<u8, align::AlignAs<1>>;
pub type U16 = super::Le<u16, align::AlignAs<2>>;
pub type U32 = super::Le<u32, align::AlignAs<4>>;
pub type U64 = super::Le<u64, align::AlignAs<8>>;
pub type U128 = super::Le<u128, align::AlignAs<16>>;
pub type Usize = super::Le<u64, align::AlignAs<8>>;

pub type F32 = super::Le<f32, align::AlignAs<4>>;
pub type F64 = super::Le<f64, align::AlignAs<8>>;

pub type Addr = super::Le<core::num::NonZeroU64, align::AlignAs<8>>;
pub type Ptr<Target> = crate::ffi::Pointer<Addr, Target>;

pub use super::shared::*;
}

/// # System-V x86 ABI
///
/// This ABI represents the 32-bit ABI of System-V for x86 systems. It is used
Expand All @@ -107,14 +138,14 @@ pub mod x86_sysv {
pub type I16 = super::Le<i16, align::AlignAs<2>>;
pub type I32 = super::Le<i32, align::AlignAs<4>>;
pub type I64 = super::Le<i64, align::AlignAs<4>>;
pub type I128 = super::Le<i128, align::AlignAs<4>>;
pub type I128 = super::Le<i128, align::AlignAs<16>>;
pub type Isize = super::Le<i32, align::AlignAs<4>>;

pub type U8 = super::Le<u8, align::AlignAs<1>>;
pub type U16 = super::Le<u16, align::AlignAs<2>>;
pub type U32 = super::Le<u32, align::AlignAs<4>>;
pub type U64 = super::Le<u64, align::AlignAs<4>>;
pub type U128 = super::Le<u128, align::AlignAs<4>>;
pub type U128 = super::Le<u128, align::AlignAs<16>>;
pub type Usize = super::Le<u32, align::AlignAs<4>>;

pub type F32 = super::Le<f32, align::AlignAs<4>>;
Expand Down Expand Up @@ -156,28 +187,34 @@ pub mod x86_64_sysv {
pub use super::shared::*;
}

#[cfg(all(
target_arch = "aarch64",
target_family = "unix",
))]
pub use aarch64_sysv as target;

#[cfg(all(
target_arch = "x86",
target_family = "unix",
))]
pub use x86_sysv as auto;
pub use x86_sysv as target;

#[cfg(all(
target_arch = "x86_64",
target_family = "unix",
))]
pub use x86_64_sysv as auto;
pub use x86_64_sysv as target;

#[cfg(all(
target_arch = "x86",
target_env = "msvc",
target_family = "windows",
))]
pub use x86_win as auto;
pub use x86_win as target;

#[cfg(all(
target_arch = "x86_64",
target_env = "msvc",
target_family = "windows",
))]
pub use x86_64_win as auto;
pub use x86_64_win as target;
4 changes: 4 additions & 0 deletions lib/osi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
// if the self-type was shown, or there was another way to quickly jump to
// it via an anchor.
//
// - rustdoc pub-use: There is currently no way to document `pub use`
// statements. Given how FFI modules in `sys` export aliases, documenting
// those would be great.
//
// - rustfmt optout: There is no global opt-out for rustfmt. While individual
// items can be annotated with `#[rustfmt::skip]`, the root module of a
// crate cannot be annotated like this (NB: inner attributes like
Expand Down
22 changes: 10 additions & 12 deletions lib/osi/src/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub const unsafe fn bswap_copy<T>(v: &T) -> T {
}
}

/// Alias a type as a [`MaybeUninit`](core::mem::MaybeUninit).
/// Alias a type as a [`Uninit`].
///
/// Any type can be aliased as a possibly uninitialized type. This is usually
/// only necessary when providing initialized data to code that can handle
Expand All @@ -171,7 +171,7 @@ pub const fn as_uninit<T>(v: &T) -> &Uninit<T> {
}
}

/// Alias a slice as a [`MaybeUninit`](core::mem::MaybeUninit).
/// Alias a slice as a [`Uninit`].
///
/// This works like [`as_uninit()`] but for slices of `T`.
pub const fn slice_as_uninit<T>(v: &[T]) -> &[Uninit<T>] {
Expand All @@ -180,11 +180,11 @@ pub const fn slice_as_uninit<T>(v: &[T]) -> &[Uninit<T>] {
}
}

/// Alias a [`MaybeUninit`](core::mem::MaybeUninit) type as initialized.
/// Alias a [`Uninit`] type as initialized.
///
/// ## Safety
///
/// It is up to the caller to guarantee that the [`MaybeUninit<T>`] really is
/// It is up to the caller to guarantee that the [`Uninit<T>`] really is
/// in an initialized state. Calling this when the content is not yet fully
/// initialized causes immediate undefined behavior.
pub const unsafe fn assume_init<T>(v: &Uninit<T>) -> &T {
Expand All @@ -193,12 +193,11 @@ pub const unsafe fn assume_init<T>(v: &Uninit<T>) -> &T {
}
}

/// Mutably alias a [`MaybeUninit`](core::mem::MaybeUninit) type as
/// initialized.
/// Mutably alias a [`Uninit`] type as initialized.
///
/// ## Safety
///
/// It is up to the caller to guarantee that the [`MaybeUninit<T>`] really is
/// It is up to the caller to guarantee that the [`Uninit<T>`] really is
/// in an initialized state. Calling this when the content is not yet fully
/// initialized causes immediate undefined behavior.
pub const unsafe fn assume_init_mut<T>(v: &mut Uninit<T>) -> &mut T {
Expand All @@ -207,11 +206,11 @@ pub const unsafe fn assume_init_mut<T>(v: &mut Uninit<T>) -> &mut T {
}
}

/// Alias a slice of [`MaybeUninit`](core::mem::MaybeUninit) as initialized.
/// Alias a slice of [`Uninit`] as initialized.
///
/// ## Safety
///
/// It is up to the caller to guarantee that the [`MaybeUninit<T>`] really is
/// It is up to the caller to guarantee that the [`Uninit<T>`] really is
/// in an initialized state. Calling this when the content is not yet fully
/// initialized causes immediate undefined behavior.
pub const unsafe fn slice_assume_init<T>(v: &[Uninit<T>]) -> &[T] {
Expand All @@ -220,12 +219,11 @@ pub const unsafe fn slice_assume_init<T>(v: &[Uninit<T>]) -> &[T] {
}
}

/// Mutably alias a slice of [`MaybeUninit`](core::mem::MaybeUninit) as
/// initialized.
/// Mutably alias a slice of [`Uninit`] as initialized.
///
/// ## Safety
///
/// It is up to the caller to guarantee that the [`MaybeUninit<T>`] really is
/// It is up to the caller to guarantee that the [`Uninit<T>`] really is
/// in an initialized state. Calling this when the content is not yet fully
/// initialized causes immediate undefined behavior.
pub const unsafe fn slice_assume_init_mut<T>(v: &mut [Uninit<T>]) -> &mut [T] {
Expand Down
3 changes: 1 addition & 2 deletions lib/osi/src/mown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
/// ## Similarity to Cow
///
/// This type is almost identical to [`Cow`](alloc::borrow::Cow), but does not
/// require [`Clone`](core::clone::Clone) or any kind of support for
/// mutability.
/// require [`Clone`] or any kind of support for mutability.
pub enum Mown<'a, B: ?Sized, O = &'a B> {
Borrowed(&'a B),
Owned(O),
Expand Down
49 changes: 0 additions & 49 deletions lib/sys/src/ffi.rs

This file was deleted.

Loading
Loading