mirror of
https://github.com/nxp-imx/linux-imx.git
synced 2025-07-06 09:25:22 +02:00

This reverts the following commits:0347be8c14
ANDROID: rust: disable floating point target features013c5ddc64
ANDROID: rust_binder: fix leak of name in binderfs2f4e6b1def
ANDROID: Disable warning about new bindgen3396c2131d
ANDROID: rust: use target.json for aarch641656e8d99d
ANDROID: rust: rustfmt scripts/generate_rust_target.rs42eb612b25
ANDROID: Enable Rust Binder Modulecb0bef6d8e
ANDROID: rust_binder: Switch Rust Binder to GKI Moduleb511e79bc5
ANDROID: Only warn on long symbols4a571c32cb
ANDROID: Re-enable Rust symbol export08dde7cab7
ANDROID: rust_binder: properly handle critical refcount increments39285e9a6e
ANDROID: rust_binder: split out logic for zero-to-one refcount increment76784ba7b8
ANDROID: rust_binder: don't use boolean to schedule nodes64018a934a
ANDROID: rust_binder: don't pr_warn on benign errors9ff51354fd
ANDROID: use 1.73.0b compiler prebuilted1360bdfa
ANDROID: rust_binder: fix CFI failure in rust_shrink_free_page741b6ae073
ANDROID: rust_binder: don't use default implementationsbee37573f9
ANDROID: rust_binder: add missing void arguments to binderfs files8ae6dec97f
ANDROID: rust_binder: fix ioctl_freezec9370a3cbb
ANDROID: rust_binder: return pending info for frozen async txnsf6d2f5ebcb
ANDROID: rust_binder: various minor improvementsd27c2c39fd
ANDROID: rust_binder: add elapsed to binder_logs/state9ef1712688
FROMLIST: rust: time: add Ktime306e7bafe8
FROMLIST: rust: don't select CONSTRUCTORS5424a7cb43
FROMLIST: rust: add flags for shadow call stack sanitizerc42560464f
ANDROID: binder: update Kconfig for choosing between implementations87f0a459c0
ANDROID: rust: uaccess: fix length usage in read_allc6c6be80a8
ANDROID: rust: use Rust atomics for Arc refcount282b78baf0
ANDROID: rust_binder: choose driver with kcmdline flag01ac18bd09
ANDROID: rust_binder: add binder_logs/stateec1855352b
ANDROID: rust_binder: fail if objects are out of orderac68e23d38
ANDROID: rust_binder: add vma shrinker2e4f09314c
ANDROID: rust_binder: add priority inheritance691f0f1682
ANDROID: rust_binder: add oneway spam detection6249f06992
ANDROID: rust_binder: add TF_UPDATE_TXN support50259804b1
ANDROID: rust_binder: add process freezing571343fd97
ANDROID: rust_binder: add BINDER_TYPE_FDA supportb427bc70cf
ANDROID: rust_binder: add BINDER_TYPE_FD support451e930fc0
ANDROID: rust_binder: add BINDER_TYPE_PTR supportae1d247379
ANDROID: rust_binder: send nodes in transactions892df033dc
ANDROID: rust_binder: add death notificationsfe5dea5fc7
ANDROID: rust_binder: serialize oneway transactionsb67f39008f
ANDROID: rust_binder: add non-oneway transactions98cf4f1b76
ANDROID: rust_binder: add epoll supportbb1d504151
ANDROID: rust_binder: add oneway transactions0ccb57c72d
ANDROID: rust_binder: add nodes and context managers6feafb413a
ANDROID: rust_binder: add work lists046eb3d735
ANDROID: rust_binder: add threading support0d512d37b0
ANDROID: rust_binder: add binderfs support to Rust binderadfa541d88
ANDROID: rust_binder: define a Rust binder driverb1661c9e45
ANDROID: rust: add linked list implementationec656ad4c9
ANDROID: rust: sync: add `Arc::into_unique_or_drop`b57704d237
ANDROID: rust: sync: add `ArcBorrow::from_raw`a1bb998934
ANDROID: rust: mm: add bindings for memory management67fe8ee749
FROMLIST: rust: add abstraction for `struct page`6896fba16f
FROMLIST: rust: uaccess: add typed accessors for userspace pointers881c1e2f85
FROMLIST: uaccess: always export _copy_[from|to]_user with CONFIG_RUST3629eb70a6
FROMLIST: rust: uaccess: add userspace pointers84e0b6c8ef
FROMLIST: rust: rbtree: add `RBTree::entry`c226168bb5
FROMLIST: rust: rbtree: add `RBTreeCursor`a3e1a10677
FROMLIST: rust: rbtree: add `RBTreeIteratorMut`97cbf6e271
FROMLIST: rust: rbtree: add `RBTreeIterator`adfa8383a5
FROMLIST: rust: rbtree: add red-black tree implementation backed by the C version4cb6d81d02
FROMLIST: rust: add `container_of!` macro879f437248
FROMLIST: rust: file: add abstraction for `poll_table`4aa358bcc5
FROMLIST: rust: file: add `DeferredFdCloser`8abb138ec8
FROMLIST: rust: file: add `Kuid` wrapperf764ce9b2b
FROMLIST: rust: file: add `FileDescriptorReservation`a34dbbde7c
FROMLIST: rust: security: add abstraction for secctxc0b96a7765
FROMLIST: rust: cred: add Rust abstraction for `struct cred`40eecc8bdf
FROMLIST: rust: file: add Rust abstraction for `struct file`c8ae5646c9
FROMLIST: rust: task: add `Task::current_raw`6b4006d2d7
FROMLIST: rust: types: add `NotThreadSafe`6bb35a6e52
FROMGIT: rust: sync: update integer types in CondVarbd6e290154
FROMGIT: rust: sync: add `CondVar::wait_timeout`117298b362
FROMGIT: rust: time: add msecs to jiffies conversiond6ce2b7bd7
FROMGIT: rust: sync: add `CondVar::notify_sync`495235c0f3
FROMGIT: rust: sync: `CondVar` rename "wait_list" to "wait_queue_head"4c5e3e9f01
UPSTREAM: binder: use enum for binder ioctlsfbb9dbf62c
UPSTREAM: rust: support `srctree`-relative links0f40dd3c65
UPSTREAM: rust: sync: Makes `CondVar::wait()` an uninterruptible wait5e2edfbc03
UPSTREAM: rust: macros: improve `#[vtable]` documentation8bd5093c30
UPSTREAM: rust: macros: update 'paste!' macro to accept string literals63a42cf758
UPSTREAM: rust: bindings: rename const binding using sed412965714b
UPSTREAM: rust: replace <linux/module.h> with <linux/export.h> in rust/exports.c1765f2a273
UPSTREAM: rust: kernel: str: Implement Debug for CStringfe69811059
UPSTREAM: rust: task: remove redundant explicit linkf2497a4bb0
UPSTREAM: rust: kernel: remove `#[allow(clippy::new_ret_no_self)]`a6ab1c4b59
UPSTREAM: rust: workqueue: add examples3525914f07
UPSTREAM: rust: workqueue: add `try_spawn` helper method7b431db132
UPSTREAM: rust: workqueue: implement `WorkItemPointer` for pointer typesc5e9e92b74
UPSTREAM: rust: workqueue: add helper for defining work_struct fieldsfef46ccba9
UPSTREAM: rust: workqueue: define built-in queues37fe02321c
UPSTREAM: rust: workqueue: add low-level workqueue bindingsa0c639eadc
UPSTREAM: rust: sync: add `Arc::{from_raw, into_raw}`37e90c8aef
ANDROID: rust: Enable KCFI support when available6be7b55440
ANDROID: rust: Use From instances for JSON encoder2b93c38ece
ANDROID: rust: Support arrays in target JSON4085063afb
ANDROID: rust: allow MODVERSIONS by no longer exporting symbolse019515a16
ANDROID: rust: Select rustc-1.73.0ae876716fc
FROMLIST: x86: rust: Disable entry padding with Rustb802a765fb
FROMLIST: arm64: rust: Enable Rust support for AArch64433a394399
FROMLIST: rust: Refactor the build target to allow the use of builtin targets5eb6b43401
UPSTREAM: rust: Suppress searching builtin sysroot9b8f3fdda6
UPSTREAM: rust: Ignore preserve-most functions5341e12502
UPSTREAM: x86: Enable IBT in Rust if enabled in C37481c8f5a
UPSTREAM: rust: upgrade to Rust 1.73.042092eccd9
UPSTREAM: rust: upgrade to Rust 1.72.130043aaafb
UPSTREAM: rust: arc: add explicit `drop()` around `Box::from_raw()`3365cb02fe
UPSTREAM: rust: Use grep -Ev rather than relying on GNU grep5dd966b03a
UPSTREAM: rust: Use awk instead of recent xargs8a38f60333
UPSTREAM: rust: Respect HOSTCC when linking for host Fixes:adfa541d88
("ANDROID: rust_binder: define a Rust binder driver") Change-Id: Id70e8c42c0b2b31753998c9b5d12e5c449aeafd7 Signed-off-by: Alice Ryhl <aliceryhl@google.com>
287 lines
9.3 KiB
Rust
287 lines
9.3 KiB
Rust
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
||
|
||
//! # The Rust core allocation and collections library
|
||
//!
|
||
//! This library provides smart pointers and collections for managing
|
||
//! heap-allocated values.
|
||
//!
|
||
//! This library, like core, normally doesn’t need to be used directly
|
||
//! since its contents are re-exported in the [`std` crate](../std/index.html).
|
||
//! Crates that use the `#![no_std]` attribute however will typically
|
||
//! not depend on `std`, so they’d use this crate instead.
|
||
//!
|
||
//! ## Boxed values
|
||
//!
|
||
//! The [`Box`] type is a smart pointer type. There can only be one owner of a
|
||
//! [`Box`], and the owner can decide to mutate the contents, which live on the
|
||
//! heap.
|
||
//!
|
||
//! This type can be sent among threads efficiently as the size of a `Box` value
|
||
//! is the same as that of a pointer. Tree-like data structures are often built
|
||
//! with boxes because each node often has only one owner, the parent.
|
||
//!
|
||
//! ## Reference counted pointers
|
||
//!
|
||
//! The [`Rc`] type is a non-threadsafe reference-counted pointer type intended
|
||
//! for sharing memory within a thread. An [`Rc`] pointer wraps a type, `T`, and
|
||
//! only allows access to `&T`, a shared reference.
|
||
//!
|
||
//! This type is useful when inherited mutability (such as using [`Box`]) is too
|
||
//! constraining for an application, and is often paired with the [`Cell`] or
|
||
//! [`RefCell`] types in order to allow mutation.
|
||
//!
|
||
//! ## Atomically reference counted pointers
|
||
//!
|
||
//! The [`Arc`] type is the threadsafe equivalent of the [`Rc`] type. It
|
||
//! provides all the same functionality of [`Rc`], except it requires that the
|
||
//! contained type `T` is shareable. Additionally, [`Arc<T>`][`Arc`] is itself
|
||
//! sendable while [`Rc<T>`][`Rc`] is not.
|
||
//!
|
||
//! This type allows for shared access to the contained data, and is often
|
||
//! paired with synchronization primitives such as mutexes to allow mutation of
|
||
//! shared resources.
|
||
//!
|
||
//! ## Collections
|
||
//!
|
||
//! Implementations of the most common general purpose data structures are
|
||
//! defined in this library. They are re-exported through the
|
||
//! [standard collections library](../std/collections/index.html).
|
||
//!
|
||
//! ## Heap interfaces
|
||
//!
|
||
//! The [`alloc`](alloc/index.html) module defines the low-level interface to the
|
||
//! default global allocator. It is not compatible with the libc allocator API.
|
||
//!
|
||
//! [`Arc`]: sync
|
||
//! [`Box`]: boxed
|
||
//! [`Cell`]: core::cell
|
||
//! [`Rc`]: rc
|
||
//! [`RefCell`]: core::cell
|
||
|
||
#![allow(unused_attributes)]
|
||
#![stable(feature = "alloc", since = "1.36.0")]
|
||
#![doc(
|
||
html_playground_url = "https://play.rust-lang.org/",
|
||
issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
|
||
test(no_crate_inject, attr(allow(unused_variables), deny(warnings)))
|
||
)]
|
||
#![doc(cfg_hide(
|
||
not(test),
|
||
not(any(test, bootstrap)),
|
||
any(not(feature = "miri-test-libstd"), test, doctest),
|
||
no_global_oom_handling,
|
||
not(no_global_oom_handling),
|
||
not(no_rc),
|
||
not(no_sync),
|
||
target_has_atomic = "ptr"
|
||
))]
|
||
#![no_std]
|
||
#![needs_allocator]
|
||
// To run alloc tests without x.py without ending up with two copies of alloc, Miri needs to be
|
||
// able to "empty" this crate. See <https://github.com/rust-lang/miri-test-libstd/issues/4>.
|
||
// rustc itself never sets the feature, so this line has no affect there.
|
||
#![cfg(any(not(feature = "miri-test-libstd"), test, doctest))]
|
||
//
|
||
// Lints:
|
||
#![deny(unsafe_op_in_unsafe_fn)]
|
||
#![deny(fuzzy_provenance_casts)]
|
||
#![warn(deprecated_in_future)]
|
||
#![warn(missing_debug_implementations)]
|
||
#![warn(missing_docs)]
|
||
#![allow(explicit_outlives_requirements)]
|
||
#![warn(multiple_supertrait_upcastable)]
|
||
//
|
||
// Library features:
|
||
// tidy-alphabetical-start
|
||
#![cfg_attr(not(no_global_oom_handling), feature(const_alloc_error))]
|
||
#![cfg_attr(not(no_global_oom_handling), feature(const_btree_len))]
|
||
#![cfg_attr(test, feature(is_sorted))]
|
||
#![cfg_attr(test, feature(new_uninit))]
|
||
#![feature(alloc_layout_extra)]
|
||
#![feature(allocator_api)]
|
||
#![feature(array_chunks)]
|
||
#![feature(array_into_iter_constructors)]
|
||
#![feature(array_methods)]
|
||
#![feature(array_windows)]
|
||
#![feature(ascii_char)]
|
||
#![feature(assert_matches)]
|
||
#![feature(async_iterator)]
|
||
#![feature(coerce_unsized)]
|
||
#![feature(const_align_of_val)]
|
||
#![feature(const_box)]
|
||
#![cfg_attr(not(no_borrow), feature(const_cow_is_borrowed))]
|
||
#![feature(const_eval_select)]
|
||
#![feature(const_maybe_uninit_as_mut_ptr)]
|
||
#![feature(const_maybe_uninit_write)]
|
||
#![feature(const_maybe_uninit_zeroed)]
|
||
#![feature(const_pin)]
|
||
#![feature(const_refs_to_cell)]
|
||
#![feature(const_size_of_val)]
|
||
#![feature(const_waker)]
|
||
#![feature(core_intrinsics)]
|
||
#![feature(core_panic)]
|
||
#![feature(dispatch_from_dyn)]
|
||
#![feature(error_generic_member_access)]
|
||
#![feature(error_in_core)]
|
||
#![feature(exact_size_is_empty)]
|
||
#![feature(extend_one)]
|
||
#![feature(fmt_internals)]
|
||
#![feature(fn_traits)]
|
||
#![feature(hasher_prefixfree_extras)]
|
||
#![feature(inline_const)]
|
||
#![feature(inplace_iteration)]
|
||
#![feature(iter_advance_by)]
|
||
#![feature(iter_next_chunk)]
|
||
#![feature(iter_repeat_n)]
|
||
#![feature(layout_for_ptr)]
|
||
#![feature(maybe_uninit_slice)]
|
||
#![feature(maybe_uninit_uninit_array)]
|
||
#![feature(maybe_uninit_uninit_array_transpose)]
|
||
#![feature(pattern)]
|
||
#![feature(pointer_byte_offsets)]
|
||
#![feature(provide_any)]
|
||
#![feature(ptr_internals)]
|
||
#![feature(ptr_metadata)]
|
||
#![feature(ptr_sub_ptr)]
|
||
#![feature(receiver_trait)]
|
||
#![feature(saturating_int_impl)]
|
||
#![feature(set_ptr_value)]
|
||
#![feature(sized_type_properties)]
|
||
#![feature(slice_from_ptr_range)]
|
||
#![feature(slice_group_by)]
|
||
#![feature(slice_ptr_get)]
|
||
#![feature(slice_ptr_len)]
|
||
#![feature(slice_range)]
|
||
#![feature(std_internals)]
|
||
#![feature(str_internals)]
|
||
#![feature(strict_provenance)]
|
||
#![feature(trusted_len)]
|
||
#![feature(trusted_random_access)]
|
||
#![feature(try_trait_v2)]
|
||
#![feature(tuple_trait)]
|
||
#![feature(unchecked_math)]
|
||
#![feature(unicode_internals)]
|
||
#![feature(unsize)]
|
||
#![feature(utf8_chunks)]
|
||
// tidy-alphabetical-end
|
||
//
|
||
// Language features:
|
||
// tidy-alphabetical-start
|
||
#![cfg_attr(not(test), feature(generator_trait))]
|
||
#![cfg_attr(test, feature(panic_update_hook))]
|
||
#![cfg_attr(test, feature(test))]
|
||
#![feature(allocator_internals)]
|
||
#![feature(allow_internal_unstable)]
|
||
#![feature(associated_type_bounds)]
|
||
#![feature(c_unwind)]
|
||
#![feature(cfg_sanitize)]
|
||
#![feature(const_mut_refs)]
|
||
#![feature(const_precise_live_drops)]
|
||
#![feature(const_ptr_write)]
|
||
#![feature(const_trait_impl)]
|
||
#![feature(const_try)]
|
||
#![feature(dropck_eyepatch)]
|
||
#![feature(exclusive_range_pattern)]
|
||
#![feature(fundamental)]
|
||
#![feature(hashmap_internals)]
|
||
#![feature(lang_items)]
|
||
#![feature(min_specialization)]
|
||
#![feature(multiple_supertrait_upcastable)]
|
||
#![feature(negative_impls)]
|
||
#![feature(never_type)]
|
||
#![feature(pointer_is_aligned)]
|
||
#![feature(rustc_allow_const_fn_unstable)]
|
||
#![feature(rustc_attrs)]
|
||
#![feature(slice_internals)]
|
||
#![feature(staged_api)]
|
||
#![feature(stmt_expr_attributes)]
|
||
#![feature(unboxed_closures)]
|
||
#![feature(unsized_fn_params)]
|
||
#![feature(with_negative_coherence)]
|
||
// tidy-alphabetical-end
|
||
//
|
||
// Rustdoc features:
|
||
#![feature(doc_cfg)]
|
||
#![feature(doc_cfg_hide)]
|
||
// Technically, this is a bug in rustdoc: rustdoc sees the documentation on `#[lang = slice_alloc]`
|
||
// blocks is for `&[T]`, which also has documentation using this feature in `core`, and gets mad
|
||
// that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs
|
||
// from other crates, but since this can only appear for lang items, it doesn't seem worth fixing.
|
||
#![feature(intra_doc_pointers)]
|
||
|
||
// Allow testing this library
|
||
#[cfg(test)]
|
||
#[macro_use]
|
||
extern crate std;
|
||
#[cfg(test)]
|
||
extern crate test;
|
||
#[cfg(test)]
|
||
mod testing;
|
||
|
||
// Module with internal macros used by other modules (needs to be included before other modules).
|
||
#[cfg(not(no_macros))]
|
||
#[macro_use]
|
||
mod macros;
|
||
|
||
mod raw_vec;
|
||
|
||
// Heaps provided for low-level allocation strategies
|
||
|
||
pub mod alloc;
|
||
|
||
// Primitive types using the heaps above
|
||
|
||
// Need to conditionally define the mod from `boxed.rs` to avoid
|
||
// duplicating the lang-items when building in test cfg; but also need
|
||
// to allow code to have `use boxed::Box;` declarations.
|
||
#[cfg(not(test))]
|
||
pub mod boxed;
|
||
#[cfg(test)]
|
||
mod boxed {
|
||
pub use std::boxed::Box;
|
||
}
|
||
#[cfg(not(no_borrow))]
|
||
pub mod borrow;
|
||
pub mod collections;
|
||
#[cfg(all(not(no_rc), not(no_sync), not(no_global_oom_handling)))]
|
||
pub mod ffi;
|
||
#[cfg(not(no_fmt))]
|
||
pub mod fmt;
|
||
#[cfg(not(no_rc))]
|
||
pub mod rc;
|
||
pub mod slice;
|
||
#[cfg(not(no_str))]
|
||
pub mod str;
|
||
#[cfg(not(no_string))]
|
||
pub mod string;
|
||
#[cfg(all(not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
|
||
pub mod sync;
|
||
#[cfg(all(not(no_global_oom_handling), not(no_rc), not(no_sync), target_has_atomic = "ptr"))]
|
||
pub mod task;
|
||
#[cfg(test)]
|
||
mod tests;
|
||
pub mod vec;
|
||
|
||
#[doc(hidden)]
|
||
#[unstable(feature = "liballoc_internals", issue = "none", reason = "implementation detail")]
|
||
pub mod __export {
|
||
pub use core::format_args;
|
||
}
|
||
|
||
#[cfg(test)]
|
||
#[allow(dead_code)] // Not used in all configurations
|
||
pub(crate) mod test_helpers {
|
||
/// Copied from `std::test_helpers::test_rng`, since these tests rely on the
|
||
/// seed not being the same for every RNG invocation too.
|
||
pub(crate) fn test_rng() -> rand_xorshift::XorShiftRng {
|
||
use std::hash::{BuildHasher, Hash, Hasher};
|
||
let mut hasher = std::collections::hash_map::RandomState::new().build_hasher();
|
||
std::panic::Location::caller().hash(&mut hasher);
|
||
let hc64 = hasher.finish();
|
||
let seed_vec =
|
||
hc64.to_le_bytes().into_iter().chain(0u8..8).collect::<crate::vec::Vec<u8>>();
|
||
let seed: [u8; 16] = seed_vec.as_slice().try_into().unwrap();
|
||
rand::SeedableRng::from_seed(seed)
|
||
}
|
||
}
|