Repository navigation
[PAC] Minicore updates for pointer authentication tests (1/6) #159086
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -165,6 +165,8 @@ pub mod arch { | |
| pub struct PhantomData<T: PointeeSized>; | ||
| impl<T: PointeeSized> Copy for PhantomData<T> {} | ||
|
|
||
| #[rustc_diagnostic_item = "Option"] | ||
| #[lang = "Option"] | ||
| pub enum Option<T> { | ||
| None, | ||
| Some(T), | ||
|
|
@@ -302,11 +304,18 @@ pub trait Add<Rhs = Self> { | |
| fn add(self, _: Rhs) -> Self::Output; | ||
| } | ||
|
|
||
| // Avoid needing to add all of the overflow handling and panic language items | ||
| impl Add<isize> for isize { | ||
| type Output = isize; | ||
|
|
||
| fn add(self, other: isize) -> isize { | ||
| 7 // avoid needing to add all of the overflow handling and panic language items | ||
| 7 | ||
| } | ||
| } | ||
| impl Add for i32 { | ||
| type Output = i32; | ||
| fn add(self, rhs: i32) -> i32 { | ||
| 7 | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -353,18 +362,30 @@ impl_marker_trait!( | |
| ); | ||
|
|
||
| impl Sync for () {} | ||
|
|
||
| impl<T, const N: usize> Sync for [T; N] {} | ||
| impl<T: Sync> Sync for Option<T> {} | ||
| impl<T: ?Sized + Sync> Sync for &T {} | ||
|
|
||
| // Function pointers are treated as `Sync` to match real `core` behavior. | ||
| // | ||
| // Minicore provides only the minimal set of impls required by tests. Rather | ||
| // than exhaustively covering all possible function pointer signatures, | ||
| // additional impls should be added as needed. | ||
| impl<R> Sync for fn() -> R {} | ||
| impl<R> Sync for extern "C" fn() -> R {} | ||
| impl<R> Sync for unsafe extern "C" fn() -> R {} | ||
| impl<A, R> Sync for extern "C" fn(A) -> R {} | ||
| impl<A, R> Sync for unsafe extern "C" fn(A) -> R {} | ||
| // additional arities should be added as needed. | ||
| macro_rules! impl_sync_for_fn_ptrs { | ||
| ($(($($T:ident),*)),* $(,)?) => { | ||
| $( | ||
| impl<$($T,)* R> Sync for fn($($T),*) -> R {} | ||
|
|
||
| impl<$($T,)* R> Sync for extern "C" fn($($T),*) -> R {} | ||
| impl<$($T,)* R> Sync for unsafe extern "C" fn($($T),*) -> R {} | ||
|
|
||
| impl<$($T,)* R> Sync for extern "C" fn($($T,)* ...) -> R {} | ||
| impl<$($T,)* R> Sync for unsafe extern "C" fn($($T,)* ...) -> R {} | ||
| )* | ||
| }; | ||
| } | ||
|
|
||
| impl_sync_for_fn_ptrs!((), (A), (A, B), (A, B, C), (A, B, C, D),); | ||
|
|
||
| #[lang = "drop_glue"] | ||
| fn drop_glue<T>(_: &mut T) {} | ||
|
|
@@ -401,7 +422,7 @@ pub trait CoerceUnsized<T: PointeeSized> {} | |
| impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a U> for &'b T {} | ||
|
|
||
| #[lang = "drop"] | ||
| trait Drop { | ||
| pub trait Drop { | ||
| fn drop(&mut self); | ||
| } | ||
|
|
||
|
|
@@ -458,6 +479,15 @@ pub mod ptr { | |
|
|
||
| unsafe { volatile_store(dst, src) }; | ||
| } | ||
|
|
||
| #[inline] | ||
| #[rustc_diagnostic_item = "ptr_read_volatile"] | ||
| pub unsafe fn read_volatile<T>(src: *const T) -> T { | ||
| #[rustc_intrinsic] | ||
| pub unsafe fn volatile_load<T>(src: *const T) -> T; | ||
|
|
||
| unsafe { volatile_load(src) } | ||
| } | ||
| } | ||
|
|
||
| pub mod hint { | ||
|
|
@@ -518,9 +548,10 @@ pub mod num { | |
|
|
||
| #[lang = "c_void"] | ||
| #[repr(u8)] | ||
| #[allow(non_camel_case_types)] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need this change? I see
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without it tidy would fail (and it is run as part of PR CI tests). |
||
| pub enum c_void { | ||
| __variant1, | ||
| __variant2, | ||
| Variant1, | ||
| Variant2, | ||
| } | ||
|
|
||
| #[allow_internal_unstable(internal_syntax)] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I failed to find direct uses of
Addtrait oraddfunction in tests. Could you please explain why we need this new implementation for i32 here?View changes since the review
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because
+operator is resolved toAdd, so without the code above this will fail to compile for minicore: