mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 03:07:24 +03:00
Auto merge of #123517 - GuillaumeGomez:rollup-eys3jfp, r=GuillaumeGomez
Rollup of 8 pull requests Successful merges: - #121419 (Add aarch64-apple-visionos and aarch64-apple-visionos-sim tier 3 targets) - #123159 (Fix target-cpu fpu features on Arm R/M-profile) - #123487 (CFI: Restore typeid_for_instance default behavior) - #123500 (Revert removing miri jobserver workaround) - #123505 (Revert "Use OS thread name by default") - #123509 (Add jieyouxu to compiler review rotation and as a reviewer for `tests/run-make`, `src/tools/run-make-support` and `src/tools/compiletest`) - #123514 (Fix typo in `compiler/rustc_middle/src/traits/solve/inspect.rs`) - #123515 (Use `include` command to reduce code duplication) r? `@ghost` `@rustbot` modify labels: rollup
This commit is contained in:
@@ -912,6 +912,7 @@ fn target_is_apple(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
|
||||
|| cgcx.opts.target_triple.triple().contains("-darwin")
|
||||
|| cgcx.opts.target_triple.triple().contains("-tvos")
|
||||
|| cgcx.opts.target_triple.triple().contains("-watchos")
|
||||
|| cgcx.opts.target_triple.triple().contains("-visionos")
|
||||
}
|
||||
|
||||
fn target_is_aix(cgcx: &CodegenContext<LlvmCodegenBackend>) -> bool {
|
||||
|
||||
@@ -147,7 +147,7 @@ pub fn declare_fn(
|
||||
for options in [
|
||||
TypeIdOptions::GENERALIZE_POINTERS,
|
||||
TypeIdOptions::NORMALIZE_INTEGERS,
|
||||
TypeIdOptions::ERASE_SELF_TYPE,
|
||||
TypeIdOptions::USE_CONCRETE_SELF,
|
||||
]
|
||||
.into_iter()
|
||||
.powerset()
|
||||
@@ -173,9 +173,7 @@ pub fn declare_fn(
|
||||
|
||||
if self.tcx.sess.is_sanitizer_kcfi_enabled() {
|
||||
// LLVM KCFI does not support multiple !kcfi_type attachments
|
||||
// Default to erasing the self type. If we need the concrete type, there will be a
|
||||
// hint in the instance.
|
||||
let mut options = TypeIdOptions::ERASE_SELF_TYPE;
|
||||
let mut options = TypeIdOptions::empty();
|
||||
if self.tcx.sess.is_sanitizer_cfi_generalize_pointers_enabled() {
|
||||
options.insert(TypeIdOptions::GENERALIZE_POINTERS);
|
||||
}
|
||||
|
||||
@@ -2946,7 +2946,7 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
let os = &sess.target.os;
|
||||
let llvm_target = &sess.target.llvm_target;
|
||||
if sess.target.vendor != "apple"
|
||||
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "macos")
|
||||
|| !matches!(os.as_ref(), "ios" | "tvos" | "watchos" | "visionos" | "macos")
|
||||
|| !matches!(flavor, LinkerFlavor::Darwin(..))
|
||||
{
|
||||
return;
|
||||
@@ -2971,6 +2971,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) {
|
||||
("arm64_32", "watchos") => "watchos",
|
||||
("aarch64", "watchos") if llvm_target.ends_with("-simulator") => "watchsimulator",
|
||||
("aarch64", "watchos") => "watchos",
|
||||
("aarch64", "visionos") if llvm_target.ends_with("-simulator") => "xrsimulator",
|
||||
("aarch64", "visionos") => "xros",
|
||||
("arm", "watchos") => "watchos",
|
||||
(_, "macos") => "macosx",
|
||||
_ => {
|
||||
@@ -3027,6 +3029,10 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
|
||||
|| sdkroot.contains("MacOSX.platform") => {}
|
||||
"watchsimulator"
|
||||
if sdkroot.contains("WatchOS.platform") || sdkroot.contains("MacOSX.platform") => {}
|
||||
"visionos"
|
||||
if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {}
|
||||
"visionossimulator"
|
||||
if sdkroot.contains("XROS.platform") || sdkroot.contains("MacOSX.platform") => {}
|
||||
// Ignore `SDKROOT` if it's not a valid path.
|
||||
_ if !p.is_absolute() || p == Path::new("/") || !p.exists() => {}
|
||||
_ => return Ok(sdkroot),
|
||||
|
||||
@@ -130,7 +130,7 @@ pub enum ProbeStep<'tcx> {
|
||||
pub enum ProbeKind<'tcx> {
|
||||
/// The root inference context while proving a goal.
|
||||
Root { result: QueryResult<'tcx> },
|
||||
/// Trying to normalize an alias by at least one stpe in `NormalizesTo`.
|
||||
/// Trying to normalize an alias by at least one step in `NormalizesTo`.
|
||||
TryNormalizeNonRigid { result: QueryResult<'tcx> },
|
||||
/// Probe entered when normalizing the self ty during candidate assembly
|
||||
NormalizedSelfTyAssembly,
|
||||
|
||||
@@ -24,9 +24,14 @@ pub struct TypeIdOptions: u32 {
|
||||
/// `-fsanitize-cfi-icall-experimental-normalize-integers` option for cross-language LLVM
|
||||
/// CFI and KCFI support.
|
||||
const NORMALIZE_INTEGERS = 4;
|
||||
/// Generalize the instance by erasing the concrete `Self` type where possible.
|
||||
/// Only has an effect on `{kcfi_,}typeid_for_instance`.
|
||||
const ERASE_SELF_TYPE = 8;
|
||||
/// Do not perform self type erasure for attaching a secondary type id to methods with their
|
||||
/// concrete self so they can be used as function pointers.
|
||||
///
|
||||
/// (This applies to typeid_for_instance only and should be used to attach a secondary type
|
||||
/// id to methods during their declaration/definition so they match the type ids returned by
|
||||
/// either typeid_for_instance or typeid_for_fnabi at call sites during code generation for
|
||||
/// type membership tests when methods are used as function pointers.)
|
||||
const USE_CONCRETE_SELF = 8;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +74,23 @@ pub fn kcfi_typeid_for_instance<'tcx>(
|
||||
instance: Instance<'tcx>,
|
||||
mut options: TypeIdOptions,
|
||||
) -> u32 {
|
||||
// If we receive a `ReifyShim` intended to produce a function pointer, we need to remain
|
||||
// concrete - abstraction is for vtables.
|
||||
// KCFI support for Rust shares most of its implementation with the CFI support, with some key
|
||||
// differences:
|
||||
//
|
||||
// 1. KCFI performs type tests differently and are implemented as different LLVM passes than CFI
|
||||
// to not require LTO.
|
||||
// 2. KCFI has the limitation that a function or method may have one type id assigned only.
|
||||
//
|
||||
// Because of the limitation listed above (2), the current KCFI implementation (not CFI) does
|
||||
// reifying of types (i.e., adds shims/trampolines for indirect calls in these cases) for:
|
||||
//
|
||||
// * Supporting casting between function items, closures, and Fn trait objects.
|
||||
// * Supporting methods being cast as function pointers.
|
||||
//
|
||||
// This was implemented for KCFI support in #123106 and #123052 (which introduced the
|
||||
// ReifyReason). The tracking issue for KCFI support for Rust is #123479.
|
||||
if matches!(instance.def, InstanceDef::ReifyShim(_, Some(ReifyReason::FnPtr))) {
|
||||
options.remove(TypeIdOptions::ERASE_SELF_TYPE);
|
||||
options.insert(TypeIdOptions::USE_CONCRETE_SELF);
|
||||
}
|
||||
// A KCFI type metadata identifier is a 32-bit constant produced by taking the lower half of the
|
||||
// xxHash64 of the type metadata identifier. (See llvm/llvm-project@cff5bef.)
|
||||
|
||||
@@ -1098,7 +1098,7 @@ pub fn typeid_for_instance<'tcx>(
|
||||
instance.args = tcx.mk_args_trait(invoke_ty, trait_ref.args.into_iter().skip(1));
|
||||
}
|
||||
|
||||
if options.contains(EncodeTyOptions::ERASE_SELF_TYPE) {
|
||||
if !options.contains(EncodeTyOptions::USE_CONCRETE_SELF) {
|
||||
if let Some(impl_id) = tcx.impl_of_method(instance.def_id())
|
||||
&& let Some(trait_ref) = tcx.impl_trait_ref(impl_id)
|
||||
{
|
||||
|
||||
@@ -102,6 +102,7 @@ fn pre_link_args(os: &'static str, arch: Arch, abi: &'static str) -> LinkArgs {
|
||||
"ios" => ios_deployment_target(arch, abi),
|
||||
"tvos" => tvos_deployment_target(),
|
||||
"watchos" => watchos_deployment_target(),
|
||||
"visionos" => visionos_deployment_target(),
|
||||
"macos" => macos_deployment_target(arch),
|
||||
_ => unreachable!(),
|
||||
};
|
||||
@@ -202,6 +203,8 @@ pub fn sdk_version(platform: u32) -> Option<(u32, u32)> {
|
||||
| object::macho::PLATFORM_TVOSSIMULATOR
|
||||
| object::macho::PLATFORM_MACCATALYST => Some((16, 2)),
|
||||
object::macho::PLATFORM_WATCHOS | object::macho::PLATFORM_WATCHOSSIMULATOR => Some((9, 1)),
|
||||
// FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
|
||||
11 | 12 => Some((1, 0)),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -216,6 +219,9 @@ pub fn platform(target: &Target) -> Option<u32> {
|
||||
("watchos", _) => object::macho::PLATFORM_WATCHOS,
|
||||
("tvos", "sim") => object::macho::PLATFORM_TVOSSIMULATOR,
|
||||
("tvos", _) => object::macho::PLATFORM_TVOS,
|
||||
// FIXME: Upgrade to `object-rs` 0.33+ implementation with visionOS platform definition
|
||||
("visionos", "sim") => 12,
|
||||
("visionos", _) => 11,
|
||||
_ => return None,
|
||||
})
|
||||
}
|
||||
@@ -240,6 +246,7 @@ pub fn deployment_target(target: &Target) -> Option<(u32, u32)> {
|
||||
}
|
||||
"watchos" => watchos_deployment_target(),
|
||||
"tvos" => tvos_deployment_target(),
|
||||
"visionos" => visionos_deployment_target(),
|
||||
_ => return None,
|
||||
};
|
||||
|
||||
@@ -290,6 +297,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
|
||||
|| sdkroot.contains("AppleTVSimulator.platform")
|
||||
|| sdkroot.contains("WatchOS.platform")
|
||||
|| sdkroot.contains("WatchSimulator.platform")
|
||||
|| sdkroot.contains("XROS.platform")
|
||||
{
|
||||
env_remove.push("SDKROOT".into())
|
||||
}
|
||||
@@ -299,6 +307,7 @@ fn link_env_remove(os: &'static str) -> StaticCow<[StaticCow<str>]> {
|
||||
// although this is apparently ignored when using the linker at "/usr/bin/ld".
|
||||
env_remove.push("IPHONEOS_DEPLOYMENT_TARGET".into());
|
||||
env_remove.push("TVOS_DEPLOYMENT_TARGET".into());
|
||||
env_remove.push("XROS_DEPLOYMENT_TARGET".into());
|
||||
env_remove.into()
|
||||
} else {
|
||||
// Otherwise if cross-compiling for a different OS/SDK (including Mac Catalyst), remove any part
|
||||
@@ -363,3 +372,18 @@ pub fn watchos_sim_llvm_target(arch: Arch) -> String {
|
||||
let (major, minor) = watchos_deployment_target();
|
||||
format!("{}-apple-watchos{}.{}.0-simulator", arch.target_name(), major, minor)
|
||||
}
|
||||
|
||||
fn visionos_deployment_target() -> (u32, u32) {
|
||||
// If you are looking for the default deployment target, prefer `rustc --print deployment-target`.
|
||||
from_set_deployment_target("XROS_DEPLOYMENT_TARGET").unwrap_or((1, 0))
|
||||
}
|
||||
|
||||
pub fn visionos_llvm_target(arch: Arch) -> String {
|
||||
let (major, minor) = visionos_deployment_target();
|
||||
format!("{}-apple-visionos{}.{}.0", arch.target_name(), major, minor)
|
||||
}
|
||||
|
||||
pub fn visionos_sim_llvm_target(arch: Arch) -> String {
|
||||
let (major, minor) = visionos_deployment_target();
|
||||
format!("{}-apple-visionos{}.{}.0-simulator", arch.target_name(), major, minor)
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use crate::spec::targets::{
|
||||
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_watchos_sim, i686_apple_darwin,
|
||||
x86_64_apple_darwin, x86_64_apple_ios, x86_64_apple_tvos, x86_64_apple_watchos_sim,
|
||||
aarch64_apple_darwin, aarch64_apple_ios_sim, aarch64_apple_visionos_sim,
|
||||
aarch64_apple_watchos_sim, i686_apple_darwin, x86_64_apple_darwin, x86_64_apple_ios,
|
||||
x86_64_apple_tvos, x86_64_apple_watchos_sim,
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -12,6 +13,7 @@ fn simulator_targets_set_abi() {
|
||||
aarch64_apple_ios_sim::target(),
|
||||
// Note: There is currently no ARM64 tvOS simulator target
|
||||
aarch64_apple_watchos_sim::target(),
|
||||
aarch64_apple_visionos_sim::target(),
|
||||
];
|
||||
|
||||
for target in &all_sim_targets {
|
||||
@@ -32,7 +34,11 @@ fn macos_link_environment_unmodified() {
|
||||
// for the host.
|
||||
assert_eq!(
|
||||
target.link_env_remove,
|
||||
crate::spec::cvs!["IPHONEOS_DEPLOYMENT_TARGET", "TVOS_DEPLOYMENT_TARGET"],
|
||||
crate::spec::cvs![
|
||||
"IPHONEOS_DEPLOYMENT_TARGET",
|
||||
"TVOS_DEPLOYMENT_TARGET",
|
||||
"XROS_DEPLOYMENT_TARGET"
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1557,6 +1557,9 @@ fn $module() {
|
||||
("aarch64-apple-watchos", aarch64_apple_watchos),
|
||||
("aarch64-apple-watchos-sim", aarch64_apple_watchos_sim),
|
||||
|
||||
("aarch64-apple-visionos", aarch64_apple_visionos),
|
||||
("aarch64-apple-visionos-sim", aarch64_apple_visionos_sim),
|
||||
|
||||
("armebv7r-none-eabi", armebv7r_none_eabi),
|
||||
("armebv7r-none-eabihf", armebv7r_none_eabihf),
|
||||
("armv7r-none-eabi", armv7r_none_eabi),
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
use crate::spec::base::apple::{opts, visionos_llvm_target, Arch};
|
||||
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let arch = Arch::Arm64;
|
||||
let mut base = opts("visionos", arch);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
llvm_target: visionos_llvm_target(arch).into(),
|
||||
metadata: crate::spec::TargetMetadata {
|
||||
description: Some("ARM64 Apple visionOS".into()),
|
||||
tier: Some(3),
|
||||
host_tools: Some(false),
|
||||
std: Some(false),
|
||||
},
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions {
|
||||
features: "+neon,+fp-armv8,+apple-a16".into(),
|
||||
max_atomic_width: Some(128),
|
||||
frame_pointer: FramePointer::NonLeaf,
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
use crate::spec::base::apple::{opts, visionos_sim_llvm_target, Arch};
|
||||
use crate::spec::{FramePointer, SanitizerSet, Target, TargetOptions};
|
||||
|
||||
pub fn target() -> Target {
|
||||
let arch = Arch::Arm64_sim;
|
||||
let mut base = opts("visionos", arch);
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::THREAD;
|
||||
|
||||
Target {
|
||||
llvm_target: visionos_sim_llvm_target(arch).into(),
|
||||
metadata: crate::spec::TargetMetadata {
|
||||
description: Some("ARM64 Apple visionOS simulator".into()),
|
||||
tier: Some(3),
|
||||
host_tools: Some(false),
|
||||
std: Some(false),
|
||||
},
|
||||
pointer_width: 64,
|
||||
data_layout: "e-m:o-i64:64-i128:128-n32:64-S128".into(),
|
||||
arch: arch.target_arch(),
|
||||
options: TargetOptions {
|
||||
features: "+neon,+fp-armv8,+apple-a16".into(),
|
||||
max_atomic_width: Some(128),
|
||||
frame_pointer: FramePointer::NonLeaf,
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ pub fn target() -> Target {
|
||||
linker: Some("rust-lld".into()),
|
||||
relocation_model: RelocModel::Static,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
features: "+vfp3,-d32,-fp16".into(),
|
||||
features: "+vfp3d16".into(),
|
||||
max_atomic_width: Some(64),
|
||||
emit_debug_gdb_scripts: false,
|
||||
// GCC defaults to 8 for arm-none here.
|
||||
|
||||
@@ -21,7 +21,7 @@ pub fn target() -> Target {
|
||||
linker: Some("rust-lld".into()),
|
||||
relocation_model: RelocModel::Static,
|
||||
panic_strategy: PanicStrategy::Abort,
|
||||
features: "+vfp3,-d32,-fp16".into(),
|
||||
features: "+vfp3d16".into(),
|
||||
max_atomic_width: Some(64),
|
||||
emit_debug_gdb_scripts: false,
|
||||
// GCC defaults to 8 for arm-none here.
|
||||
|
||||
@@ -25,16 +25,15 @@ pub fn target() -> Target {
|
||||
|
||||
options: TargetOptions {
|
||||
abi: "eabihf".into(),
|
||||
// `+vfp4` is the lowest common denominator between the Cortex-M4 (vfp4-16) and the
|
||||
// Cortex-M7 (vfp5)
|
||||
// `-d32` both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers
|
||||
// available
|
||||
// `-fp64` The Cortex-M4 only supports single precision floating point operations
|
||||
// whereas in the Cortex-M7 double precision is optional
|
||||
// vfp4 is the lowest common denominator between the Cortex-M4F (vfp4) and the
|
||||
// Cortex-M7 (vfp5).
|
||||
// Both the Cortex-M4 and the Cortex-M7 only have 16 double-precision registers
|
||||
// available, and the Cortex-M4 only supports single-precision floating point operations
|
||||
// whereas in the Cortex-M7 double-precision is optional.
|
||||
//
|
||||
// Reference:
|
||||
// ARMv7-M Architecture Reference Manual - A2.5 The optional floating-point extension
|
||||
features: "+vfp4,-d32,-fp64".into(),
|
||||
features: "+vfp4d16sp".into(),
|
||||
max_atomic_width: Some(32),
|
||||
..base::thumb::opts()
|
||||
},
|
||||
|
||||
@@ -22,8 +22,7 @@ pub fn target() -> Target {
|
||||
// processor, the Cortex-M33 Technical Reference Manual states that
|
||||
// the FPU uses the FPv5 architecture, single-precision instructions
|
||||
// and 16 D registers.
|
||||
// These parameters map to the following LLVM features.
|
||||
features: "+fp-armv8,-fp64,-d32".into(),
|
||||
features: "+fp-armv8d16sp".into(),
|
||||
max_atomic_width: Some(32),
|
||||
..base::thumb::opts()
|
||||
},
|
||||
|
||||
@@ -22,6 +22,7 @@ fn main() {
|
||||
|| target_os == "ios"
|
||||
|| target_os == "tvos"
|
||||
|| target_os == "watchos"
|
||||
|| target_os == "visionos"
|
||||
|| target_os == "windows"
|
||||
|| target_os == "fuchsia"
|
||||
|| (target_vendor == "fortanix" && target_env == "sgx")
|
||||
|
||||
@@ -1644,8 +1644,8 @@ fn test_file_times() {
|
||||
use crate::os::macos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "tvos")]
|
||||
use crate::os::tvos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "tvos")]
|
||||
use crate::os::tvos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "visionos")]
|
||||
use crate::os::visionos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "watchos")]
|
||||
use crate::os::watchos::fs::FileTimesExt;
|
||||
#[cfg(windows)]
|
||||
@@ -1662,6 +1662,7 @@ fn test_file_times() {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
let created = SystemTime::UNIX_EPOCH + Duration::from_secs(32123);
|
||||
@@ -1670,6 +1671,7 @@ fn test_file_times() {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
{
|
||||
@@ -1701,6 +1703,7 @@ fn test_file_times() {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
{
|
||||
@@ -1709,7 +1712,13 @@ fn test_file_times() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
fn test_file_times_pre_epoch_with_nanos() {
|
||||
#[cfg(target_os = "ios")]
|
||||
use crate::os::ios::fs::FileTimesExt;
|
||||
@@ -1717,6 +1726,8 @@ fn test_file_times_pre_epoch_with_nanos() {
|
||||
use crate::os::macos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "tvos")]
|
||||
use crate::os::tvos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "visionos")]
|
||||
use crate::os::visionos::fs::FileTimesExt;
|
||||
#[cfg(target_os = "watchos")]
|
||||
use crate::os::watchos::fs::FileTimesExt;
|
||||
|
||||
|
||||
@@ -149,6 +149,8 @@ pub mod windows {}
|
||||
pub(crate) mod tvos;
|
||||
#[cfg(target_os = "uefi")]
|
||||
pub mod uefi;
|
||||
#[cfg(target_os = "visionos")]
|
||||
pub(crate) mod visionos;
|
||||
#[cfg(target_os = "vita")]
|
||||
pub mod vita;
|
||||
#[cfg(target_os = "vxworks")]
|
||||
|
||||
@@ -79,6 +79,8 @@ mod platform {
|
||||
pub use crate::os::solaris::*;
|
||||
#[cfg(target_os = "tvos")]
|
||||
pub use crate::os::tvos::*;
|
||||
#[cfg(target_os = "visionos")]
|
||||
pub use crate::os::visionos::*;
|
||||
#[cfg(target_os = "vita")]
|
||||
pub use crate::os::vita::*;
|
||||
#[cfg(target_os = "vxworks")]
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
@@ -46,6 +47,7 @@
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
target_os = "tvos",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "nto"
|
||||
@@ -234,6 +235,7 @@ pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
||||
target_os = "tvos",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "nto"
|
||||
|
||||
@@ -35,7 +35,13 @@ pub struct UCred {
|
||||
))]
|
||||
pub(super) use self::impl_bsd::peer_cred;
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
pub(super) use self::impl_mac::peer_cred;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
@@ -97,7 +103,13 @@ pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
mod impl_mac {
|
||||
use super::UCred;
|
||||
use crate::os::unix::io::AsRawFd;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
target_os = "tvos",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn test_socket_pair() {
|
||||
@@ -32,6 +33,7 @@ fn test_socket_pair() {
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
))]
|
||||
fn test_socket_pair_pids(arg: Type) -> RetType {
|
||||
|
||||
@@ -0,0 +1,160 @@
|
||||
#![stable(feature = "metadata_ext", since = "1.1.0")]
|
||||
|
||||
use crate::fs::{self, Metadata};
|
||||
use crate::sealed::Sealed;
|
||||
use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
|
||||
use crate::time::SystemTime;
|
||||
|
||||
#[allow(deprecated)]
|
||||
use super::raw;
|
||||
|
||||
/// OS-specific extensions to [`fs::Metadata`].
|
||||
///
|
||||
/// [`fs::Metadata`]: crate::fs::Metadata
|
||||
#[stable(feature = "metadata_ext", since = "1.1.0")]
|
||||
pub trait MetadataExt {
|
||||
/// Gain a reference to the underlying `stat` structure which contains
|
||||
/// the raw information returned by the OS.
|
||||
///
|
||||
/// The contents of the returned `stat` are **not** consistent across
|
||||
/// Unix platforms. The `os::unix::fs::MetadataExt` trait contains the
|
||||
/// cross-Unix abstractions contained within the raw stat.
|
||||
#[stable(feature = "metadata_ext", since = "1.1.0")]
|
||||
#[deprecated(
|
||||
since = "1.8.0",
|
||||
note = "deprecated in favor of the accessor \
|
||||
methods of this trait"
|
||||
)]
|
||||
#[allow(deprecated)]
|
||||
fn as_raw_stat(&self) -> &raw::stat;
|
||||
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_dev(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_ino(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_mode(&self) -> u32;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_nlink(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_uid(&self) -> u32;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_gid(&self) -> u32;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_rdev(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_size(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_atime(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_atime_nsec(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_mtime(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_mtime_nsec(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_ctime(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_ctime_nsec(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_birthtime(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_birthtime_nsec(&self) -> i64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_blksize(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_blocks(&self) -> u64;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_flags(&self) -> u32;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_gen(&self) -> u32;
|
||||
#[stable(feature = "metadata_ext2", since = "1.8.0")]
|
||||
fn st_lspare(&self) -> u32;
|
||||
}
|
||||
|
||||
#[stable(feature = "metadata_ext", since = "1.1.0")]
|
||||
impl MetadataExt for Metadata {
|
||||
#[allow(deprecated)]
|
||||
fn as_raw_stat(&self) -> &raw::stat {
|
||||
unsafe { &*(self.as_inner().as_inner() as *const libc::stat as *const raw::stat) }
|
||||
}
|
||||
fn st_dev(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_dev as u64
|
||||
}
|
||||
fn st_ino(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_ino as u64
|
||||
}
|
||||
fn st_mode(&self) -> u32 {
|
||||
self.as_inner().as_inner().st_mode as u32
|
||||
}
|
||||
fn st_nlink(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_nlink as u64
|
||||
}
|
||||
fn st_uid(&self) -> u32 {
|
||||
self.as_inner().as_inner().st_uid as u32
|
||||
}
|
||||
fn st_gid(&self) -> u32 {
|
||||
self.as_inner().as_inner().st_gid as u32
|
||||
}
|
||||
fn st_rdev(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_rdev as u64
|
||||
}
|
||||
fn st_size(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_size as u64
|
||||
}
|
||||
fn st_atime(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_atime as i64
|
||||
}
|
||||
fn st_atime_nsec(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_atime_nsec as i64
|
||||
}
|
||||
fn st_mtime(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_mtime as i64
|
||||
}
|
||||
fn st_mtime_nsec(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_mtime_nsec as i64
|
||||
}
|
||||
fn st_ctime(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_ctime as i64
|
||||
}
|
||||
fn st_ctime_nsec(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_ctime_nsec as i64
|
||||
}
|
||||
fn st_birthtime(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_birthtime as i64
|
||||
}
|
||||
fn st_birthtime_nsec(&self) -> i64 {
|
||||
self.as_inner().as_inner().st_birthtime_nsec as i64
|
||||
}
|
||||
fn st_blksize(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_blksize as u64
|
||||
}
|
||||
fn st_blocks(&self) -> u64 {
|
||||
self.as_inner().as_inner().st_blocks as u64
|
||||
}
|
||||
fn st_gen(&self) -> u32 {
|
||||
self.as_inner().as_inner().st_gen as u32
|
||||
}
|
||||
fn st_flags(&self) -> u32 {
|
||||
self.as_inner().as_inner().st_flags as u32
|
||||
}
|
||||
fn st_lspare(&self) -> u32 {
|
||||
self.as_inner().as_inner().st_lspare as u32
|
||||
}
|
||||
}
|
||||
|
||||
/// OS-specific extensions to [`fs::FileTimes`].
|
||||
#[stable(feature = "file_set_times", since = "1.75.0")]
|
||||
pub trait FileTimesExt: Sealed {
|
||||
/// Set the creation time of a file.
|
||||
#[stable(feature = "file_set_times", since = "1.75.0")]
|
||||
fn set_created(self, t: SystemTime) -> Self;
|
||||
}
|
||||
|
||||
#[stable(feature = "file_set_times", since = "1.75.0")]
|
||||
impl FileTimesExt for fs::FileTimes {
|
||||
fn set_created(mut self, t: SystemTime) -> Self {
|
||||
self.as_inner_mut().set_created(t.into_inner());
|
||||
self
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
//! visionos-specific definitions
|
||||
|
||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
||||
|
||||
pub mod fs;
|
||||
pub mod raw;
|
||||
@@ -0,0 +1,83 @@
|
||||
//! visionos-specific raw type definitions
|
||||
|
||||
#![stable(feature = "raw_ext", since = "1.1.0")]
|
||||
#![deprecated(
|
||||
since = "1.8.0",
|
||||
note = "these type aliases are no longer supported by \
|
||||
the standard library, the `libc` crate on \
|
||||
crates.io should be used instead for the correct \
|
||||
definitions"
|
||||
)]
|
||||
#![allow(deprecated)]
|
||||
|
||||
use crate::os::raw::c_long;
|
||||
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type blkcnt_t = u64;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type blksize_t = u64;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type dev_t = u64;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type ino_t = u64;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type mode_t = u32;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type nlink_t = u64;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type off_t = u64;
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub type time_t = i64;
|
||||
|
||||
#[stable(feature = "pthread_t", since = "1.8.0")]
|
||||
pub type pthread_t = usize;
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone)]
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub struct stat {
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_dev: i32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_mode: u16,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_nlink: u16,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_ino: u64,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_uid: u32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_gid: u32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_rdev: i32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_atime: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_atime_nsec: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_mtime: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_mtime_nsec: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_ctime: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_ctime_nsec: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_birthtime: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_birthtime_nsec: c_long,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_size: i64,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_blocks: i64,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_blksize: i32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_flags: u32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_gen: u32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_lspare: i32,
|
||||
#[stable(feature = "raw_ext", since = "1.1.0")]
|
||||
pub st_qspare: [i64; 2],
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use super::abi;
|
||||
use super::thread_local_dtor::run_dtors;
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::mem;
|
||||
use crate::num::NonZero;
|
||||
@@ -71,10 +71,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn sleep(dur: Duration) {
|
||||
unsafe {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
};
|
||||
use crate::{
|
||||
cell::UnsafeCell,
|
||||
ffi::{CStr, CString},
|
||||
ffi::CStr,
|
||||
hint, io,
|
||||
mem::ManuallyDrop,
|
||||
num::NonZero,
|
||||
@@ -204,10 +204,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
for timeout in dur2reltims(dur) {
|
||||
expect_success(unsafe { abi::dly_tsk(timeout) }, &"dly_tsk");
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![cfg_attr(test, allow(dead_code))] // why is this necessary?
|
||||
use super::unsupported;
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::num::NonZero;
|
||||
use crate::time::Duration;
|
||||
@@ -133,10 +133,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// which succeeds as-is with the SGX target.
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
usercalls::wait_timeout(0, dur, || true);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use core::convert::TryInto;
|
||||
|
||||
use crate::cmp;
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::mem;
|
||||
use crate::num::NonZero;
|
||||
@@ -101,10 +101,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// contact the teeos rustzone team.
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
/// only main thread could wait for sometime in teeos
|
||||
pub fn sleep(dur: Duration) {
|
||||
let sleep_millis = dur.as_millis();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::unsupported;
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::num::NonZero;
|
||||
use crate::ptr::NonNull;
|
||||
@@ -23,10 +23,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
let boot_services: NonNull<r_efi::efi::BootServices> =
|
||||
crate::os::uefi::env::boot_services().expect("can't sleep").cast();
|
||||
|
||||
@@ -170,7 +170,13 @@ fn clone() -> Vec<OsString> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
mod imp {
|
||||
use super::Args;
|
||||
use crate::ffi::CStr;
|
||||
@@ -211,7 +217,12 @@ pub fn args() -> Args {
|
||||
// for i in (0..[args count])
|
||||
// res.push([args objectAtIndex:i])
|
||||
// res
|
||||
#[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos"
|
||||
))]
|
||||
pub fn args() -> Args {
|
||||
use crate::ffi::{c_char, c_void, OsString};
|
||||
use crate::mem;
|
||||
|
||||
@@ -53,6 +53,17 @@ pub mod os {
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "visionos")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "visionos";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".dylib";
|
||||
pub const DLL_EXTENSION: &str = "dylib";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &str = "unix";
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
const fn max_iov() -> usize {
|
||||
libc::IOV_MAX as usize
|
||||
@@ -81,6 +82,7 @@ const fn max_iov() -> usize {
|
||||
target_os = "horizon",
|
||||
target_os = "vita",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
)))]
|
||||
const fn max_iov() -> usize {
|
||||
16 // The minimum value required by POSIX.
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
use crate::sys::weak::syscall;
|
||||
#[cfg(any(target_os = "android", target_os = "macos", target_os = "solaris"))]
|
||||
@@ -35,6 +36,7 @@
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "solaris",
|
||||
all(target_os = "linux", target_env = "gnu")
|
||||
))]
|
||||
@@ -377,7 +379,13 @@ pub struct FilePermissions {
|
||||
pub struct FileTimes {
|
||||
accessed: Option<SystemTime>,
|
||||
modified: Option<SystemTime>,
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
created: Option<SystemTime>,
|
||||
}
|
||||
|
||||
@@ -555,6 +563,7 @@ pub fn accessed(&self) -> io::Result<SystemTime> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
pub fn created(&self) -> io::Result<SystemTime> {
|
||||
SystemTime::new(self.stat.st_birthtime as i64, self.stat.st_birthtime_nsec as i64)
|
||||
@@ -567,6 +576,7 @@ pub fn created(&self) -> io::Result<SystemTime> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "vita",
|
||||
)))]
|
||||
pub fn created(&self) -> io::Result<SystemTime> {
|
||||
@@ -647,7 +657,13 @@ pub fn set_modified(&mut self, t: SystemTime) {
|
||||
self.modified = Some(t);
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
pub fn set_created(&mut self, t: SystemTime) {
|
||||
self.created = Some(t);
|
||||
}
|
||||
@@ -938,6 +954,7 @@ pub fn file_type(&self) -> io::Result<FileType> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "linux",
|
||||
target_os = "emscripten",
|
||||
target_os = "android",
|
||||
@@ -974,6 +991,7 @@ pub fn ino(&self) -> u64 {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
@@ -993,6 +1011,7 @@ fn name_bytes(&self) -> &[u8] {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
@@ -1162,6 +1181,7 @@ pub fn fsync(&self) -> io::Result<()> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
libc::fcntl(fd, libc::F_FULLFSYNC)
|
||||
@@ -1171,6 +1191,7 @@ unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
)))]
|
||||
unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
libc::fsync(fd)
|
||||
@@ -1186,6 +1207,7 @@ pub fn datasync(&self) -> io::Result<()> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
unsafe fn os_datasync(fd: c_int) -> c_int {
|
||||
libc::fcntl(fd, libc::F_FULLFSYNC)
|
||||
@@ -1212,6 +1234,7 @@ unsafe fn os_datasync(fd: c_int) -> c_int {
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "nto",
|
||||
target_os = "hurd",
|
||||
)))]
|
||||
@@ -1322,7 +1345,7 @@ pub fn set_times(&self, times: FileTimes) -> io::Result<()> {
|
||||
io::ErrorKind::Unsupported,
|
||||
"setting file times not supported",
|
||||
))
|
||||
} else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))] {
|
||||
} else if #[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] {
|
||||
let mut buf = [mem::MaybeUninit::<libc::timespec>::uninit(); 3];
|
||||
let mut num_times = 0;
|
||||
let mut attrlist: libc::attrlist = unsafe { mem::zeroed() };
|
||||
@@ -1787,6 +1810,7 @@ fn open_to_and_set_permissions(
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
)))]
|
||||
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
let (mut reader, reader_metadata) = open_from(from)?;
|
||||
@@ -1813,7 +1837,13 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
use crate::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
|
||||
@@ -83,6 +83,7 @@ unsafe fn sanitize_standard_fds() {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "redox",
|
||||
target_os = "l4re",
|
||||
target_os = "horizon",
|
||||
@@ -405,7 +406,7 @@ pub fn abort_internal() -> ! {
|
||||
} else if #[cfg(target_os = "macos")] {
|
||||
#[link(name = "System")]
|
||||
extern "C" {}
|
||||
} else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))] {
|
||||
} else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos"))] {
|
||||
#[link(name = "System")]
|
||||
#[link(name = "objc")]
|
||||
#[link(name = "Foundation", kind = "framework")]
|
||||
|
||||
@@ -69,7 +69,8 @@
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "freebsd",
|
||||
target_os = "watchos"
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
),
|
||||
link_name = "__error"
|
||||
)]
|
||||
@@ -430,7 +431,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
||||
Ok(PathBuf::from(OsString::from_vec(e)))
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
pub fn current_exe() -> io::Result<PathBuf> {
|
||||
unsafe {
|
||||
let mut sz: u32 = 0;
|
||||
@@ -699,6 +706,7 @@ pub fn home_dir() -> Option<PathBuf> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "emscripten",
|
||||
target_os = "redox",
|
||||
target_os = "vxworks",
|
||||
@@ -714,6 +722,7 @@ unsafe fn fallback() -> Option<OsString> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "emscripten",
|
||||
target_os = "redox",
|
||||
target_os = "vxworks",
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
target_os = "freebsd",
|
||||
all(target_os = "linux", target_env = "gnu"),
|
||||
|
||||
@@ -16,6 +16,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "tvos"),
|
||||
not(target_os = "watchos"),
|
||||
not(target_os = "visionos"),
|
||||
not(target_os = "openbsd"),
|
||||
not(target_os = "netbsd"),
|
||||
not(target_os = "fuchsia"),
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use crate::cmp;
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::mem;
|
||||
use crate::num::NonZero;
|
||||
@@ -150,7 +150,13 @@ pub fn set_name(name: &CStr) {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
pub fn set_name(name: &CStr) {
|
||||
unsafe {
|
||||
let name = truncate_cstr::<{ libc::MAXTHREADNAMESIZE }>(name);
|
||||
@@ -228,78 +234,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// Newlib, Emscripten, and VxWorks have no way to set a thread name.
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos"
|
||||
))]
|
||||
pub fn get_name() -> Option<CString> {
|
||||
#[cfg(target_os = "linux")]
|
||||
const TASK_COMM_LEN: usize = 16;
|
||||
#[cfg(target_os = "freebsd")]
|
||||
const TASK_COMM_LEN: usize = libc::MAXCOMLEN + 1;
|
||||
#[cfg(any(target_os = "netbsd", target_os = "solaris", target_os = "illumos"))]
|
||||
const TASK_COMM_LEN: usize = 32;
|
||||
let mut name = vec![0u8; TASK_COMM_LEN];
|
||||
let res = unsafe {
|
||||
libc::pthread_getname_np(libc::pthread_self(), name.as_mut_ptr().cast(), name.len())
|
||||
};
|
||||
if res != 0 {
|
||||
return None;
|
||||
}
|
||||
name.truncate(name.iter().position(|&c| c == 0)?);
|
||||
CString::new(name).ok()
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
|
||||
pub fn get_name() -> Option<CString> {
|
||||
let mut name = vec![0u8; libc::MAXTHREADNAMESIZE];
|
||||
let res = unsafe {
|
||||
libc::pthread_getname_np(libc::pthread_self(), name.as_mut_ptr().cast(), name.len())
|
||||
};
|
||||
if res != 0 {
|
||||
return None;
|
||||
}
|
||||
name.truncate(name.iter().position(|&c| c == 0)?);
|
||||
CString::new(name).ok()
|
||||
}
|
||||
|
||||
#[cfg(target_os = "haiku")]
|
||||
pub fn get_name() -> Option<CString> {
|
||||
unsafe {
|
||||
let mut tinfo = mem::MaybeUninit::<libc::thread_info>::uninit();
|
||||
// See BeOS teams group and threads api.
|
||||
// https://www.haiku-os.org/legacy-docs/bebook/TheKernelKit_ThreadsAndTeams_Overview.html
|
||||
let thread_self = libc::find_thread(ptr::null_mut());
|
||||
let res = libc::get_thread_info(thread_self, tinfo.as_mut_ptr());
|
||||
if res != libc::B_OK {
|
||||
return None;
|
||||
}
|
||||
let info = tinfo.assume_init();
|
||||
let name =
|
||||
core::slice::from_raw_parts(info.name.as_ptr() as *const u8, info.name.len());
|
||||
CStr::from_bytes_until_nul(name).map(CStr::to_owned).ok()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(
|
||||
target_os = "linux",
|
||||
target_os = "freebsd",
|
||||
target_os = "netbsd",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "haiku",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos"
|
||||
)))]
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(not(target_os = "espidf"))]
|
||||
pub fn sleep(dur: Duration) {
|
||||
let mut secs = dur.as_secs();
|
||||
@@ -371,6 +305,7 @@ fn drop(&mut self) {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "nto",
|
||||
target_os = "solaris",
|
||||
target_os = "illumos",
|
||||
|
||||
@@ -76,7 +76,13 @@ pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
|
||||
// workaround below is to register, via _tlv_atexit, a custom DTOR list once per
|
||||
// thread. thread_local dtors are pushed to the DTOR list without calling
|
||||
// _tlv_atexit.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "tvos"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
pub unsafe fn register_dtor(t: *mut u8, dtor: unsafe extern "C" fn(*mut u8)) {
|
||||
use crate::cell::{Cell, RefCell};
|
||||
use crate::ptr;
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos",
|
||||
),
|
||||
not(miri),
|
||||
|
||||
@@ -48,6 +48,7 @@ unsafe fn wait_timeout(
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon",
|
||||
))]
|
||||
@@ -76,6 +77,7 @@ unsafe fn wait_timeout(
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon",
|
||||
)))]
|
||||
@@ -124,6 +126,7 @@ pub unsafe fn new_in_place(parker: *mut Parker) {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox",
|
||||
|
||||
@@ -90,7 +90,8 @@ const fn new(tv_sec: i64, tv_nsec: i64) -> Result<Timespec, io::Error> {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos"
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
let (tv_sec, tv_nsec) =
|
||||
if (tv_sec <= 0 && tv_sec > i64::MIN) && (tv_nsec < 0 && tv_nsec > -1_000_000_000) {
|
||||
@@ -278,6 +279,7 @@ pub fn now() -> Instant {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
))]
|
||||
const clock_id: libc::clockid_t = libc::CLOCK_UPTIME_RAW;
|
||||
@@ -285,6 +287,7 @@ pub fn now() -> Instant {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "tvos"
|
||||
)))]
|
||||
const clock_id: libc::clockid_t = libc::CLOCK_MONOTONIC;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use super::unsupported;
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::num::NonZero;
|
||||
use crate::time::Duration;
|
||||
@@ -22,10 +22,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(_dur: Duration) {
|
||||
panic!("can't sleep");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::mem;
|
||||
use crate::num::NonZero;
|
||||
@@ -134,10 +134,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
let nanos = dur.as_nanos();
|
||||
assert!(nanos <= u64::MAX as u128);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::ffi::CStr;
|
||||
use crate::ffi::CString;
|
||||
use crate::io;
|
||||
use crate::num::NonZero;
|
||||
use crate::sys::unsupported;
|
||||
@@ -18,9 +17,6 @@ pub unsafe fn new(_stack: usize, _p: Box<dyn FnOnce()>) -> io::Result<Thread> {
|
||||
pub fn yield_now() {}
|
||||
|
||||
pub fn set_name(_name: &CStr) {}
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
use crate::arch::wasm32;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
use crate::sys::stack_overflow;
|
||||
use crate::sys_common::FromInner;
|
||||
use crate::time::Duration;
|
||||
use alloc::ffi::CString;
|
||||
use core::ffi::c_void;
|
||||
|
||||
use super::time::WaitableTimer;
|
||||
@@ -67,29 +66,6 @@ pub fn set_name(name: &CStr) {
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
unsafe {
|
||||
let mut ptr = core::ptr::null_mut();
|
||||
let result = c::GetThreadDescription(c::GetCurrentThread(), &mut ptr);
|
||||
if result < 0 {
|
||||
return None;
|
||||
}
|
||||
let name = String::from_utf16_lossy({
|
||||
let mut len = 0;
|
||||
while *ptr.add(len) != 0 {
|
||||
len += 1;
|
||||
}
|
||||
core::slice::from_raw_parts(ptr, len)
|
||||
})
|
||||
.into_bytes();
|
||||
// Attempt to free the memory.
|
||||
// This should never fail but if it does then there's not much we can do about it.
|
||||
let result = c::LocalFree(ptr.cast::<c_void>());
|
||||
debug_assert!(result.is_null());
|
||||
if name.is_empty() { None } else { Some(CString::from_vec_unchecked(name)) }
|
||||
}
|
||||
}
|
||||
|
||||
pub fn join(self) {
|
||||
let rc = unsafe { c::WaitForSingleObject(self.handle.as_raw_handle(), c::INFINITE) };
|
||||
if rc == c::WAIT_FAILED {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use crate::ffi::{CStr, CString};
|
||||
use crate::ffi::CStr;
|
||||
use crate::io;
|
||||
use crate::num::NonZero;
|
||||
use crate::os::xous::ffi::{
|
||||
@@ -113,10 +113,6 @@ pub fn set_name(_name: &CStr) {
|
||||
// nope
|
||||
}
|
||||
|
||||
pub fn get_name() -> Option<CString> {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn sleep(dur: Duration) {
|
||||
// Because the sleep server works on units of `usized milliseconds`, split
|
||||
// the messages up into these chunks. This means we may run into issues
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "tvos"), not(target_os = "watchos"), not(target_os = "netbsd")))] {
|
||||
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "tvos"), not(target_os = "watchos"), not(target_os = "visionos"), not(target_os = "netbsd")))] {
|
||||
// ARM EHABI personality routine.
|
||||
// https://web.archive.org/web/20190728160938/https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
|
||||
//
|
||||
|
||||
@@ -34,6 +34,7 @@ fn init() -> Box<Self> {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox"
|
||||
@@ -127,6 +128,7 @@ pub unsafe fn wait(&self, mutex: &Mutex) {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "android",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon"
|
||||
@@ -162,6 +164,7 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
target_os = "android",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon"
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
target_os = "dragonfly", target_os = "freebsd",
|
||||
target_os = "ios", target_os = "tvos", target_os = "macos", target_os = "watchos",
|
||||
target_os = "ios", target_os = "tvos", target_os = "macos", target_os = "watchos", target_os = "visionos",
|
||||
target_os = "openbsd", target_os = "netbsd", target_os = "illumos",
|
||||
target_os = "solaris", target_os = "haiku", target_os = "l4re", target_os = "nto"))] {
|
||||
use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
|
||||
|
||||
@@ -694,9 +694,7 @@ pub(crate) fn set_current(thread: Thread) {
|
||||
/// In contrast to the public `current` function, this will not panic if called
|
||||
/// from inside a TLS destructor.
|
||||
pub(crate) fn try_current() -> Option<Thread> {
|
||||
CURRENT
|
||||
.try_with(|current| current.get_or_init(|| Thread::new(imp::Thread::get_name())).clone())
|
||||
.ok()
|
||||
CURRENT.try_with(|current| current.get_or_init(|| Thread::new(None)).clone()).ok()
|
||||
}
|
||||
|
||||
/// Gets a handle to the thread that invokes it.
|
||||
|
||||
@@ -43,7 +43,8 @@ fn test_named_thread() {
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos"
|
||||
target_os = "watchos",
|
||||
target_os = "visionos",
|
||||
))]
|
||||
#[test]
|
||||
fn test_named_thread_truncation() {
|
||||
@@ -69,26 +70,6 @@ fn test_named_thread_truncation() {
|
||||
result.unwrap().join().unwrap();
|
||||
}
|
||||
|
||||
#[cfg(any(
|
||||
all(target_os = "windows", not(target_vendor = "win7")),
|
||||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "tvos",
|
||||
target_os = "watchos"
|
||||
))]
|
||||
#[test]
|
||||
fn test_get_os_named_thread() {
|
||||
use crate::sys::thread::Thread;
|
||||
// Spawn a new thread to avoid interfering with other tests running on this thread.
|
||||
let handler = thread::spawn(|| {
|
||||
let name = c"test me please";
|
||||
Thread::set_name(name);
|
||||
assert_eq!(name, Thread::get_name().unwrap().as_c_str());
|
||||
});
|
||||
handler.join().unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_invalid_named_thread() {
|
||||
|
||||
@@ -123,7 +123,7 @@ pub enum _Unwind_Context {}
|
||||
}
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "netbsd", not(target_arch = "arm")))] {
|
||||
if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos", target_os = "visionos", target_os = "netbsd", not(target_arch = "arm")))] {
|
||||
// Not ARM EHABI
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
@@ -365,10 +365,11 @@ fn run(self, builder: &Builder<'_>) -> LlvmResult {
|
||||
cfg.define("LLVM_ENABLE_ZLIB", "OFF");
|
||||
}
|
||||
|
||||
// Are we compiling for iOS/tvOS/watchOS?
|
||||
// Are we compiling for iOS/tvOS/watchOS/visionOS?
|
||||
if target.contains("apple-ios")
|
||||
|| target.contains("apple-tvos")
|
||||
|| target.contains("apple-watchos")
|
||||
|| target.contains("apple-visionos")
|
||||
{
|
||||
// These two defines prevent CMake from automatically trying to add a MacOSX sysroot, which leads to a compiler error.
|
||||
cfg.define("CMAKE_OSX_SYSROOT", "/");
|
||||
|
||||
@@ -92,8 +92,9 @@
|
||||
(Some(Mode::Std), "backtrace_in_libstd", None),
|
||||
/* Extra values not defined in the built-in targets yet, but used in std */
|
||||
(Some(Mode::Std), "target_env", Some(&["libnx", "p2"])),
|
||||
// (Some(Mode::Std), "target_os", Some(&[])),
|
||||
(Some(Mode::Std), "target_os", Some(&["visionos"])),
|
||||
(Some(Mode::Std), "target_arch", Some(&["arm64ec", "spirv", "nvptx", "xtensa"])),
|
||||
(Some(Mode::ToolStd), "target_os", Some(&["visionos"])),
|
||||
/* Extra names used by dependencies */
|
||||
// FIXME: Used by serde_json, but we should not be triggering on external dependencies.
|
||||
(Some(Mode::Rustc), "no_btreemap_remove_entry", None),
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
- [arm64ec-pc-windows-msvc](platform-support/arm64ec-pc-windows-msvc.md)
|
||||
- [\*-apple-tvos](platform-support/apple-tvos.md)
|
||||
- [\*-apple-watchos\*](platform-support/apple-watchos.md)
|
||||
- [aarch64-apple-visionos\*](platform-support/apple-visionos.md)
|
||||
- [aarch64-nintendo-switch-freestanding](platform-support/aarch64-nintendo-switch-freestanding.md)
|
||||
- [armeb-unknown-linux-gnueabi](platform-support/armeb-unknown-linux-gnueabi.md)
|
||||
- [arm-none-eabi](platform-support/arm-none-eabi.md)
|
||||
|
||||
@@ -243,6 +243,8 @@ target | std | host | notes
|
||||
[`aarch64-apple-tvos-sim`](platform-support/apple-tvos.md) | ? | | ARM64 tvOS Simulator
|
||||
[`aarch64-apple-watchos`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS
|
||||
[`aarch64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | ARM64 Apple WatchOS Simulator
|
||||
[`aarch64-apple-visionos`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS
|
||||
[`aarch64-apple-visionos-sim`](platform-support/apple-visionos.md) | ✓ | | ARM64 Apple visionOS Simulator
|
||||
[`aarch64-kmc-solid_asp3`](platform-support/kmc-solid.md) | ✓ | | ARM64 SOLID with TOPPERS/ASP3
|
||||
[`aarch64-nintendo-switch-freestanding`](platform-support/aarch64-nintendo-switch-freestanding.md) | * | | ARM64 Nintendo Switch, Horizon
|
||||
[`aarch64-pc-windows-gnullvm`](platform-support/pc-windows-gnullvm.md) | ✓ | ✓ |
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# aarch64-apple-visionos\*
|
||||
|
||||
- aarch64-apple-visionos
|
||||
- aarch64-apple-visionos-sim
|
||||
|
||||
**Tier: 3**
|
||||
|
||||
Apple visionOS targets:
|
||||
|
||||
- Apple visionOS on arm64
|
||||
- Apple visionOS Simulator on arm64
|
||||
|
||||
## Target maintainers
|
||||
|
||||
- [@agg23](https://github.com/agg23)
|
||||
- [@madsmtm](https://github.com/madsmtm)
|
||||
|
||||
## Requirements
|
||||
|
||||
These targets are cross-compiled.
|
||||
To build these targets Xcode 15 or higher on macOS is required, along with LLVM 18.
|
||||
|
||||
## Building the target
|
||||
|
||||
The targets can be built by enabling them for a `rustc` build, for example:
|
||||
|
||||
```toml
|
||||
[build]
|
||||
build-stage = 1
|
||||
target = ["aarch64-apple-visionos-sim"]
|
||||
```
|
||||
|
||||
## Building Rust programs
|
||||
|
||||
_Note: Building for this target requires the corresponding visionOS SDK, as provided by Xcode 15+._
|
||||
|
||||
Rust programs can be built for these targets, if `rustc` has been built with support for them, for example:
|
||||
|
||||
```text
|
||||
rustc --target aarch64-apple-visionos-sim your-code.rs
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
There is no support for running the Rust testsuite on visionOS or the simulators.
|
||||
|
||||
There is no easy way to run simple programs on visionOS or the visionOS simulators. Static library builds can be embedded into visionOS applications.
|
||||
|
||||
## Cross-compilation toolchains and C code
|
||||
|
||||
This target can be cross-compiled from x86_64 or aarch64 macOS hosts.
|
||||
|
||||
Other hosts are not supported for cross-compilation, but might work when also providing the required Xcode SDK.
|
||||
@@ -511,6 +511,7 @@ fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
"wasi" => "WASI",
|
||||
"watchos" => "watchOS",
|
||||
"windows" => "Windows",
|
||||
"visionos" => "visionOS",
|
||||
_ => "",
|
||||
},
|
||||
(sym::target_arch, Some(arch)) => match arch.as_str() {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
/// on the number of cores available.
|
||||
///
|
||||
/// This fixes issue #7772.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos", target_os = "visionos"))]
|
||||
#[allow(non_camel_case_types)]
|
||||
pub unsafe fn raise_fd_limit() {
|
||||
use std::cmp;
|
||||
|
||||
@@ -558,6 +558,13 @@ pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: Runner
|
||||
// Set missing env vars. We prefer build-time env vars over run-time ones; see
|
||||
// <https://github.com/rust-lang/miri/issues/1661> for the kind of issue that fixes.
|
||||
for (name, val) in info.env {
|
||||
// `CARGO_MAKEFLAGS` contains information about how to reach the jobserver, but by the time
|
||||
// the program is being run, that jobserver no longer exists (cargo only runs the jobserver
|
||||
// for the build portion of `cargo run`/`cargo test`). Hence we shouldn't forward this.
|
||||
// Also see <https://github.com/rust-lang/rust/pull/113730>.
|
||||
if name == "CARGO_MAKEFLAGS" {
|
||||
continue;
|
||||
}
|
||||
if let Some(old_val) = env::var_os(&name) {
|
||||
if old_val == val {
|
||||
// This one did not actually change, no need to re-set it.
|
||||
|
||||
@@ -27,6 +27,14 @@
|
||||
//@ revisions: arm64_32_apple_watchos
|
||||
//@ [arm64_32_apple_watchos] compile-flags: --target arm64_32-apple-watchos
|
||||
//@ [arm64_32_apple_watchos] needs-llvm-components: aarch64
|
||||
//@ revisions: aarch64_apple_visionos
|
||||
//@ [aarch64_apple_visionos] min-llvm-version: 18
|
||||
//@ [aarch64_apple_visionos] compile-flags: --target aarch64-apple-visionos
|
||||
//@ [aarch64_apple_visionos] needs-llvm-components: aarch64
|
||||
//@ revisions: aarch64_apple_visionos_sim
|
||||
//@ [aarch64_apple_visionos_sim] min-llvm-version: 18
|
||||
//@ [aarch64_apple_visionos_sim] compile-flags: --target aarch64-apple-visionos-sim
|
||||
//@ [aarch64_apple_visionos_sim] needs-llvm-components: aarch64
|
||||
//@ revisions: arm64e_apple_darwin
|
||||
//@ [arm64e_apple_darwin] compile-flags: --target arm64e-apple-darwin
|
||||
//@ [arm64e_apple_darwin] needs-llvm-components: aarch64
|
||||
|
||||
+2
-2
@@ -18,5 +18,5 @@ fn foo(&self) {}
|
||||
}
|
||||
|
||||
|
||||
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
|
||||
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
|
||||
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvu3refIu3dynIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}6Trait1u6regionEEE"}
|
||||
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtC{{[[:print:]]+}}_{{[[:print:]]+}}5Type1EE"}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test is to ensure that the anchors (`§`) have the expected color and position.
|
||||
include: "utils.goml"
|
||||
|
||||
define-function: (
|
||||
"check-colors",
|
||||
@@ -8,10 +9,7 @@ define-function: (
|
||||
// This is needed to ensure that the text color is computed.
|
||||
show-text: true
|
||||
|
||||
// Setting the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
assert-css: ("#toggle-all-docs", {"color": |main_color|})
|
||||
assert-css: (".main-heading h1 a:nth-of-type(1)", {"color": |main_heading_color|})
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// check that the rule isn't applied on other "<code>" elements.
|
||||
//
|
||||
// While we're at it, we also check it for the other themes.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
||||
// If the text isn't displayed, the browser doesn't compute color style correctly...
|
||||
show-text: true
|
||||
@@ -10,10 +11,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, doc_code_color, doc_inline_code_color],
|
||||
block {
|
||||
// Set the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".docblock pre > code", {"color": |doc_code_color|}, ALL)
|
||||
assert-css: (".docblock > p > code", {"color": |doc_inline_code_color|}, ALL)
|
||||
},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checking the colors of the codeblocks tooltips.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
||||
show-text: true
|
||||
|
||||
@@ -6,9 +7,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, background, color, border],
|
||||
block {
|
||||
// Setting the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
// compile_fail block
|
||||
assert-css: (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checks that the setting "line numbers" is working as expected.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
||||
|
||||
// Otherwise, we can't check text color
|
||||
@@ -13,14 +14,10 @@ define-function: (
|
||||
[theme, color],
|
||||
block {
|
||||
// We now set the setting to show the line numbers on code examples.
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": |theme|,
|
||||
"rustdoc-use-system-theme": "false",
|
||||
"rustdoc-line-numbers": "true"
|
||||
}
|
||||
// We reload to make the line numbers appear and change theme.
|
||||
reload:
|
||||
// We wait for them to be added into the DOM by the JS...
|
||||
set-local-storage: {"rustdoc-line-numbers": "true"}
|
||||
// Page will be reloaded in "switch-theme".
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
// We wait for the line numbers to be added into the DOM by the JS...
|
||||
wait-for: "pre.example-line-numbers"
|
||||
// If the test didn't fail, it means that it was found!
|
||||
assert-css: (
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// This ensures that the `<details>`/`<summary>` elements are displayed as expected.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/details/struct.Details.html"
|
||||
show-text: true
|
||||
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "dark"})
|
||||
|
||||
// We first check that the headers in the `.top-doc` doc block still have their
|
||||
// bottom border.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test checks the appearance of the tables in the doc comments.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/doc_block_table/struct.DocBlockTable.html#method.func"
|
||||
|
||||
compare-elements-css: (".impl-items .docblock table th", ".top-doc .docblock table th", ["border"])
|
||||
@@ -8,8 +9,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, border_color, zebra_stripe_color],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".top-doc .docblock table tbody tr:nth-child(1)", {
|
||||
"background-color": "rgba(0, 0, 0, 0)",
|
||||
})
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// This test check for headings text and background colors for the different themes.
|
||||
|
||||
include: "utils.goml"
|
||||
|
||||
define-function: (
|
||||
"check-colors",
|
||||
[theme, color, code_header_color, focus_background_color, headings_color],
|
||||
@@ -7,8 +9,7 @@ define-function: (
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
||||
// This is needed so that the text color is computed.
|
||||
show-text: true
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (
|
||||
".impl",
|
||||
{"color": |color|, "background-color": "rgba(0, 0, 0, 0)"},
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
// 18px 1.125em
|
||||
// 16px 1rem
|
||||
// 14px 0.875rem
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.HeavilyDocumentedStruct.html"
|
||||
|
||||
assert-css: (".main-heading h1", {"font-size": "24px"})
|
||||
@@ -158,8 +159,8 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, heading_color, small_heading_color, heading_border_color],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
assert-css: (
|
||||
".top-doc .docblock h2",
|
||||
{"color": |heading_color|, "border-bottom": "1px solid " + |heading_border_color|},
|
||||
@@ -222,8 +223,7 @@ define-function: (
|
||||
"check-since-color",
|
||||
[theme],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".since", {"color": "#808080"}, ALL)
|
||||
},
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test ensures that opening the help page in its own tab works.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/help.html"
|
||||
set-window-size: (1000, 1000) // Try desktop size first.
|
||||
wait-for: "#help"
|
||||
@@ -19,10 +20,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, color, background, box_shadow],
|
||||
block {
|
||||
// Setting the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: ("#help kbd", {
|
||||
"color": |color|,
|
||||
"background-color": |background|,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test checks the highlight colors in the source code pages.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||
show-text: true
|
||||
|
||||
@@ -22,8 +23,7 @@ define-function: (
|
||||
doc_comment,
|
||||
],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: ("pre.rust .kw", {"color": |kw|}, ALL)
|
||||
assert-css: ("pre.rust .kw-2", {"color": |kw2|}, ALL)
|
||||
assert-css: ("pre.rust .prelude-ty", {"color": |prelude_ty|}, ALL)
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// This test ensures that the color of the items in the type decl are working as expected.
|
||||
|
||||
include: "utils.goml"
|
||||
|
||||
// We need to disable this check because `trait.impl/test_docs/trait.TraitWithoutGenerics.js`
|
||||
// doesn't exist.
|
||||
fail-on-request-error: false
|
||||
@@ -21,8 +23,8 @@ define-function: (
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.WithGenerics.html"
|
||||
show-text: true
|
||||
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
assert-css: (".item-decl .code-attribute", {"color": |attr_color|}, ALL)
|
||||
assert-css: (".item-decl .trait", {"color": |trait_color|}, ALL)
|
||||
// We need to add `code` here because otherwise it would select the parent too.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test checks that comments in item declarations are highlighted.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/private/enum.Enum.html"
|
||||
show-text: true
|
||||
|
||||
@@ -7,8 +8,7 @@ define-function: (
|
||||
[theme, url, comment_color],
|
||||
block {
|
||||
go-to: |url|
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".item-decl .comment", {"color": |comment_color|}, ALL)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
// We check the background color on the jump to definition links in the src code page.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/src/link_to_definition/lib.rs.html"
|
||||
|
||||
define-function: (
|
||||
"check-background-color",
|
||||
[theme, background_color],
|
||||
block {
|
||||
// Set the theme.
|
||||
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (
|
||||
"body.src .example-wrap pre.rust a",
|
||||
{"background-color": |background_color|},
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test checks links colors.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
|
||||
// This is needed so that the text color is computed.
|
||||
@@ -9,11 +10,7 @@ define-function: (
|
||||
[theme, mod, macro, struct, enum, trait, fn, type, union, keyword,
|
||||
sidebar, sidebar_current, sidebar_current_background],
|
||||
block {
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": |theme|,
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
// Checking results colors.
|
||||
assert-css: (".item-table .mod", {"color": |mod|}, ALL)
|
||||
assert-css: (".item-table .macro", {"color": |macro|}, ALL)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test checks the position of the `i` for the notable traits.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.NotableStructWithLongName.html"
|
||||
show-text: true
|
||||
// We start with a wide screen.
|
||||
@@ -128,10 +129,7 @@ define-function: (
|
||||
// This is needed to ensure that the text color is computed.
|
||||
show-text: true
|
||||
|
||||
// Setting the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
assert-css: (
|
||||
"//*[@id='method.create_an_iterator_from_read']//*[@class='tooltip']",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test ensures that the "pocket menus" are working as expected.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
// First we check that the help menu doesn't exist yet.
|
||||
assert-false: "#help-button .popover"
|
||||
@@ -33,11 +34,7 @@ define-function: (
|
||||
"check-popover-colors",
|
||||
[theme, border_color],
|
||||
block {
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": |theme|,
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
click: "#help-button"
|
||||
assert-css: (
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Playground. That button is hidden until the user hovers over the code block.
|
||||
// This test checks that it is hidden, and that it shows on hover. It also
|
||||
// checks for its color.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html"
|
||||
show-text: true
|
||||
|
||||
@@ -9,8 +10,7 @@ define-function: (
|
||||
"check-run-button",
|
||||
[theme, color, background, hover_color, hover_background],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".test-arrow", {"visibility": "hidden"})
|
||||
move-cursor-to: ".example-wrap"
|
||||
assert-css: (".test-arrow", {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test ensures that the correct style is applied to the rust logo in the sidebar.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
|
||||
|
||||
define-function: (
|
||||
@@ -8,14 +9,12 @@ define-function: (
|
||||
// Going to the doc page.
|
||||
go-to: "file://" + |DOC_PATH| + "/staged_api/index.html"
|
||||
// Changing theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".rust-logo", {"filter": |filter|})
|
||||
// Now we check that the non-rust logos don't have a CSS filter set.
|
||||
go-to: "file://" + |DOC_PATH| + "/huge_logo/index.html"
|
||||
// Changing theme on the new page (again...).
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
// Check there is no rust logo
|
||||
assert-false: ".rust-logo"
|
||||
// Check there is no filter.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Check that scrape example code blocks have the expected colors.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
||||
show-text: true
|
||||
|
||||
@@ -7,8 +8,7 @@ define-function: (
|
||||
[theme, highlight, highlight_focus, help_border, help_color, help_hover_border,
|
||||
help_hover_color],
|
||||
block {
|
||||
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
wait-for: ".more-examples-toggle"
|
||||
assert-css: (".scraped-example .example-wrap .rust span.highlight:not(.focus)", {
|
||||
"background-color": |highlight|,
|
||||
@@ -66,8 +66,7 @@ define-function: (
|
||||
"check-background",
|
||||
[theme, background_color_start, background_color_end],
|
||||
block {
|
||||
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false", }
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (".scraped-example:not(.expanded) .code-wrapper::before", {
|
||||
"background-image": "linear-gradient(" + |background_color_start| + ", " +
|
||||
|background_color_end| + ")",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This tests checks that the "scraped examples" toggle is working as expected.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test_many.html"
|
||||
|
||||
// Checking the color of the toggle line.
|
||||
@@ -7,8 +8,7 @@ define-function: (
|
||||
"check-color",
|
||||
[theme, toggle_line_color, toggle_line_hover_color],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
// Clicking "More examples..." will open additional examples
|
||||
assert-attribute-false: (".more-examples-toggle", {"open": ""})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checks that the crate search filtering is handled correctly and changes the results.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=sa'%3Bda'%3Bds"
|
||||
show-text: true
|
||||
|
||||
@@ -6,11 +7,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, error_background],
|
||||
block {
|
||||
// Setting the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
wait-for: "#search .error code"
|
||||
assert-css: ("#search .error code", {"background-color": |error_background|})
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checks that the crate search filtering is handled correctly and changes the results.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
show-text: true
|
||||
write-into: (".search-input", "test")
|
||||
@@ -59,8 +60,7 @@ assert-text: (".search-results-title", "Results in all crates", STARTS_WITH)
|
||||
|
||||
// Checking the display of the crate filter.
|
||||
// We start with the light theme.
|
||||
set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "light"})
|
||||
|
||||
set-timeout: 2000
|
||||
wait-for: "#crate-search"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test ensures that the elements in ".search-form" have the expected display.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
show-text: true
|
||||
|
||||
@@ -9,11 +10,7 @@ define-function: (
|
||||
menu_button_border, menu_button_a_color, menu_button_a_border_hover, menu_a_color,
|
||||
],
|
||||
block {
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": |theme|,
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (
|
||||
".search-input",
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// The goal of this test is to check the color of the "no result" links.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/lib2/index.html?search=sdkfskjfsdks"
|
||||
show-text: true
|
||||
|
||||
@@ -6,9 +7,7 @@ define-function: (
|
||||
"check-no-result",
|
||||
[theme, link, link_hover],
|
||||
block {
|
||||
// Changing theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
wait-for: "#results"
|
||||
assert: ".search-failed.active"
|
||||
assert-css: ("#results a", {"color": |link|}, ALL)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Checks that the reexports are present in the search index, can have
|
||||
// doc aliases and are highligted when their ID is the hash of the page.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "dark"})
|
||||
// First we check that the reexport has the correct ID and no background color.
|
||||
assert-text: ("//*[@id='reexport.TheStdReexport']", "pub use ::std as TheStdReexport;")
|
||||
assert-css: ("//*[@id='reexport.TheStdReexport']", {"background-color": "rgba(0, 0, 0, 0)"})
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// The goal of this test is to ensure the color of the text is the one expected.
|
||||
|
||||
include: "utils.goml"
|
||||
define-function: (
|
||||
"check-result-color",
|
||||
[result_kind, color, hover_color],
|
||||
@@ -43,11 +44,7 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/index.html?search=coo"
|
||||
show-text: true
|
||||
|
||||
// Ayu theme
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": "ayu",
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "ayu"})
|
||||
|
||||
// Waiting for the search results to appear...
|
||||
wait-for: "#search-tabs"
|
||||
@@ -155,11 +152,7 @@ assert-css: (
|
||||
)
|
||||
|
||||
// Dark theme
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": "dark",
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "dark"})
|
||||
|
||||
// Waiting for the search results to appear...
|
||||
wait-for: "#search-tabs"
|
||||
@@ -255,8 +248,7 @@ assert-css: (
|
||||
)
|
||||
|
||||
// Light theme
|
||||
set-local-storage: {"rustdoc-theme": "light", "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "light"})
|
||||
|
||||
// Waiting for the search results to appear...
|
||||
wait-for: "#search-tabs"
|
||||
@@ -360,8 +352,7 @@ define-function: (
|
||||
"check-alias",
|
||||
[theme, alias, grey],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
write-into: (".search-input", "thisisanalias")
|
||||
// To be SURE that the search will be run.
|
||||
press-key: 'Enter'
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// ignore-tidy-linelength
|
||||
// Checks that the search results have the expected width.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
set-window-size: (900, 1000)
|
||||
write-into: (".search-input", "test")
|
||||
@@ -71,8 +72,7 @@ define-function: (
|
||||
"check-filter",
|
||||
[theme, border, filter, hover_border, hover_filter],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
wait-for: "#crate-search"
|
||||
assert-css: ("#crate-search", {"border": "1px solid " + |border|})
|
||||
assert-css: ("#crate-search-div::after", {"filter": |filter|})
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checking the colors of the search tab headers.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/fn.foo.html?search=foo"
|
||||
show-text: true
|
||||
|
||||
@@ -8,9 +9,7 @@ define-function: (
|
||||
border_bottom_selected, border_bottom_hover, border_top, border_top_selected,
|
||||
border_top_hover],
|
||||
block {
|
||||
// Setting the theme.
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
|
||||
// These two commands are used to be sure the search will be run.
|
||||
focus: ".search-input"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// This test ensures that the settings menu display is working as expected and that
|
||||
// the settings page is also rendered as expected.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
show-text: true // needed when we check for colors below.
|
||||
// First, we check that the settings page doesn't exist.
|
||||
@@ -35,8 +36,7 @@ wait-for: "#alternative-display #search"
|
||||
assert: "#main-content.hidden"
|
||||
|
||||
// Now let's check the content of the settings menu.
|
||||
set-local-storage: {"rustdoc-theme": "dark", "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "dark"})
|
||||
click: "#settings-menu"
|
||||
wait-for: "#settings"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test checks links colors in sidebar before and after hover.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
||||
|
||||
// This is needed so that the text color is computed.
|
||||
@@ -13,8 +14,7 @@ define-function: (
|
||||
type_hover_background, keyword, keyword_hover, keyword_hover_background,
|
||||
],
|
||||
block {
|
||||
set-local-storage: { "rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false" }
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
// Struct
|
||||
assert-css: (
|
||||
".sidebar .block.struct li:not(.current) a",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// This test ensure that the sidebar isn't "hidden" on mobile but instead moved out of the viewport.
|
||||
// This is especially important for devices for "text-first" content (like for users with
|
||||
// sight issues).
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/struct.Foo.html"
|
||||
// Switching to "mobile view" by reducing the width to 600px.
|
||||
set-window-size: (600, 600)
|
||||
@@ -59,7 +60,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, color, background],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-use-system-theme": "false", "rustdoc-theme": |theme|}
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
reload:
|
||||
|
||||
// Open the sidebar menu.
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// This test ensures that the elements in the sidebar are displayed correctly.
|
||||
include: "utils.goml"
|
||||
javascript: false
|
||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||
// Since the javascript is disabled, there shouldn't be a toggle.
|
||||
@@ -34,8 +35,7 @@ define-function: (
|
||||
theme, color, color_hover, background, background_hover, background_toggle,
|
||||
],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
wait-for-css: (".src .sidebar > *", {"visibility": "visible"})
|
||||
assert-css: (
|
||||
"#src-sidebar details[open] > .files a.selected",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// The goal of this test is to ensure that the sidebar is working as expected in the source
|
||||
// code pages.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||
show-text: true
|
||||
|
||||
@@ -8,11 +9,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, color, background_color],
|
||||
block {
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": |theme|,
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
// Checking results colors.
|
||||
assert-css: (".src .sidebar", {
|
||||
"color": |color|,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checks multiple things on the sidebar display (width of its elements, colors, etc).
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/test_docs/index.html"
|
||||
assert-property: (".sidebar", {"clientWidth": "200"})
|
||||
show-text: true
|
||||
@@ -8,11 +9,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, color, background_color],
|
||||
block {
|
||||
set-local-storage: {
|
||||
"rustdoc-theme": |theme|,
|
||||
"rustdoc-use-system-theme": "false",
|
||||
}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
// Checking results colors.
|
||||
assert-css: (".sidebar", {
|
||||
"color": |color|,
|
||||
@@ -46,9 +43,7 @@ call-function: (
|
||||
}
|
||||
)
|
||||
|
||||
set-local-storage: {"rustdoc-theme": "light"}
|
||||
// We reload the page so the local storage settings are being used.
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": "light"})
|
||||
|
||||
assert-text: (".sidebar > .sidebar-crate > h2 > a", "test_docs")
|
||||
// Crate root has no "location" element
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// Checks that the interactions with the source code pages are working as expected.
|
||||
include: "utils.goml"
|
||||
go-to: "file://" + |DOC_PATH| + "/src/test_docs/lib.rs.html"
|
||||
show-text: true
|
||||
// Check that we can click on the line number.
|
||||
@@ -23,8 +24,7 @@ define-function: (
|
||||
"check-colors",
|
||||
[theme, color, background_color, highlight_color, highlight_background_color],
|
||||
block {
|
||||
set-local-storage: {"rustdoc-theme": |theme|, "rustdoc-use-system-theme": "false"}
|
||||
reload:
|
||||
call-function: ("switch-theme", {"theme": |theme|})
|
||||
assert-css: (
|
||||
".src-line-numbers > a:not(.line-highlighted)",
|
||||
{"color": |color|, "background-color": |background_color|},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user