Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v32.1.1-rc3 #84

Merged
merged 1 commit into from
Jul 5, 2024
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 36.1.1-rc3 (api=2.0.0, abi=2.0.0)
- Allow structures to compute their single-niche evaluation properly.

# 36.1.1-rc2 (api=2.0.0, abi=2.0.0)
- Add the `#[stabby::vt_attr(_)]` sub-attribute to `#[stabby::stabby]` on traits, letting you place custom attributes on the v-tables generated for a trait.
- Add support for `core::ffi::c_void`.
Expand Down
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ license = " EPL-2.0 OR Apache-2.0"
categories = ["development-tools::ffi", "no-std::no-alloc"]
repository = "https://github.com/ZettaScaleLabs/stabby"
readme = "stabby/README.md"
version = "36.1.1-rc2" # Track
version = "36.1.1-rc3" # Track

[workspace.dependencies]
stabby-macros = { path = "./stabby-macros/", version = "36.1.1-rc2", default-features = false } # Track
stabby-abi = { path = "./stabby-abi/", version = "36.1.1-rc2", default-features = false } # Track
stabby = { path = "./stabby/", version = "36.1.1-rc2", default-features = false } # Track
stabby-macros = { path = "./stabby-macros/", version = "36.1.1-rc3", default-features = false } # Track
stabby-abi = { path = "./stabby-abi/", version = "36.1.1-rc3", default-features = false } # Track
stabby = { path = "./stabby/", version = "36.1.1-rc3", default-features = false } # Track

abi_stable = "0.11.0"
libc = "0.2"
Expand Down
16 changes: 12 additions & 4 deletions stabby-abi/src/istable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,9 +385,13 @@ unsafe impl<A: IStable, B: IStable> IStable for FieldPair<A, B> {
<A::UnusedBits as IBitMask>::BitOr<<AlignedAfter<B, A::Size> as IStable>::UnusedBits>;
type Size = <AlignedAfter<B, A::Size> as IStable>::Size;
type Align = <A::Align as Alignment>::Max<B::Align>;
type HasExactlyOneNiche = <A::HasExactlyOneNiche as ISaturatingAdd>::SaturatingAdd<
<AlignedAfter<B, A::Size> as IStable>::HasExactlyOneNiche,
>;
type HasExactlyOneNiche =
<<Self::Size as Unsigned>::Equal<<A::Size as Unsigned>::Add<B::Size>> as Bit>::SaddTernary<
<A::HasExactlyOneNiche as ISaturatingAdd>::SaturatingAdd<
<AlignedAfter<B, A::Size> as IStable>::HasExactlyOneNiche,
>,
Saturator,
>;
type ContainsIndirections = <A::ContainsIndirections as Bit>::Or<B::ContainsIndirections>;
#[cfg(feature = "experimental-ctypes")]
type CType = ();
Expand Down Expand Up @@ -426,6 +430,7 @@ impl ISaturatingAdd for Saturator {
type SaturatingAddB1 = Saturator;
type SaturatingAdd<B: ISaturatingAdd> = Saturator;
}
#[derive(Default)]
/// An Exception-like value that indicates a computation can never succeed.
pub struct Saturator;

Expand Down Expand Up @@ -553,7 +558,10 @@ unsafe impl<T: IStable> IStable for Struct<T> {
type ForbiddenValues = T::ForbiddenValues;
type UnusedBits = <T::UnusedBits as IBitMask>::BitOr<
<<tyeval!(<T::Size as Unsigned>::NextMultipleOf<T::Align> - T::Size) as IUnsignedBase>::PaddingBitMask as IBitMask>::Shift<T::Size>>;
type HasExactlyOneNiche = Saturator;
type HasExactlyOneNiche = <<T::Size as Unsigned>::Equal<Self::Size> as Bit>::SaddTernary<
T::HasExactlyOneNiche,
Saturator,
>;
type ContainsIndirections = T::ContainsIndirections;
#[cfg(feature = "experimental-ctypes")]
type CType = ();
Expand Down
30 changes: 23 additions & 7 deletions stabby/src/tests/layouts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use core::num::{NonZeroU16, NonZeroU32, NonZeroU8};

use crate as stabby;
use stabby::tuple::{Tuple2, Tuple3, Tuple8};
use stabby_abi::{typenum2::*, Array, End, Result};
use stabby_abi::{istable::Saturator, typenum2::*, Array, End, IStable, Result};

#[stabby::stabby]
pub union UTest {
pub union UnionTest {
u8: u8,
usize: usize,
u64: u64,
}
#[stabby::stabby]
pub union UTest2 {
Expand Down Expand Up @@ -88,23 +88,23 @@ pub enum SameFieldsFourTimes<T> {
pub struct WeirdStructBadLayout {
fields: FieldsC,
no_fields: NoFields,
utest: UTest,
utest: UnionTest,
u32: u32,
}

#[stabby::stabby]
pub struct WeirdStructBadLayout2 {
fields: FieldsC,
no_fields: NoFields,
utest: UTest,
utest: UnionTest,
}

#[stabby::stabby]
pub struct WeirdStruct {
fields: FieldsC,
no_fields: NoFields,
u32: u32,
utest: UTest,
utest: UnionTest,
}

#[stabby::stabby]
Expand All @@ -117,9 +117,25 @@ pub struct Test {
a: u32,
}

#[stabby::stabby]
pub struct SingleNiche {
a: usize,
b: &'static u8,
}
#[stabby::stabby]
pub struct EndPadding {
a: usize,
b: u8,
}

#[test]
fn layouts() {
use stabby::abi::istable::IForbiddenValues;
let _: B1 = <<SingleNiche as IStable>::HasExactlyOneNiche>::default();
let _: Saturator = <<EndPadding as IStable>::HasExactlyOneNiche>::default();
let _: B0 = <<Tuple3<u32, u32, u32> as IStable>::HasExactlyOneNiche>::default();
let _: Saturator = <<Tuple2<u8, u32> as IStable>::HasExactlyOneNiche>::default();
let _: Saturator = <<Test as IStable>::HasExactlyOneNiche>::default();
macro_rules! test {
() => {};
($t: ty, $unused: ty, $illegal: ty) => {
Expand Down Expand Up @@ -199,7 +215,7 @@ fn layouts() {
test!(stabby::abi::Union<u8, ()>, End, End);
test!(stabby::abi::Union<(), u8>, End, End);
test!(stabby::result::Result<(), ()>, Array<U0, Ub11111110, End>, End);
test!(UTest, End, End);
test!(UnionTest, End, End);
test!(FieldsC, Array<U1, UxFF, Array<U2, UxFF, Array<U3, UxFF, End>>>, End);
test!(FieldsStabby, End, End);
test!(MultiFieldsC, Array<U1, UxFF, End>, End);
Expand Down
Loading