From 6bfe27a3e0f1c4d77999ccc2350ab861327615a2 Mon Sep 17 00:00:00 2001 From: Lzu Tao Date: Tue, 27 Oct 2020 13:10:31 +0000 Subject: [PATCH] Drop support for cloudabi targets --- .../build_sysroot/alloc_system/lib.rs | 6 +- .../src/spec/aarch64_unknown_cloudabi.rs | 16 - .../src/spec/armv7_unknown_cloudabi_eabihf.rs | 18 - .../rustc_target/src/spec/cloudabi_base.rs | 36 - .../src/spec/i686_unknown_cloudabi.rs | 20 - compiler/rustc_target/src/spec/mod.rs | 6 - .../src/spec/x86_64_unknown_cloudabi.rs | 19 - library/panic_abort/src/lib.rs | 2 +- library/panic_unwind/src/lib.rs | 1 - library/std/build.rs | 1 - library/std/src/fs.rs | 2 +- library/std/src/net/tcp.rs | 2 +- library/std/src/net/udp.rs | 2 +- library/std/src/process.rs | 2 +- library/std/src/sys/cloudabi/abi/bitflags.rs | 47 - library/std/src/sys/cloudabi/abi/cloudabi.rs | 2954 ----------------- library/std/src/sys/cloudabi/abi/mod.rs | 3 - library/std/src/sys/cloudabi/args.rs | 7 - library/std/src/sys/cloudabi/condvar.rs | 149 - library/std/src/sys/cloudabi/io.rs | 47 - library/std/src/sys/cloudabi/mod.rs | 73 - library/std/src/sys/cloudabi/mutex.rs | 153 - library/std/src/sys/cloudabi/os.rs | 26 - library/std/src/sys/cloudabi/rwlock.rs | 215 -- library/std/src/sys/cloudabi/shims/args.rs | 35 - library/std/src/sys/cloudabi/shims/env.rs | 9 - library/std/src/sys/cloudabi/shims/fs.rs | 308 -- library/std/src/sys/cloudabi/shims/mod.rs | 19 - library/std/src/sys/cloudabi/shims/net.rs | 326 -- library/std/src/sys/cloudabi/shims/os.rs | 86 - library/std/src/sys/cloudabi/shims/pipe.rs | 38 - library/std/src/sys/cloudabi/shims/process.rs | 149 - .../std/src/sys/cloudabi/stack_overflow.rs | 5 - library/std/src/sys/cloudabi/stdio.rs | 66 - library/std/src/sys/cloudabi/thread.rs | 118 - library/std/src/sys/cloudabi/time.rs | 82 - library/std/src/sys/mod.rs | 13 +- library/std/src/sys_common/mod.rs | 3 +- .../std/src/thread/available_concurrency.rs | 1 - library/std/src/time.rs | 4 - library/test/src/lib.rs | 2 +- library/unwind/build.rs | 2 - library/unwind/src/lib.rs | 1 - rustfmt.toml | 3 - .../build-cloudabi-toolchain.sh | 40 - src/doc/rustc/src/platform-support.md | 4 - src/test/codegen/dllimports/main.rs | 1 - src/test/codegen/panic-abort-windows.rs | 1 - src/test/run-pass-valgrind/exit-flushes.rs | 1 - src/test/ui/abi/segfault-no-out-of-stack.rs | 1 - src/test/ui/abi/stack-probes-lto.rs | 1 - src/test/ui/abi/stack-probes.rs | 1 - .../no_std-alloc-error-handler-custom.rs | 1 - .../no_std-alloc-error-handler-default.rs | 1 - src/test/ui/atomic-print.rs | 1 - src/test/ui/backtrace-debuginfo.rs | 1 - src/test/ui/backtrace.rs | 1 - src/test/ui/cfg/cfg-family.rs | 1 - src/test/ui/cfg/cfg-target-family.rs | 1 - src/test/ui/cleanup-shortcircuit.rs | 1 - src/test/ui/command/command-argv0-debug.rs | 1 - src/test/ui/command/command-argv0.rs | 1 - src/test/ui/command/command-exec.rs | 1 - src/test/ui/command/command-pre-exec.rs | 1 - src/test/ui/command/command-uid-gid.rs | 1 - src/test/ui/core-run-destroy.rs | 1 - src/test/ui/default-alloc-error-hook.rs | 1 - src/test/ui/env-args-reverse-iterator.rs | 1 - src/test/ui/env-funky-keys.rs | 1 - src/test/ui/env-home-dir.rs | 1 - src/test/ui/env-vars.rs | 1 - src/test/ui/error-codes/E0277.rs | 2 - src/test/ui/error-codes/E0277.stderr | 4 +- src/test/ui/exec-env.rs | 1 - src/test/ui/fds-are-cloexec.rs | 1 - src/test/ui/intrinsics/intrinsic-alignment.rs | 1 - src/test/ui/issues/issue-10626.rs | 1 - src/test/ui/issues/issue-12133-3.rs | 1 - src/test/ui/issues/issue-13304.rs | 1 - src/test/ui/issues/issue-14456.rs | 1 - src/test/ui/issues/issue-14940.rs | 1 - src/test/ui/issues/issue-16272.rs | 1 - src/test/ui/issues/issue-17121.rs | 1 - src/test/ui/issues/issue-20091.rs | 1 - src/test/ui/issues/issue-20644.rs | 1 - src/test/ui/issues/issue-20797.rs | 1 - src/test/ui/issues/issue-2214.rs | 2 +- src/test/ui/issues/issue-22577.rs | 1 - src/test/ui/issues/issue-23036.rs | 1 - src/test/ui/issues/issue-23649-2.rs | 1 - src/test/ui/issues/issue-24313.rs | 1 - src/test/ui/issues/issue-27859.rs | 1 - src/test/ui/issues/issue-30490.rs | 1 - src/test/ui/issues/issue-33770.rs | 1 - src/test/ui/issues/issue-37665.rs | 1 - src/test/ui/issues/issue-37665.stderr | 2 +- src/test/ui/issues/issue-39175.rs | 1 - src/test/ui/issues/issue-39175.stderr | 2 +- src/test/ui/issues/issue-4541.rs | 1 - src/test/ui/issues/issue-4542.rs | 1 - src/test/ui/issues/issue-46576.rs | 2 - src/test/ui/issues/issue-46576.stderr | 4 +- src/test/ui/lint/use_suggestion_json.rs | 1 - src/test/ui/lint/use_suggestion_json.stderr | 106 +- src/test/ui/mir/issue-77911.rs | 1 - src/test/ui/mir/mir_dynamic_drops_1.rs | 1 - src/test/ui/mir/mir_dynamic_drops_2.rs | 1 - src/test/ui/mir/mir_dynamic_drops_3.rs | 1 - .../ui/mismatched_types/recovered-block.rs | 2 - .../mismatched_types/recovered-block.stderr | 4 +- src/test/ui/multi-panic.rs | 1 - src/test/ui/never_type/issue-13352.rs | 2 - src/test/ui/never_type/issue-13352.stderr | 2 +- src/test/ui/no-stdio.rs | 1 - src/test/ui/out-of-stack.rs | 1 - .../abort-link-to-unwind-dylib.rs | 1 - .../abort-link-to-unwinding-crates.rs | 1 - src/test/ui/panic-runtime/abort.rs | 1 - src/test/ui/panic-runtime/lto-abort.rs | 1 - src/test/ui/panic-runtime/lto-unwind.rs | 1 - src/test/ui/panics/abort-on-panic.rs | 1 - .../ui/panics/issue-47429-short-backtraces.rs | 1 - .../issue-47429-short-backtraces.run.stderr | 2 +- src/test/ui/paths-containing-nul.rs | 1 - src/test/ui/print-stdout-eprint-stderr.rs | 1 - src/test/ui/process/process-envs.rs | 1 - src/test/ui/process/process-exit.rs | 1 - .../ui/process/process-remove-from-env.rs | 1 - src/test/ui/process/process-sigpipe.rs | 1 - .../ui/process/process-spawn-nonexistent.rs | 1 - .../process-spawn-with-unicode-params.rs | 1 - .../process/process-status-inherits-stdin.rs | 1 - src/test/ui/process/tls-exit-status.rs | 1 - src/test/ui/resolve/token-error-correct-3.rs | 2 - .../ui/resolve/token-error-correct-3.stderr | 6 +- .../ui/resolve/use_suggestion_placement.rs | 2 - .../resolve/use_suggestion_placement.stderr | 6 +- src/test/ui/rfcs/rfc-1014.rs | 1 - src/test/ui/running-with-no-runtime.rs | 1 - src/test/ui/signal-alternate-stack-cleanup.rs | 1 - src/test/ui/signal-exit-status.rs | 1 - src/test/ui/sigpipe-should-be-ignored.rs | 1 - src/test/ui/span/issue-33884.rs | 2 - src/test/ui/span/issue-33884.stderr | 2 +- src/test/ui/sse2.rs | 1 - src/test/ui/std-backtrace.rs | 1 - src/test/ui/stdio-is-blocking.rs | 1 - src/test/ui/structs-enums/rec-align-u64.rs | 1 - src/test/ui/tcp-stress.rs | 1 - .../ui/threads-sendsync/sync-send-in-std.rs | 1 - src/test/ui/try-operator-on-main.rs | 2 - src/test/ui/try-operator-on-main.stderr | 8 +- src/test/ui/try-operator.rs | 1 - src/test/ui/try-wait.rs | 1 - src/test/ui/wait-forked-but-failed-child.rs | 1 - src/test/ui/x86stdcall.rs | 1 - src/tools/build-manifest/src/main.rs | 2 - src/tools/clippy/clippy_lints/src/attrs.rs | 2 +- .../ui/mismatched_target_os_non_unix.fixed | 5 +- .../tests/ui/mismatched_target_os_non_unix.rs | 5 +- .../ui/mismatched_target_os_non_unix.stderr | 35 +- src/tools/compiletest/src/runtest.rs | 3 +- src/tools/compiletest/src/util.rs | 1 - src/tools/tidy/src/style.rs | 1 - src/tools/tidy/src/unit_tests.rs | 2 - 165 files changed, 103 insertions(+), 5329 deletions(-) delete mode 100644 compiler/rustc_target/src/spec/aarch64_unknown_cloudabi.rs delete mode 100644 compiler/rustc_target/src/spec/armv7_unknown_cloudabi_eabihf.rs delete mode 100644 compiler/rustc_target/src/spec/cloudabi_base.rs delete mode 100644 compiler/rustc_target/src/spec/i686_unknown_cloudabi.rs delete mode 100644 compiler/rustc_target/src/spec/x86_64_unknown_cloudabi.rs delete mode 100644 library/std/src/sys/cloudabi/abi/bitflags.rs delete mode 100644 library/std/src/sys/cloudabi/abi/cloudabi.rs delete mode 100644 library/std/src/sys/cloudabi/abi/mod.rs delete mode 100644 library/std/src/sys/cloudabi/args.rs delete mode 100644 library/std/src/sys/cloudabi/condvar.rs delete mode 100644 library/std/src/sys/cloudabi/io.rs delete mode 100644 library/std/src/sys/cloudabi/mod.rs delete mode 100644 library/std/src/sys/cloudabi/mutex.rs delete mode 100644 library/std/src/sys/cloudabi/os.rs delete mode 100644 library/std/src/sys/cloudabi/rwlock.rs delete mode 100644 library/std/src/sys/cloudabi/shims/args.rs delete mode 100644 library/std/src/sys/cloudabi/shims/env.rs delete mode 100644 library/std/src/sys/cloudabi/shims/fs.rs delete mode 100644 library/std/src/sys/cloudabi/shims/mod.rs delete mode 100644 library/std/src/sys/cloudabi/shims/net.rs delete mode 100644 library/std/src/sys/cloudabi/shims/os.rs delete mode 100644 library/std/src/sys/cloudabi/shims/pipe.rs delete mode 100644 library/std/src/sys/cloudabi/shims/process.rs delete mode 100644 library/std/src/sys/cloudabi/stack_overflow.rs delete mode 100644 library/std/src/sys/cloudabi/stdio.rs delete mode 100644 library/std/src/sys/cloudabi/thread.rs delete mode 100644 library/std/src/sys/cloudabi/time.rs delete mode 100755 src/ci/docker/host-x86_64/dist-various-2/build-cloudabi-toolchain.sh diff --git a/compiler/rustc_codegen_cranelift/build_sysroot/alloc_system/lib.rs b/compiler/rustc_codegen_cranelift/build_sysroot/alloc_system/lib.rs index ca145e4f2a5..c832d5e5ebb 100644 --- a/compiler/rustc_codegen_cranelift/build_sysroot/alloc_system/lib.rs +++ b/compiler/rustc_codegen_cranelift/build_sysroot/alloc_system/lib.rs @@ -23,7 +23,7 @@ all(target_arch = "wasm32", not(target_os = "emscripten")), feature(integer_atomics, stdsimd) )] -#![cfg_attr(any(unix, target_os = "cloudabi", target_os = "redox"), feature(libc))] +#![cfg_attr(any(unix, target_os = "redox"), feature(libc))] // The minimum alignment guaranteed by the architecture. This value is used to // add fast paths for low alignment values. #[cfg(all(any(target_arch = "x86", @@ -69,7 +69,7 @@ const MIN_ALIGN: usize = 16; /// independently of the standard library’s global allocator. #[stable(feature = "alloc_system_type", since = "1.28.0")] pub struct System; -#[cfg(any(windows, unix, target_os = "cloudabi", target_os = "redox"))] +#[cfg(any(windows, unix, target_os = "redox"))] mod realloc_fallback { use core::alloc::{GlobalAlloc, Layout}; use core::cmp; @@ -89,7 +89,7 @@ mod realloc_fallback { } } } -#[cfg(any(unix, target_os = "cloudabi", target_os = "redox"))] +#[cfg(any(unix, target_os = "redox"))] mod platform { extern crate libc; use core::ptr; diff --git a/compiler/rustc_target/src/spec/aarch64_unknown_cloudabi.rs b/compiler/rustc_target/src/spec/aarch64_unknown_cloudabi.rs deleted file mode 100644 index 67f69b40e55..00000000000 --- a/compiler/rustc_target/src/spec/aarch64_unknown_cloudabi.rs +++ /dev/null @@ -1,16 +0,0 @@ -use crate::spec::Target; - -pub fn target() -> Target { - let mut base = super::cloudabi_base::opts(); - base.max_atomic_width = Some(128); - base.unsupported_abis = super::arm_base::unsupported_abis(); - base.linker = Some("aarch64-unknown-cloudabi-cc".to_string()); - - Target { - llvm_target: "aarch64-unknown-cloudabi".to_string(), - pointer_width: 64, - data_layout: "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128".to_string(), - arch: "aarch64".to_string(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/armv7_unknown_cloudabi_eabihf.rs b/compiler/rustc_target/src/spec/armv7_unknown_cloudabi_eabihf.rs deleted file mode 100644 index d47ee541b25..00000000000 --- a/compiler/rustc_target/src/spec/armv7_unknown_cloudabi_eabihf.rs +++ /dev/null @@ -1,18 +0,0 @@ -use crate::spec::{Target, TargetOptions}; - -pub fn target() -> Target { - let mut base = super::cloudabi_base::opts(); - base.cpu = "cortex-a8".to_string(); - base.max_atomic_width = Some(64); - base.features = "+v7,+vfp3,+neon".to_string(); - base.unsupported_abis = super::arm_base::unsupported_abis(); - base.linker = Some("armv7-unknown-cloudabi-eabihf-cc".to_string()); - - Target { - llvm_target: "armv7-unknown-cloudabi-eabihf".to_string(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64".to_string(), - arch: "arm".to_string(), - options: TargetOptions { mcount: "\u{1}mcount".to_string(), ..base }, - } -} diff --git a/compiler/rustc_target/src/spec/cloudabi_base.rs b/compiler/rustc_target/src/spec/cloudabi_base.rs deleted file mode 100644 index 20a095742ec..00000000000 --- a/compiler/rustc_target/src/spec/cloudabi_base.rs +++ /dev/null @@ -1,36 +0,0 @@ -use crate::spec::{LinkArgs, LinkerFlavor, RelroLevel, TargetOptions, TlsModel}; - -pub fn opts() -> TargetOptions { - let mut args = LinkArgs::new(); - args.insert( - LinkerFlavor::Gcc, - vec![ - "-Wl,-Bstatic".to_string(), - "-Wl,--no-dynamic-linker".to_string(), - "-Wl,--gc-sections".to_string(), - ], - ); - - TargetOptions { - os: "cloudabi".to_string(), - executables: true, - os_family: None, - linker_is_gnu: true, - pre_link_args: args, - position_independent_executables: true, - // As CloudABI only supports static linkage, there is no need - // for dynamic TLS. The C library therefore does not provide - // __tls_get_addr(), which is normally used to perform dynamic - // TLS lookups by programs that make use of dlopen(). Only the - // "local-exec" and "initial-exec" TLS models can be used. - // - // "local-exec" is more efficient than "initial-exec", as the - // latter has one more level of indirection: it accesses the GOT - // (Global Offset Table) to obtain the effective address of a - // thread-local variable. Using a GOT is useful only when doing - // dynamic linking. - tls_model: TlsModel::LocalExec, - relro_level: RelroLevel::Full, - ..Default::default() - } -} diff --git a/compiler/rustc_target/src/spec/i686_unknown_cloudabi.rs b/compiler/rustc_target/src/spec/i686_unknown_cloudabi.rs deleted file mode 100644 index 0cdb9f9de56..00000000000 --- a/compiler/rustc_target/src/spec/i686_unknown_cloudabi.rs +++ /dev/null @@ -1,20 +0,0 @@ -use crate::spec::{LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut base = super::cloudabi_base::opts(); - base.cpu = "pentium4".to_string(); - base.max_atomic_width = Some(64); - base.linker = Some("i686-unknown-cloudabi-cc".to_string()); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m32".to_string()); - base.stack_probes = true; - - Target { - llvm_target: "i686-unknown-cloudabi".to_string(), - pointer_width: 32, - data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\ - f64:32:64-f80:32-n8:16:32-S128" - .to_string(), - arch: "x86".to_string(), - options: base, - } -} diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 045da7963c5..1bda33939b8 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -54,7 +54,6 @@ mod apple_base; mod apple_sdk_base; mod arm_base; mod avr_gnu_base; -mod cloudabi_base; mod dragonfly_base; mod freebsd_base; mod fuchsia_base; @@ -628,11 +627,6 @@ supported_targets! { ("msp430-none-elf", msp430_none_elf), - ("aarch64-unknown-cloudabi", aarch64_unknown_cloudabi), - ("armv7-unknown-cloudabi-eabihf", armv7_unknown_cloudabi_eabihf), - ("i686-unknown-cloudabi", i686_unknown_cloudabi), - ("x86_64-unknown-cloudabi", x86_64_unknown_cloudabi), - ("aarch64-unknown-hermit", aarch64_unknown_hermit), ("x86_64-unknown-hermit", x86_64_unknown_hermit), ("x86_64-unknown-hermit-kernel", x86_64_unknown_hermit_kernel), diff --git a/compiler/rustc_target/src/spec/x86_64_unknown_cloudabi.rs b/compiler/rustc_target/src/spec/x86_64_unknown_cloudabi.rs deleted file mode 100644 index cf57f4ec624..00000000000 --- a/compiler/rustc_target/src/spec/x86_64_unknown_cloudabi.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::spec::{LinkerFlavor, Target}; - -pub fn target() -> Target { - let mut base = super::cloudabi_base::opts(); - base.cpu = "x86-64".to_string(); - base.max_atomic_width = Some(64); - base.linker = Some("x86_64-unknown-cloudabi-cc".to_string()); - base.pre_link_args.get_mut(&LinkerFlavor::Gcc).unwrap().push("-m64".to_string()); - base.stack_probes = true; - - Target { - llvm_target: "x86_64-unknown-cloudabi".to_string(), - pointer_width: 64, - data_layout: "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" - .to_string(), - arch: "x86_64".to_string(), - options: base, - } -} diff --git a/library/panic_abort/src/lib.rs b/library/panic_abort/src/lib.rs index 9690996e602..a8ebb4b3219 100644 --- a/library/panic_abort/src/lib.rs +++ b/library/panic_abort/src/lib.rs @@ -32,7 +32,7 @@ pub unsafe extern "C" fn __rust_start_panic(_payload: usize) -> u32 { abort(); cfg_if::cfg_if! { - if #[cfg(any(unix, target_os = "cloudabi"))] { + if #[cfg(unix)] { unsafe fn abort() -> ! { libc::abort(); } diff --git a/library/panic_unwind/src/lib.rs b/library/panic_unwind/src/lib.rs index 682289384c8..0b74a844fec 100644 --- a/library/panic_unwind/src/lib.rs +++ b/library/panic_unwind/src/lib.rs @@ -49,7 +49,6 @@ cfg_if::cfg_if! { mod real_imp; } else if #[cfg(any( all(target_family = "windows", target_env = "gnu"), - target_os = "cloudabi", target_os = "psp", target_family = "unix", all(target_vendor = "fortanix", target_env = "sgx"), diff --git a/library/std/build.rs b/library/std/build.rs index f730569f74b..a14ac63c7a8 100644 --- a/library/std/build.rs +++ b/library/std/build.rs @@ -18,7 +18,6 @@ fn main() { || target.contains("uwp") || target.contains("windows") || target.contains("fuchsia") - || target.contains("cloudabi") || (target.contains("sgx") && target.contains("fortanix")) || target.contains("hermit") || target.contains("l4re") diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs index 4cff6cb6f10..e2d4f2e6a56 100644 --- a/library/std/src/fs.rs +++ b/library/std/src/fs.rs @@ -8,7 +8,7 @@ #![stable(feature = "rust1", since = "1.0.0")] #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten", target_env = "sgx"))))] +#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx"))))] mod tests; use crate::ffi::OsString; diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs index 58c6343ea34..325acf0b979 100644 --- a/library/std/src/net/tcp.rs +++ b/library/std/src/net/tcp.rs @@ -1,6 +1,6 @@ #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten"))))] +#[cfg(all(test, not(target_os = "emscripten")))] mod tests; use crate::io::prelude::*; diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs index 17e3e4497c4..2377a76a33d 100644 --- a/library/std/src/net/udp.rs +++ b/library/std/src/net/udp.rs @@ -1,4 +1,4 @@ -#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten", target_env = "sgx"))))] +#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx"))))] mod tests; use crate::fmt; diff --git a/library/std/src/process.rs b/library/std/src/process.rs index 2c7ed4614bc..77a11ac8201 100644 --- a/library/std/src/process.rs +++ b/library/std/src/process.rs @@ -97,7 +97,7 @@ #![stable(feature = "process", since = "1.0.0")] #![deny(unsafe_op_in_unsafe_fn)] -#[cfg(all(test, not(any(target_os = "cloudabi", target_os = "emscripten", target_env = "sgx"))))] +#[cfg(all(test, not(any(target_os = "emscripten", target_env = "sgx"))))] mod tests; use crate::io::prelude::*; diff --git a/library/std/src/sys/cloudabi/abi/bitflags.rs b/library/std/src/sys/cloudabi/abi/bitflags.rs deleted file mode 100644 index 2383277ad72..00000000000 --- a/library/std/src/sys/cloudabi/abi/bitflags.rs +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2018 Nuxi (https://nuxi.nl/) and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. - -#[cfg(feature = "bitflags")] -use bitflags::bitflags; - -// Minimal implementation of bitflags! in case we can't depend on the bitflags -// crate. Only implements `bits()` and a `from_bits_truncate()` that doesn't -// actually truncate. -#[cfg(not(feature = "bitflags"))] -macro_rules! bitflags { - ( - $(#[$attr:meta])* - pub struct $name:ident: $type:ty { - $($(#[$const_attr:meta])* const $const:ident = $val:expr;)* - } - ) => { - $(#[$attr])* - #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] - pub struct $name { bits: $type } - impl $name { - $($(#[$const_attr])* pub const $const: $name = $name{ bits: $val };)* - pub fn bits(&self) -> $type { self.bits } - pub fn from_bits_truncate(bits: $type) -> Self { $name{ bits } } - } - } -} diff --git a/library/std/src/sys/cloudabi/abi/cloudabi.rs b/library/std/src/sys/cloudabi/abi/cloudabi.rs deleted file mode 100644 index d67f0f81a9f..00000000000 --- a/library/std/src/sys/cloudabi/abi/cloudabi.rs +++ /dev/null @@ -1,2954 +0,0 @@ -// Copyright (c) 2016-2017 Nuxi and contributors. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -// ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -// OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -// HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -// SUCH DAMAGE. -// -// This file is automatically generated. Do not edit. -// -// Source: https://github.com/NuxiNL/cloudabi - -// Appease Rust's tidy. -// ignore-tidy-linelength - -//! **PLEASE NOTE: This entire crate including this -//! documentation is automatically generated from -//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt)** -//! -//! # Nuxi CloudABI -//! -//! CloudABI is what you get if you take POSIX, add capability-based -//! security, and remove everything that's incompatible with that. The -//! result is a minimal ABI consisting of only 49 syscalls. -//! -//! CloudABI doesn't have its own kernel, but instead is implemented in existing -//! kernels: FreeBSD has CloudABI support for x86-64 and arm64, and [a patch-set -//! for NetBSD](https://github.com/NuxiNL/netbsd) and [a patch-set for -//! Linux](https://github.com/NuxiNL/linux) are available as well. This means that -//! CloudABI binaries can be executed on different operating systems, without any -//! modification. -//! -//! ## Capability-Based Security -//! -//! Capability-based security means that processes can only perform -//! actions that have no global impact. Processes cannot open files by -//! their absolute path, cannot open network connections, and cannot -//! observe global system state such as the process table. -//! -//! The capabilities of a process are fully determined by its set of open -//! file descriptors (fds). For example, files can only be opened if the -//! process already has a file descriptor to a directory the file is in. -//! -//! Unlike in POSIX, where processes are normally started with file -//! descriptors 0, 1, and 2 reserved for standard input, output, and -//! error, CloudABI does not reserve any file descriptor numbers for -//! specific purposes. -//! -//! In CloudABI, a process depends on its parent process to launch it with -//! the right set of resources, since the process will not be able to open -//! any new resources. For example, a simple static web server would need -//! to be started with a file descriptor to a [TCP -//! listener](https://github.com/NuxiNL/flower), and a file descriptor to -//! the directory for which to serve files. The web server will then be -//! unable to do anything other than reading files in that directory, and -//! process incoming network connections. -//! -//! So, unknown CloudABI binaries can safely be executed without the need -//! for containers, virtual machines, or other sandboxing technologies. -//! -//! Watch [Ed Schouten's Talk at -//! 32C3](https://www.youtube.com/watch?v=3N29vrPoDv8) for more -//! information about what capability-based security for UNIX means. -//! -//! ## Cloudlibc -//! -//! [Cloudlibc](https://github.com/NuxiNL/cloudlibc) is an implementation -//! of the C standard library, without all CloudABI-incompatible -//! functions. For example, Cloudlibc does not have `printf`, but does -//! have `fprintf`. It does not have `open`, but does have `openat`. -//! -//! ## CloudABI-Ports -//! -//! [CloudABI-Ports](https://github.com/NuxiNL/cloudabi-ports) is a -//! collection of ports of commonly used libraries and applications to -//! CloudABI. It contains software such as `zlib`, `libpng`, `boost`, -//! `memcached`, and much more. The software is patched to not depend on -//! any global state, such as files in `/etc` or `/dev`, using `open()`, -//! etc. -//! -//! ## Using CloudABI -//! -//! Instructions for using CloudABI (including kernel modules/patches, -//! toolchain, and ports) are available for several operating systems: -//! -//! - [Arch Linux](https://nuxi.nl/cloudabi/archlinux/) -//! - [Debian, Ubuntu, and other Debian derivatives](https://nuxi.nl/cloudabi/debian/) -//! - [FreeBSD, PC-BSD and DragonFly BSD](https://nuxi.nl/cloudabi/freebsd/) -//! - [Mac OS X](https://nuxi.nl/cloudabi/mac/) -//! - [NetBSD](https://nuxi.nl/cloudabi/netbsd/) -//! -//! ## Specification of the ABI -//! -//! The entire ABI is specified in a file called -//! [`cloudabi.txt`](https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt), -//! from which all -//! [headers](https://github.com/NuxiNL/cloudabi/tree/master/headers) -//! and documentation (including the one you're reading now) is generated. - -#![no_std] -#![allow(non_camel_case_types)] -#![allow(deprecated)] // FIXME: using `mem::uninitialized()` - -include!("bitflags.rs"); - -/// File or memory access pattern advisory information. -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum advice { - /// The application expects that it will not access the - /// specified data in the near future. - DONTNEED = 1, - /// The application expects to access the specified data - /// once and then not reuse it thereafter. - NOREUSE = 2, - /// The application has no advice to give on its behavior - /// with respect to the specified data. - NORMAL = 3, - /// The application expects to access the specified data - /// in a random order. - RANDOM = 4, - /// The application expects to access the specified data - /// sequentially from lower offsets to higher offsets. - SEQUENTIAL = 5, - /// The application expects to access the specified data - /// in the near future. - WILLNEED = 6, -} - -/// Enumeration describing the kind of value stored in [`auxv`]. -#[repr(u32)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum auxtype { - /// Base address of the binary argument data provided to - /// [`proc_exec()`](fn.proc_exec.html). - ARGDATA = 256, - /// Length of the binary argument data provided to - /// [`proc_exec()`](fn.proc_exec.html). - ARGDATALEN = 257, - /// Base address at which the executable is placed in - /// memory. - BASE = 7, - /// Base address of a buffer of random data that may be - /// used for non-cryptographic purposes, for example as a - /// canary for stack smashing protection. - CANARY = 258, - /// Length of a buffer of random data that may be used - /// for non-cryptographic purposes, for example as a - /// canary for stack smashing protection. - CANARYLEN = 259, - /// Number of CPUs that the system this process is running - /// on has. - NCPUS = 260, - /// Terminator of the auxiliary vector. - NULL = 0, - /// Smallest memory object size for which individual - /// memory protection controls can be configured. - PAGESZ = 6, - /// Address of the first ELF program header of the - /// executable. - PHDR = 3, - /// Number of ELF program headers of the executable. - PHNUM = 4, - /// Identifier of the process. - /// - /// This environment does not provide any simple numerical - /// process identifiers, for the reason that these are not - /// useful in distributed contexts. Instead, processes are - /// identified by a UUID. - /// - /// This record should point to sixteen bytes of binary - /// data, containing a version 4 UUID (fully random). - PID = 263, - /// Address of the ELF header of the vDSO. - /// - /// The vDSO is a shared library that is mapped in the - /// address space of the process. It provides entry points - /// for every system call supported by the environment, - /// all having a corresponding symbol that is prefixed - /// with `cloudabi_sys_`. System calls should be invoked - /// through these entry points. - /// - /// The first advantage of letting processes call into a - /// vDSO to perform system calls instead of raising - /// hardware traps is that it allows for easy emulation of - /// executables on top of existing operating systems. The - /// second advantage is that in cases where an operating - /// system provides native support for CloudABI executables, - /// it may still implement partial userspace - /// implementations of these system calls to improve - /// performance (e.g., [`clock_time_get()`](fn.clock_time_get.html)). It also provides - /// a more dynamic way of adding, removing or replacing - /// system calls. - SYSINFO_EHDR = 262, - /// Thread ID of the initial thread of the process. - TID = 261, -} - -/// Identifiers for clocks. -#[repr(u32)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum clockid { - /// The system-wide monotonic clock, which is defined as a - /// clock measuring real time, whose value cannot be - /// adjusted and which cannot have negative clock jumps. - /// - /// The epoch of this clock is undefined. The absolute - /// time value of this clock therefore has no meaning. - MONOTONIC = 1, - /// The CPU-time clock associated with the current - /// process. - PROCESS_CPUTIME_ID = 2, - /// The system-wide clock measuring real time. Time value - /// zero corresponds with 1970-01-01T00:00:00Z. - REALTIME = 3, - /// The CPU-time clock associated with the current thread. - THREAD_CPUTIME_ID = 4, -} - -/// A userspace condition variable. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct condvar(pub u32); -/// The condition variable is in its initial state. There -/// are no threads waiting to be woken up. If the -/// condition variable has any other value, the kernel -/// must be called to wake up any sleeping threads. -pub const CONDVAR_HAS_NO_WAITERS: condvar = condvar(0); - -/// Identifier for a device containing a file system. Can be used -/// in combination with [`inode`] to uniquely identify a file on the -/// local system. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct device(pub u64); - -/// A reference to the offset of a directory entry. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct dircookie(pub u64); -/// Permanent reference to the first directory entry -/// within a directory. -pub const DIRCOOKIE_START: dircookie = dircookie(0); - -/// Error codes returned by system calls. -/// -/// Not all of these error codes are returned by the system calls -/// provided by this environment, but are either used in userspace -/// exclusively or merely provided for alignment with POSIX. -#[repr(u16)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum errno { - /// No error occurred. System call completed successfully. - SUCCESS = 0, - /// Argument list too long. - TOOBIG = 1, - /// Permission denied. - ACCES = 2, - /// Address in use. - ADDRINUSE = 3, - /// Address not available. - ADDRNOTAVAIL = 4, - /// Address family not supported. - AFNOSUPPORT = 5, - /// Resource unavailable, or operation would block. - AGAIN = 6, - /// Connection already in progress. - ALREADY = 7, - /// Bad file descriptor. - BADF = 8, - /// Bad message. - BADMSG = 9, - /// Device or resource busy. - BUSY = 10, - /// Operation canceled. - CANCELED = 11, - /// No child processes. - CHILD = 12, - /// Connection aborted. - CONNABORTED = 13, - /// Connection refused. - CONNREFUSED = 14, - /// Connection reset. - CONNRESET = 15, - /// Resource deadlock would occur. - DEADLK = 16, - /// Destination address required. - DESTADDRREQ = 17, - /// Mathematics argument out of domain of function. - DOM = 18, - /// Reserved. - DQUOT = 19, - /// File exists. - EXIST = 20, - /// Bad address. - FAULT = 21, - /// File too large. - FBIG = 22, - /// Host is unreachable. - HOSTUNREACH = 23, - /// Identifier removed. - IDRM = 24, - /// Illegal byte sequence. - ILSEQ = 25, - /// Operation in progress. - INPROGRESS = 26, - /// Interrupted function. - INTR = 27, - /// Invalid argument. - INVAL = 28, - /// I/O error. - IO = 29, - /// Socket is connected. - ISCONN = 30, - /// Is a directory. - ISDIR = 31, - /// Too many levels of symbolic links. - LOOP = 32, - /// File descriptor value too large. - MFILE = 33, - /// Too many links. - MLINK = 34, - /// Message too large. - MSGSIZE = 35, - /// Reserved. - MULTIHOP = 36, - /// Filename too long. - NAMETOOLONG = 37, - /// Network is down. - NETDOWN = 38, - /// Connection aborted by network. - NETRESET = 39, - /// Network unreachable. - NETUNREACH = 40, - /// Too many files open in system. - NFILE = 41, - /// No buffer space available. - NOBUFS = 42, - /// No such device. - NODEV = 43, - /// No such file or directory. - NOENT = 44, - /// Executable file format error. - NOEXEC = 45, - /// No locks available. - NOLCK = 46, - /// Reserved. - NOLINK = 47, - /// Not enough space. - NOMEM = 48, - /// No message of the desired type. - NOMSG = 49, - /// Protocol not available. - NOPROTOOPT = 50, - /// No space left on device. - NOSPC = 51, - /// Function not supported. - NOSYS = 52, - /// The socket is not connected. - NOTCONN = 53, - /// Not a directory or a symbolic link to a directory. - NOTDIR = 54, - /// Directory not empty. - NOTEMPTY = 55, - /// State not recoverable. - NOTRECOVERABLE = 56, - /// Not a socket. - NOTSOCK = 57, - /// Not supported, or operation not supported on socket. - NOTSUP = 58, - /// Inappropriate I/O control operation. - NOTTY = 59, - /// No such device or address. - NXIO = 60, - /// Value too large to be stored in data type. - OVERFLOW = 61, - /// Previous owner died. - OWNERDEAD = 62, - /// Operation not permitted. - PERM = 63, - /// Broken pipe. - PIPE = 64, - /// Protocol error. - PROTO = 65, - /// Protocol not supported. - PROTONOSUPPORT = 66, - /// Protocol wrong type for socket. - PROTOTYPE = 67, - /// Result too large. - RANGE = 68, - /// Read-only file system. - ROFS = 69, - /// Invalid seek. - SPIPE = 70, - /// No such process. - SRCH = 71, - /// Reserved. - STALE = 72, - /// Connection timed out. - TIMEDOUT = 73, - /// Text file busy. - TXTBSY = 74, - /// Cross-device link. - XDEV = 75, - /// Extension: Capabilities insufficient. - NOTCAPABLE = 76, -} - -bitflags! { - /// The state of the file descriptor subscribed to with - /// [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). - #[repr(C)] - pub struct eventrwflags: u16 { - /// The peer of this socket has closed or disconnected. - const HANGUP = 0x0001; - } -} - -/// Type of a subscription to an event or its occurrence. -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum eventtype { - /// The time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id) - /// has reached timestamp [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout). - CLOCK = 1, - /// Condition variable [`subscription.union.condvar.condvar`](struct.subscription_condvar.html#structfield.condvar) has - /// been woken up and [`subscription.union.condvar.lock`](struct.subscription_condvar.html#structfield.lock) has been - /// acquired for writing. - CONDVAR = 2, - /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has - /// data available for reading. This event always triggers - /// for regular files. - FD_READ = 3, - /// File descriptor [`subscription.union.fd_readwrite.fd`](struct.subscription_fd_readwrite.html#structfield.fd) has - /// capacity available for writing. This event always - /// triggers for regular files. - FD_WRITE = 4, - /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for - /// reading. - LOCK_RDLOCK = 5, - /// Lock [`subscription.union.lock.lock`](struct.subscription_lock.html#structfield.lock) has been acquired for - /// writing. - LOCK_WRLOCK = 6, - /// The process associated with process descriptor - /// [`subscription.union.proc_terminate.fd`](struct.subscription_proc_terminate.html#structfield.fd) has terminated. - PROC_TERMINATE = 7, -} - -/// Exit code generated by a process when exiting. -pub type exitcode = u32; - -/// A file descriptor number. -/// -/// Unlike on POSIX-compliant systems, none of the file descriptor -/// numbers are reserved for a purpose (e.g., stdin, stdout, -/// stderr). Operating systems are not required to allocate new -/// file descriptors in ascending order. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct fd(pub u32); -/// Returned to the child process by [`proc_fork()`](fn.proc_fork.html). -pub const PROCESS_CHILD: fd = fd(0xffffffff); -/// Passed to [`mem_map()`](fn.mem_map.html) when creating a mapping to -/// anonymous memory. -pub const MAP_ANON_FD: fd = fd(0xffffffff); - -bitflags! { - /// File descriptor flags. - #[repr(C)] - pub struct fdflags: u16 { - /// Append mode: Data written to the file is always - /// appended to the file's end. - const APPEND = 0x0001; - /// Write according to synchronized I/O data integrity - /// completion. Only the data stored in the file is - /// synchronized. - const DSYNC = 0x0002; - /// Non-blocking mode. - const NONBLOCK = 0x0004; - /// Synchronized read I/O operations. - const RSYNC = 0x0008; - /// Write according to synchronized I/O file integrity - /// completion. In addition to synchronizing the data - /// stored in the file, the system may also synchronously - /// update the file's metadata. - const SYNC = 0x0010; - } -} - -bitflags! { - /// Which file descriptor attributes to adjust. - #[repr(C)] - pub struct fdsflags: u16 { - /// Adjust the file descriptor flags stored in - /// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags). - const FLAGS = 0x0001; - /// Restrict the rights of the file descriptor to the - /// rights stored in [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and - /// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting). - const RIGHTS = 0x0002; - } -} - -/// Relative offset within a file. -pub type filedelta = i64; - -/// Non-negative file size or length of a region within a file. -pub type filesize = u64; - -/// The type of a file descriptor or file. -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum filetype { - /// The type of the file descriptor or file is unknown or - /// is different from any of the other types specified. - UNKNOWN = 0, - /// The file descriptor or file refers to a block device - /// inode. - BLOCK_DEVICE = 16, - /// The file descriptor or file refers to a character - /// device inode. - CHARACTER_DEVICE = 17, - /// The file descriptor or file refers to a directory - /// inode. - DIRECTORY = 32, - /// The file descriptor refers to a process handle. - PROCESS = 80, - /// The file descriptor or file refers to a regular file - /// inode. - REGULAR_FILE = 96, - /// The file descriptor refers to a shared memory object. - SHARED_MEMORY = 112, - /// The file descriptor or file refers to a datagram - /// socket. - SOCKET_DGRAM = 128, - /// The file descriptor or file refers to a byte-stream - /// socket. - SOCKET_STREAM = 130, - /// The file refers to a symbolic link inode. - SYMBOLIC_LINK = 144, -} - -bitflags! { - /// Which file attributes to adjust. - #[repr(C)] - pub struct fsflags: u16 { - /// Adjust the last data access timestamp to the value - /// stored in [`filestat.st_atim`](struct.filestat.html#structfield.st_atim). - const ATIM = 0x0001; - /// Adjust the last data access timestamp to the time - /// of clock [`REALTIME`](enum.clockid.html#variant.REALTIME). - const ATIM_NOW = 0x0002; - /// Adjust the last data modification timestamp to the - /// value stored in [`filestat.st_mtim`](struct.filestat.html#structfield.st_mtim). - const MTIM = 0x0004; - /// Adjust the last data modification timestamp to the - /// time of clock [`REALTIME`](enum.clockid.html#variant.REALTIME). - const MTIM_NOW = 0x0008; - /// Truncate or extend the file to the size stored in - /// [`filestat.st_size`](struct.filestat.html#structfield.st_size). - const SIZE = 0x0010; - } -} - -/// File serial number that is unique within its file system. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct inode(pub u64); - -/// Number of hard links to an inode. -pub type linkcount = u32; - -/// A userspace read-recursive readers-writer lock, similar to a -/// Linux futex or a FreeBSD umtx. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct lock(pub u32); -/// Value indicating that the lock is in its initial -/// unlocked state. -pub const LOCK_UNLOCKED: lock = lock(0x00000000); -/// Bitmask indicating that the lock is write-locked. If -/// set, the lower 30 bits of the lock contain the -/// identifier of the thread that owns the write lock. -/// Otherwise, the lower 30 bits of the lock contain the -/// number of acquired read locks. -pub const LOCK_WRLOCKED: lock = lock(0x40000000); -/// Bitmask indicating that the lock is either read locked -/// or write locked, and that one or more threads have -/// their execution suspended, waiting to acquire the -/// lock. The last owner of the lock must call the -/// kernel to unlock. -/// -/// When the lock is acquired for reading and this bit is -/// set, it means that one or more threads are attempting -/// to acquire this lock for writing. In that case, other -/// threads should only acquire additional read locks if -/// suspending execution would cause a deadlock. It is -/// preferred to suspend execution, as this prevents -/// starvation of writers. -pub const LOCK_KERNEL_MANAGED: lock = lock(0x80000000); -/// Value indicating that the lock is in an incorrect -/// state. A lock cannot be in its initial unlocked state, -/// while also managed by the kernel. -pub const LOCK_BOGUS: lock = lock(0x80000000); - -bitflags! { - /// Flags determining the method of how paths are resolved. - #[repr(C)] - pub struct lookupflags: u32 { - /// As long as the resolved path corresponds to a symbolic - /// link, it is expanded. - const SYMLINK_FOLLOW = 0x00000001; - } -} - -bitflags! { - /// Memory mapping flags. - #[repr(C)] - pub struct mflags: u8 { - /// Instead of mapping the contents of the file provided, - /// create a mapping to anonymous memory. The file - /// descriptor argument must be set to [`MAP_ANON_FD`](constant.MAP_ANON_FD.html), - /// and the offset must be set to zero. - const ANON = 0x01; - /// Require that the mapping is performed at the base - /// address provided. - const FIXED = 0x02; - /// Changes are private. - const PRIVATE = 0x04; - /// Changes are shared. - const SHARED = 0x08; - } -} - -bitflags! { - /// Memory page protection options. - /// - /// This implementation enforces the `W^X` property: Pages cannot be - /// mapped for execution while also mapped for writing. - #[repr(C)] - pub struct mprot: u8 { - /// Page can be executed. - const EXEC = 0x01; - /// Page can be written. - const WRITE = 0x02; - /// Page can be read. - const READ = 0x04; - } -} - -bitflags! { - /// Methods of synchronizing memory with physical storage. - #[repr(C)] - pub struct msflags: u8 { - /// Performs asynchronous writes. - const ASYNC = 0x01; - /// Invalidates cached data. - const INVALIDATE = 0x02; - /// Performs synchronous writes. - const SYNC = 0x04; - } -} - -/// Specifies the number of threads sleeping on a condition -/// variable that should be woken up. -pub type nthreads = u32; - -bitflags! { - /// Open flags used by [`file_open()`](fn.file_open.html). - #[repr(C)] - pub struct oflags: u16 { - /// Create file if it does not exist. - const CREAT = 0x0001; - /// Fail if not a directory. - const DIRECTORY = 0x0002; - /// Fail if file already exists. - const EXCL = 0x0004; - /// Truncate file to size 0. - const TRUNC = 0x0008; - } -} - -bitflags! { - /// Flags provided to [`sock_recv()`](fn.sock_recv.html). - #[repr(C)] - pub struct riflags: u16 { - /// Returns the message without removing it from the - /// socket's receive queue. - const PEEK = 0x0004; - /// On byte-stream sockets, block until the full amount - /// of data can be returned. - const WAITALL = 0x0010; - } -} - -bitflags! { - /// File descriptor rights, determining which actions may be - /// performed. - #[repr(C)] - pub struct rights: u64 { - /// The right to invoke [`fd_datasync()`](fn.fd_datasync.html). - /// - /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to - /// invoke [`file_open()`](fn.file_open.html) with [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC). - const FD_DATASYNC = 0x0000000000000001; - /// The right to invoke [`fd_read()`](fn.fd_read.html) and [`sock_recv()`](fn.sock_recv.html). - /// - /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to - /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option - /// [`READ`](struct.mprot.html#associatedconstant.READ). - /// - /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to invoke - /// [`fd_pread()`](fn.fd_pread.html). - const FD_READ = 0x0000000000000002; - /// The right to invoke [`fd_seek()`](fn.fd_seek.html). This flag implies - /// [`FD_TELL`](struct.rights.html#associatedconstant.FD_TELL). - const FD_SEEK = 0x0000000000000004; - /// The right to invoke [`fd_stat_put()`](fn.fd_stat_put.html) with - /// [`FLAGS`](struct.fdsflags.html#associatedconstant.FLAGS). - const FD_STAT_PUT_FLAGS = 0x0000000000000008; - /// The right to invoke [`fd_sync()`](fn.fd_sync.html). - /// - /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to - /// invoke [`file_open()`](fn.file_open.html) with [`RSYNC`](struct.fdflags.html#associatedconstant.RSYNC) and - /// [`DSYNC`](struct.fdflags.html#associatedconstant.DSYNC). - const FD_SYNC = 0x0000000000000010; - /// The right to invoke [`fd_seek()`](fn.fd_seek.html) in such a way that the - /// file offset remains unaltered (i.e., [`CUR`](enum.whence.html#variant.CUR) with - /// offset zero). - const FD_TELL = 0x0000000000000020; - /// The right to invoke [`fd_write()`](fn.fd_write.html) and [`sock_send()`](fn.sock_send.html). - /// - /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, includes the right to - /// invoke [`mem_map()`](fn.mem_map.html) with memory protection option - /// [`WRITE`](struct.mprot.html#associatedconstant.WRITE). - /// - /// If [`FD_SEEK`](struct.rights.html#associatedconstant.FD_SEEK) is set, includes the right to - /// invoke [`fd_pwrite()`](fn.fd_pwrite.html). - const FD_WRITE = 0x0000000000000040; - /// The right to invoke [`file_advise()`](fn.file_advise.html). - const FILE_ADVISE = 0x0000000000000080; - /// The right to invoke [`file_allocate()`](fn.file_allocate.html). - const FILE_ALLOCATE = 0x0000000000000100; - /// The right to invoke [`file_create()`](fn.file_create.html) with - /// [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY). - const FILE_CREATE_DIRECTORY = 0x0000000000000200; - /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, the right to invoke - /// [`file_open()`](fn.file_open.html) with [`CREAT`](struct.oflags.html#associatedconstant.CREAT). - const FILE_CREATE_FILE = 0x0000000000000400; - /// The right to invoke [`file_link()`](fn.file_link.html) with the file - /// descriptor as the source directory. - const FILE_LINK_SOURCE = 0x0000000000001000; - /// The right to invoke [`file_link()`](fn.file_link.html) with the file - /// descriptor as the target directory. - const FILE_LINK_TARGET = 0x0000000000002000; - /// The right to invoke [`file_open()`](fn.file_open.html). - const FILE_OPEN = 0x0000000000004000; - /// The right to invoke [`file_readdir()`](fn.file_readdir.html). - const FILE_READDIR = 0x0000000000008000; - /// The right to invoke [`file_readlink()`](fn.file_readlink.html). - const FILE_READLINK = 0x0000000000010000; - /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file - /// descriptor as the source directory. - const FILE_RENAME_SOURCE = 0x0000000000020000; - /// The right to invoke [`file_rename()`](fn.file_rename.html) with the file - /// descriptor as the target directory. - const FILE_RENAME_TARGET = 0x0000000000040000; - /// The right to invoke [`file_stat_fget()`](fn.file_stat_fget.html). - const FILE_STAT_FGET = 0x0000000000080000; - /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with - /// [`SIZE`](struct.fsflags.html#associatedconstant.SIZE). - /// - /// If [`FILE_OPEN`](struct.rights.html#associatedconstant.FILE_OPEN) is set, includes the right to - /// invoke [`file_open()`](fn.file_open.html) with [`TRUNC`](struct.oflags.html#associatedconstant.TRUNC). - const FILE_STAT_FPUT_SIZE = 0x0000000000100000; - /// The right to invoke [`file_stat_fput()`](fn.file_stat_fput.html) with - /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM), - /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW). - const FILE_STAT_FPUT_TIMES = 0x0000000000200000; - /// The right to invoke [`file_stat_get()`](fn.file_stat_get.html). - const FILE_STAT_GET = 0x0000000000400000; - /// The right to invoke [`file_stat_put()`](fn.file_stat_put.html) with - /// [`ATIM`](struct.fsflags.html#associatedconstant.ATIM), [`ATIM_NOW`](struct.fsflags.html#associatedconstant.ATIM_NOW), [`MTIM`](struct.fsflags.html#associatedconstant.MTIM), - /// and [`MTIM_NOW`](struct.fsflags.html#associatedconstant.MTIM_NOW). - const FILE_STAT_PUT_TIMES = 0x0000000000800000; - /// The right to invoke [`file_symlink()`](fn.file_symlink.html). - const FILE_SYMLINK = 0x0000000001000000; - /// The right to invoke [`file_unlink()`](fn.file_unlink.html). - const FILE_UNLINK = 0x0000000002000000; - /// The right to invoke [`mem_map()`](fn.mem_map.html) with [`mprot`] set to - /// zero. - const MEM_MAP = 0x0000000004000000; - /// If [`MEM_MAP`](struct.rights.html#associatedconstant.MEM_MAP) is set, the right to invoke - /// [`mem_map()`](fn.mem_map.html) with [`EXEC`](struct.mprot.html#associatedconstant.EXEC). - const MEM_MAP_EXEC = 0x0000000008000000; - /// If [`FD_READ`](struct.rights.html#associatedconstant.FD_READ) is set, includes the right to - /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_READ`](enum.eventtype.html#variant.FD_READ). - /// - /// If [`FD_WRITE`](struct.rights.html#associatedconstant.FD_WRITE) is set, includes the right to - /// invoke [`poll()`](fn.poll.html) to subscribe to [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). - const POLL_FD_READWRITE = 0x0000000010000000; - /// The right to invoke [`poll()`](fn.poll.html) to subscribe to - /// [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE). - const POLL_PROC_TERMINATE = 0x0000000040000000; - /// The right to invoke [`proc_exec()`](fn.proc_exec.html). - const PROC_EXEC = 0x0000000100000000; - /// The right to invoke [`sock_shutdown()`](fn.sock_shutdown.html). - const SOCK_SHUTDOWN = 0x0000008000000000; - } -} - -bitflags! { - /// Flags returned by [`sock_recv()`](fn.sock_recv.html). - #[repr(C)] - pub struct roflags: u16 { - /// Returned by [`sock_recv()`](fn.sock_recv.html): List of file descriptors - /// has been truncated. - const FDS_TRUNCATED = 0x0001; - /// Returned by [`sock_recv()`](fn.sock_recv.html): Message data has been - /// truncated. - const DATA_TRUNCATED = 0x0008; - } -} - -/// Indicates whether an object is stored in private or shared -/// memory. -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum scope { - /// The object is stored in private memory. - PRIVATE = 4, - /// The object is stored in shared memory. - SHARED = 8, -} - -bitflags! { - /// Which channels on a socket need to be shut down. - #[repr(C)] - pub struct sdflags: u8 { - /// Disables further receive operations. - const RD = 0x01; - /// Disables further send operations. - const WR = 0x02; - } -} - -bitflags! { - /// Flags provided to [`sock_send()`](fn.sock_send.html). As there are currently no flags - /// defined, it must be set to zero. - #[repr(C)] - pub struct siflags: u16 { - const DEFAULT = 0; - } -} - -/// Signal condition. -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum signal { - /// Process abort signal. - /// - /// Action: Terminates the process. - ABRT = 1, - /// Alarm clock. - /// - /// Action: Terminates the process. - ALRM = 2, - /// Access to an undefined portion of a memory object. - /// - /// Action: Terminates the process. - BUS = 3, - /// Child process terminated, stopped, or continued. - /// - /// Action: Ignored. - CHLD = 4, - /// Continue executing, if stopped. - /// - /// Action: Continues executing, if stopped. - CONT = 5, - /// Erroneous arithmetic operation. - /// - /// Action: Terminates the process. - FPE = 6, - /// Hangup. - /// - /// Action: Terminates the process. - HUP = 7, - /// Illegal instruction. - /// - /// Action: Terminates the process. - ILL = 8, - /// Terminate interrupt signal. - /// - /// Action: Terminates the process. - INT = 9, - /// Kill. - /// - /// Action: Terminates the process. - KILL = 10, - /// Write on a pipe with no one to read it. - /// - /// Action: Ignored. - PIPE = 11, - /// Terminal quit signal. - /// - /// Action: Terminates the process. - QUIT = 12, - /// Invalid memory reference. - /// - /// Action: Terminates the process. - SEGV = 13, - /// Stop executing. - /// - /// Action: Stops executing. - STOP = 14, - /// Bad system call. - /// - /// Action: Terminates the process. - SYS = 15, - /// Termination signal. - /// - /// Action: Terminates the process. - TERM = 16, - /// Trace/breakpoint trap. - /// - /// Action: Terminates the process. - TRAP = 17, - /// Terminal stop signal. - /// - /// Action: Stops executing. - TSTP = 18, - /// Background process attempting read. - /// - /// Action: Stops executing. - TTIN = 19, - /// Background process attempting write. - /// - /// Action: Stops executing. - TTOU = 20, - /// High bandwidth data is available at a socket. - /// - /// Action: Ignored. - URG = 21, - /// User-defined signal 1. - /// - /// Action: Terminates the process. - USR1 = 22, - /// User-defined signal 2. - /// - /// Action: Terminates the process. - USR2 = 23, - /// Virtual timer expired. - /// - /// Action: Terminates the process. - VTALRM = 24, - /// CPU time limit exceeded. - /// - /// Action: Terminates the process. - XCPU = 25, - /// File size limit exceeded. - /// - /// Action: Terminates the process. - XFSZ = 26, -} - -bitflags! { - /// Flags determining how the timestamp provided in - /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) should be interpreted. - #[repr(C)] - pub struct subclockflags: u16 { - /// If set, treat the timestamp provided in - /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) as an absolute timestamp - /// of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id). - /// - /// If clear, treat the timestamp provided in - /// [`subscription.union.clock.timeout`](struct.subscription_clock.html#structfield.timeout) relative to the current - /// time value of clock [`subscription.union.clock.clock_id`](struct.subscription_clock.html#structfield.clock_id). - const ABSTIME = 0x0001; - } -} - -bitflags! { - /// Flags influencing the method of polling for read or writing on - /// a file descriptor. - #[repr(C)] - pub struct subrwflags: u16 { - /// Deprecated. Must be set by callers and ignored by - /// implementations. - const POLL = 0x0001; - } -} - -/// Unique system-local identifier of a thread. This identifier is -/// only valid during the lifetime of the thread. -/// -/// Threads must be aware of their thread identifier, as it is -/// written it into locks when acquiring them for writing. It is -/// not advised to use these identifiers for any other purpose. -/// -/// As the thread identifier is also stored in [`lock`] when -/// [`LOCK_WRLOCKED`](constant.LOCK_WRLOCKED.html) is set, the top two bits of the thread -/// must always be set to zero. -#[repr(C)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -pub struct tid(pub u32); - -/// Timestamp in nanoseconds. -pub type timestamp = u64; - -bitflags! { - /// Specifies whether files are unlinked or directories are - /// removed. - #[repr(C)] - pub struct ulflags: u8 { - /// If set, removes a directory. Otherwise, unlinks any - /// non-directory file. - const REMOVEDIR = 0x01; - } -} - -/// User-provided value that can be attached to objects that is -/// retained when extracted from the kernel. -pub type userdata = u64; - -/// Relative to which position the offset of the file descriptor -/// should be set. -#[repr(u8)] -#[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] -#[non_exhaustive] -pub enum whence { - /// Seek relative to current position. - CUR = 1, - /// Seek relative to end-of-file. - END = 2, - /// Seek relative to start-of-file. - SET = 3, -} - -/// Auxiliary vector entry. -/// -/// The auxiliary vector is a list of key-value pairs that is -/// provided to the process on startup. Unlike structures, it is -/// extensible, as it is possible to add new records later on. -/// The auxiliary vector is always terminated by an entry having -/// type [`NULL`](enum.auxtype.html#variant.NULL). -/// -/// The auxiliary vector is part of the x86-64 ABI, but is used by -/// this environment on all architectures. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct auxv { - /// The type of the auxiliary vector entry. - pub a_type: auxtype, - pub union: auxv_union, -} -/// A union inside `auxv`. -#[repr(C)] -#[derive(Copy, Clone)] -pub union auxv_union { - /// Used when `a_type` is [`ARGDATALEN`](enum.auxtype.html#variant.ARGDATALEN), [`CANARYLEN`](enum.auxtype.html#variant.CANARYLEN), [`NCPUS`](enum.auxtype.html#variant.NCPUS), [`PAGESZ`](enum.auxtype.html#variant.PAGESZ), [`PHNUM`](enum.auxtype.html#variant.PHNUM), or [`TID`](enum.auxtype.html#variant.TID). - /// A numerical value. - pub a_val: usize, - /// Used when `a_type` is [`ARGDATA`](enum.auxtype.html#variant.ARGDATA), [`BASE`](enum.auxtype.html#variant.BASE), [`CANARY`](enum.auxtype.html#variant.CANARY), [`PHDR`](enum.auxtype.html#variant.PHDR), [`PID`](enum.auxtype.html#variant.PID), or [`SYSINFO_EHDR`](enum.auxtype.html#variant.SYSINFO_EHDR). - /// A pointer value. - pub a_ptr: *mut (), -} -#[test] -#[cfg(target_pointer_width = "32")] -fn auxv_layout_test_32() { - assert_eq!(core::mem::size_of::(), 8); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: auxv = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.a_type as *const _ as usize - base, 0); - assert_eq!(&obj.union.a_val as *const _ as usize - base, 4); - assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 4); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn auxv_layout_test_64() { - assert_eq!(core::mem::size_of::(), 16); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: auxv = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.a_type as *const _ as usize - base, 0); - assert_eq!(&obj.union.a_val as *const _ as usize - base, 8); - assert_eq!(&obj.union.a_ptr as *const _ as usize - base, 8); - } -} - -/// A region of memory for scatter/gather writes. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct ciovec { - /// The address and length of the buffer to be written. - pub buf: (*const (), usize), -} -#[test] -#[cfg(target_pointer_width = "32")] -fn ciovec_layout_test_32() { - assert_eq!(core::mem::size_of::(), 8); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: ciovec = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); - assert_eq!(&obj.buf.1 as *const _ as usize - base, 4); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn ciovec_layout_test_64() { - assert_eq!(core::mem::size_of::(), 16); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: ciovec = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); - assert_eq!(&obj.buf.1 as *const _ as usize - base, 8); - } -} - -/// A directory entry. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct dirent { - /// The offset of the next directory entry stored in this - /// directory. - pub d_next: dircookie, - /// The serial number of the file referred to by this - /// directory entry. - pub d_ino: inode, - /// The length of the name of the directory entry. - pub d_namlen: u32, - /// The type of the file referred to by this directory - /// entry. - pub d_type: filetype, -} -#[test] -fn dirent_layout_test() { - assert_eq!(core::mem::size_of::(), 24); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: dirent = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.d_next as *const _ as usize - base, 0); - assert_eq!(&obj.d_ino as *const _ as usize - base, 8); - assert_eq!(&obj.d_namlen as *const _ as usize - base, 16); - assert_eq!(&obj.d_type as *const _ as usize - base, 20); - } -} - -/// An event that occurred. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct event { - /// User-provided value that got attached to - /// [`subscription.userdata`](struct.subscription.html#structfield.userdata). - pub userdata: userdata, - /// If non-zero, an error that occurred while processing - /// the subscription request. - pub error: errno, - /// The type of the event that occurred. - pub type_: eventtype, - pub union: event_union, -} -/// A union inside `event`. -#[repr(C)] -#[derive(Copy, Clone)] -pub union event_union { - /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). - pub fd_readwrite: event_fd_readwrite, - /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE). - pub proc_terminate: event_proc_terminate, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct event_fd_readwrite { - /// The number of bytes available - /// for reading or writing. - pub nbytes: filesize, - /// Obsolete. - pub unused: [u8; 4], - /// The state of the file - /// descriptor. - pub flags: eventrwflags, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct event_proc_terminate { - /// Obsolete. - pub unused: [u8; 4], - /// If zero, the process has - /// exited. - /// Otherwise, the signal - /// condition causing it to - /// terminated. - pub signal: signal, - /// If exited, the exit code of - /// the process. - pub exitcode: exitcode, -} -#[test] -fn event_layout_test() { - assert_eq!(core::mem::size_of::(), 32); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: event = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.userdata as *const _ as usize - base, 0); - assert_eq!(&obj.error as *const _ as usize - base, 8); - assert_eq!(&obj.type_ as *const _ as usize - base, 10); - assert_eq!(&obj.union.fd_readwrite.nbytes as *const _ as usize - base, 16); - assert_eq!(&obj.union.fd_readwrite.unused as *const _ as usize - base, 24); - assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 28); - assert_eq!(&obj.union.proc_terminate.unused as *const _ as usize - base, 16); - assert_eq!(&obj.union.proc_terminate.signal as *const _ as usize - base, 20); - assert_eq!(&obj.union.proc_terminate.exitcode as *const _ as usize - base, 24); - } -} - -/// File descriptor attributes. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct fdstat { - /// File type. - pub fs_filetype: filetype, - /// File descriptor flags. - pub fs_flags: fdflags, - /// Rights that apply to this file descriptor. - pub fs_rights_base: rights, - /// Maximum set of rights that can be installed on new - /// file descriptors that are created through this file - /// descriptor, e.g., through [`file_open()`](fn.file_open.html). - pub fs_rights_inheriting: rights, -} -#[test] -fn fdstat_layout_test() { - assert_eq!(core::mem::size_of::(), 24); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: fdstat = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.fs_filetype as *const _ as usize - base, 0); - assert_eq!(&obj.fs_flags as *const _ as usize - base, 2); - assert_eq!(&obj.fs_rights_base as *const _ as usize - base, 8); - assert_eq!(&obj.fs_rights_inheriting as *const _ as usize - base, 16); - } -} - -/// File attributes. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct filestat { - /// Device ID of device containing the file. - pub st_dev: device, - /// File serial number. - pub st_ino: inode, - /// File type. - pub st_filetype: filetype, - /// Number of hard links to the file. - pub st_nlink: linkcount, - /// For regular files, the file size in bytes. For - /// symbolic links, the length in bytes of the pathname - /// contained in the symbolic link. - pub st_size: filesize, - /// Last data access timestamp. - pub st_atim: timestamp, - /// Last data modification timestamp. - pub st_mtim: timestamp, - /// Last file status change timestamp. - pub st_ctim: timestamp, -} -#[test] -fn filestat_layout_test() { - assert_eq!(core::mem::size_of::(), 56); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: filestat = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.st_dev as *const _ as usize - base, 0); - assert_eq!(&obj.st_ino as *const _ as usize - base, 8); - assert_eq!(&obj.st_filetype as *const _ as usize - base, 16); - assert_eq!(&obj.st_nlink as *const _ as usize - base, 20); - assert_eq!(&obj.st_size as *const _ as usize - base, 24); - assert_eq!(&obj.st_atim as *const _ as usize - base, 32); - assert_eq!(&obj.st_mtim as *const _ as usize - base, 40); - assert_eq!(&obj.st_ctim as *const _ as usize - base, 48); - } -} - -/// A region of memory for scatter/gather reads. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct iovec { - /// The address and length of the buffer to be filled. - pub buf: (*mut (), usize), -} -#[test] -#[cfg(target_pointer_width = "32")] -fn iovec_layout_test_32() { - assert_eq!(core::mem::size_of::(), 8); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: iovec = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); - assert_eq!(&obj.buf.1 as *const _ as usize - base, 4); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn iovec_layout_test_64() { - assert_eq!(core::mem::size_of::(), 16); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: iovec = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.buf.0 as *const _ as usize - base, 0); - assert_eq!(&obj.buf.1 as *const _ as usize - base, 8); - } -} - -/// Path lookup properties. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct lookup { - /// The working directory at which the resolution of the - /// path starts. - pub fd: fd, - /// Flags determining the method of how the path is - /// resolved. - pub flags: lookupflags, -} -#[test] -fn lookup_layout_test() { - assert_eq!(core::mem::size_of::(), 8); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: lookup = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.fd as *const _ as usize - base, 0); - assert_eq!(&obj.flags as *const _ as usize - base, 4); - } -} - -/// Entry point for a process (`_start`). -/// -/// **auxv**: -/// The auxiliary vector. See [`auxv`]. -pub type processentry = unsafe extern "C" fn(auxv: *const auxv) -> (); - -/// Arguments of [`sock_recv()`](fn.sock_recv.html). -#[repr(C)] -#[derive(Copy, Clone)] -pub struct recv_in { - /// List of scatter/gather vectors where message data - /// should be stored. - pub ri_data: (*const iovec, usize), - /// Buffer where numbers of incoming file descriptors - /// should be stored. - pub ri_fds: (*mut fd, usize), - /// Message flags. - pub ri_flags: riflags, -} -#[test] -#[cfg(target_pointer_width = "32")] -fn recv_in_layout_test_32() { - assert_eq!(core::mem::size_of::(), 20); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: recv_in = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0); - assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 4); - assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 8); - assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 12); - assert_eq!(&obj.ri_flags as *const _ as usize - base, 16); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn recv_in_layout_test_64() { - assert_eq!(core::mem::size_of::(), 40); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: recv_in = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.ri_data.0 as *const _ as usize - base, 0); - assert_eq!(&obj.ri_data.1 as *const _ as usize - base, 8); - assert_eq!(&obj.ri_fds.0 as *const _ as usize - base, 16); - assert_eq!(&obj.ri_fds.1 as *const _ as usize - base, 24); - assert_eq!(&obj.ri_flags as *const _ as usize - base, 32); - } -} - -/// Results of [`sock_recv()`](fn.sock_recv.html). -#[repr(C)] -#[derive(Copy, Clone)] -pub struct recv_out { - /// Number of bytes stored in [`recv_in.ri_data`](struct.recv_in.html#structfield.ri_data). - pub ro_datalen: usize, - /// Number of file descriptors stored in [`recv_in.ri_fds`](struct.recv_in.html#structfield.ri_fds). - pub ro_fdslen: usize, - /// Fields that were used by previous implementations. - pub ro_unused: [u8; 40], - /// Message flags. - pub ro_flags: roflags, -} -#[test] -#[cfg(target_pointer_width = "32")] -fn recv_out_layout_test_32() { - assert_eq!(core::mem::size_of::(), 52); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: recv_out = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0); - assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 4); - assert_eq!(&obj.ro_unused as *const _ as usize - base, 8); - assert_eq!(&obj.ro_flags as *const _ as usize - base, 48); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn recv_out_layout_test_64() { - assert_eq!(core::mem::size_of::(), 64); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: recv_out = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.ro_datalen as *const _ as usize - base, 0); - assert_eq!(&obj.ro_fdslen as *const _ as usize - base, 8); - assert_eq!(&obj.ro_unused as *const _ as usize - base, 16); - assert_eq!(&obj.ro_flags as *const _ as usize - base, 56); - } -} - -/// Arguments of [`sock_send()`](fn.sock_send.html). -#[repr(C)] -#[derive(Copy, Clone)] -pub struct send_in { - /// List of scatter/gather vectors where message data - /// should be retrieved. - pub si_data: (*const ciovec, usize), - /// File descriptors that need to be attached to the - /// message. - pub si_fds: (*const fd, usize), - /// Message flags. - pub si_flags: siflags, -} -#[test] -#[cfg(target_pointer_width = "32")] -fn send_in_layout_test_32() { - assert_eq!(core::mem::size_of::(), 20); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: send_in = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0); - assert_eq!(&obj.si_data.1 as *const _ as usize - base, 4); - assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 8); - assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 12); - assert_eq!(&obj.si_flags as *const _ as usize - base, 16); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn send_in_layout_test_64() { - assert_eq!(core::mem::size_of::(), 40); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: send_in = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.si_data.0 as *const _ as usize - base, 0); - assert_eq!(&obj.si_data.1 as *const _ as usize - base, 8); - assert_eq!(&obj.si_fds.0 as *const _ as usize - base, 16); - assert_eq!(&obj.si_fds.1 as *const _ as usize - base, 24); - assert_eq!(&obj.si_flags as *const _ as usize - base, 32); - } -} - -/// Results of [`sock_send()`](fn.sock_send.html). -#[repr(C)] -#[derive(Copy, Clone)] -pub struct send_out { - /// Number of bytes transmitted. - pub so_datalen: usize, -} -#[test] -#[cfg(target_pointer_width = "32")] -fn send_out_layout_test_32() { - assert_eq!(core::mem::size_of::(), 4); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: send_out = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.so_datalen as *const _ as usize - base, 0); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn send_out_layout_test_64() { - assert_eq!(core::mem::size_of::(), 8); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: send_out = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.so_datalen as *const _ as usize - base, 0); - } -} - -/// Subscription to an event. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct subscription { - /// User-provided value that is attached to the - /// subscription in the kernel and returned through - /// [`event.userdata`](struct.event.html#structfield.userdata). - pub userdata: userdata, - /// Used by previous implementations. Ignored. - pub unused: u16, - /// The type of the event to which to subscribe. - /// - /// Currently, [`CONDVAR`](enum.eventtype.html#variant.CONDVAR), - /// [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK), and [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK) - /// must be provided as the first subscription and may - /// only be followed by up to one other subscription, - /// having type [`CLOCK`](enum.eventtype.html#variant.CLOCK). - pub type_: eventtype, - pub union: subscription_union, -} -/// A union inside `subscription`. -#[repr(C)] -#[derive(Copy, Clone)] -pub union subscription_union { - /// Used when `type_` is [`CLOCK`](enum.eventtype.html#variant.CLOCK). - pub clock: subscription_clock, - /// Used when `type_` is [`CONDVAR`](enum.eventtype.html#variant.CONDVAR). - pub condvar: subscription_condvar, - /// Used when `type_` is [`FD_READ`](enum.eventtype.html#variant.FD_READ) or [`FD_WRITE`](enum.eventtype.html#variant.FD_WRITE). - pub fd_readwrite: subscription_fd_readwrite, - /// Used when `type_` is [`LOCK_RDLOCK`](enum.eventtype.html#variant.LOCK_RDLOCK) or [`LOCK_WRLOCK`](enum.eventtype.html#variant.LOCK_WRLOCK). - pub lock: subscription_lock, - /// Used when `type_` is [`PROC_TERMINATE`](enum.eventtype.html#variant.PROC_TERMINATE). - pub proc_terminate: subscription_proc_terminate, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct subscription_clock { - /// The user-defined unique - /// identifier of the clock. - pub identifier: userdata, - /// The clock against which the - /// timestamp should be compared. - pub clock_id: clockid, - /// The absolute or relative - /// timestamp. - pub timeout: timestamp, - /// The amount of time that the - /// kernel may wait additionally - /// to coalesce with other events. - pub precision: timestamp, - /// Flags specifying whether the - /// timeout is absolute or - /// relative. - pub flags: subclockflags, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct subscription_condvar { - /// The condition variable on - /// which to wait to be woken up. - pub condvar: *mut condvar, - /// The lock that will be - /// released while waiting. - /// - /// The lock will be reacquired - /// for writing when the condition - /// variable triggers. - pub lock: *mut lock, - /// Whether the condition variable - /// is stored in private or shared - /// memory. - pub condvar_scope: scope, - /// Whether the lock is stored in - /// private or shared memory. - pub lock_scope: scope, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct subscription_fd_readwrite { - /// The file descriptor on which - /// to wait for it to become ready - /// for reading or writing. - pub fd: fd, - /// Under which conditions to - /// trigger. - pub flags: subrwflags, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct subscription_lock { - /// The lock that will be acquired - /// for reading or writing. - pub lock: *mut lock, - /// Whether the lock is stored in - /// private or shared memory. - pub lock_scope: scope, -} -#[repr(C)] -#[derive(Copy, Clone)] -pub struct subscription_proc_terminate { - /// The process descriptor on - /// which to wait for process - /// termination. - pub fd: fd, -} -#[test] -#[cfg(target_pointer_width = "32")] -fn subscription_layout_test_32() { - assert_eq!(core::mem::size_of::(), 56); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: subscription = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.userdata as *const _ as usize - base, 0); - assert_eq!(&obj.unused as *const _ as usize - base, 8); - assert_eq!(&obj.type_ as *const _ as usize - base, 10); - assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16); - assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24); - assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32); - assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40); - assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48); - assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16); - assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 20); - assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 24); - assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 25); - assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16); - assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20); - assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16); - assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 20); - assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn subscription_layout_test_64() { - assert_eq!(core::mem::size_of::(), 56); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: subscription = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.userdata as *const _ as usize - base, 0); - assert_eq!(&obj.unused as *const _ as usize - base, 8); - assert_eq!(&obj.type_ as *const _ as usize - base, 10); - assert_eq!(&obj.union.clock.identifier as *const _ as usize - base, 16); - assert_eq!(&obj.union.clock.clock_id as *const _ as usize - base, 24); - assert_eq!(&obj.union.clock.timeout as *const _ as usize - base, 32); - assert_eq!(&obj.union.clock.precision as *const _ as usize - base, 40); - assert_eq!(&obj.union.clock.flags as *const _ as usize - base, 48); - assert_eq!(&obj.union.condvar.condvar as *const _ as usize - base, 16); - assert_eq!(&obj.union.condvar.lock as *const _ as usize - base, 24); - assert_eq!(&obj.union.condvar.condvar_scope as *const _ as usize - base, 32); - assert_eq!(&obj.union.condvar.lock_scope as *const _ as usize - base, 33); - assert_eq!(&obj.union.fd_readwrite.fd as *const _ as usize - base, 16); - assert_eq!(&obj.union.fd_readwrite.flags as *const _ as usize - base, 20); - assert_eq!(&obj.union.lock.lock as *const _ as usize - base, 16); - assert_eq!(&obj.union.lock.lock_scope as *const _ as usize - base, 24); - assert_eq!(&obj.union.proc_terminate.fd as *const _ as usize - base, 16); - } -} - -/// The Thread Control Block (TCB). -/// -/// After a thread begins execution (at program startup or when -/// created through [`thread_create()`](fn.thread_create.html)), the CPU's registers -/// controlling Thread-Local Storage (TLS) will already be -/// initialized. They will point to an area only containing the -/// TCB. -/// -/// If the thread needs space for storing thread-specific -/// variables, the thread may allocate a larger area and adjust -/// the CPU's registers to point to that area instead. However, it -/// does need to make sure that the TCB is copied over to the new -/// TLS area. -/// -/// The purpose of the TCB is that it allows light-weight -/// emulators to store information related to individual threads. -/// For example, it may be used to store a copy of the CPU -/// registers prior emulation, so that TLS for the host system -/// can be restored if needed. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct tcb { - /// Pointer that may be freely assigned by the system. Its - /// value cannot be interpreted by the application. - pub parent: *mut (), -} -#[test] -#[cfg(target_pointer_width = "32")] -fn tcb_layout_test_32() { - assert_eq!(core::mem::size_of::(), 4); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: tcb = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.parent as *const _ as usize - base, 0); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn tcb_layout_test_64() { - assert_eq!(core::mem::size_of::(), 8); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: tcb = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.parent as *const _ as usize - base, 0); - } -} - -/// Entry point for additionally created threads. -/// -/// `tid`: thread ID of the current thread. -/// -/// `aux`: copy of the value stored in -/// [`threadattr.argument`](struct.threadattr.html#structfield.argument). -pub type threadentry = unsafe extern "C" fn(tid: tid, aux: *mut ()) -> (); - -/// Attributes for thread creation. -#[repr(C)] -#[derive(Copy, Clone)] -pub struct threadattr { - /// Initial program counter value. - pub entry_point: threadentry, - /// Region allocated to serve as stack space. - pub stack: (*mut (), usize), - /// Argument to be forwarded to the entry point function. - pub argument: *mut (), -} -#[test] -#[cfg(target_pointer_width = "32")] -fn threadattr_layout_test_32() { - assert_eq!(core::mem::size_of::(), 16); - assert_eq!(core::mem::align_of::(), 4); - unsafe { - let obj: threadattr = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.entry_point as *const _ as usize - base, 0); - assert_eq!(&obj.stack.0 as *const _ as usize - base, 4); - assert_eq!(&obj.stack.1 as *const _ as usize - base, 8); - assert_eq!(&obj.argument as *const _ as usize - base, 12); - } -} -#[test] -#[cfg(target_pointer_width = "64")] -fn threadattr_layout_test_64() { - assert_eq!(core::mem::size_of::(), 32); - assert_eq!(core::mem::align_of::(), 8); - unsafe { - let obj: threadattr = core::mem::uninitialized(); - let base = &obj as *const _ as usize; - assert_eq!(&obj.entry_point as *const _ as usize - base, 0); - assert_eq!(&obj.stack.0 as *const _ as usize - base, 8); - assert_eq!(&obj.stack.1 as *const _ as usize - base, 16); - assert_eq!(&obj.argument as *const _ as usize - base, 24); - } -} - -/// The table with pointers to all syscall implementations. -#[allow(improper_ctypes)] -extern "C" { - fn cloudabi_sys_clock_res_get(_: clockid, _: *mut timestamp) -> errno; - fn cloudabi_sys_clock_time_get(_: clockid, _: timestamp, _: *mut timestamp) -> errno; - fn cloudabi_sys_condvar_signal(_: *mut condvar, _: scope, _: nthreads) -> errno; - fn cloudabi_sys_fd_close(_: fd) -> errno; - fn cloudabi_sys_fd_create1(_: filetype, _: *mut fd) -> errno; - fn cloudabi_sys_fd_create2(_: filetype, _: *mut fd, _: *mut fd) -> errno; - fn cloudabi_sys_fd_datasync(_: fd) -> errno; - fn cloudabi_sys_fd_dup(_: fd, _: *mut fd) -> errno; - fn cloudabi_sys_fd_pread(_: fd, _: *const iovec, _: usize, _: filesize, _: *mut usize) - -> errno; - fn cloudabi_sys_fd_pwrite( - _: fd, - _: *const ciovec, - _: usize, - _: filesize, - _: *mut usize, - ) -> errno; - fn cloudabi_sys_fd_read(_: fd, _: *const iovec, _: usize, _: *mut usize) -> errno; - fn cloudabi_sys_fd_replace(_: fd, _: fd) -> errno; - fn cloudabi_sys_fd_seek(_: fd, _: filedelta, _: whence, _: *mut filesize) -> errno; - fn cloudabi_sys_fd_stat_get(_: fd, _: *mut fdstat) -> errno; - fn cloudabi_sys_fd_stat_put(_: fd, _: *const fdstat, _: fdsflags) -> errno; - fn cloudabi_sys_fd_sync(_: fd) -> errno; - fn cloudabi_sys_fd_write(_: fd, _: *const ciovec, _: usize, _: *mut usize) -> errno; - fn cloudabi_sys_file_advise(_: fd, _: filesize, _: filesize, _: advice) -> errno; - fn cloudabi_sys_file_allocate(_: fd, _: filesize, _: filesize) -> errno; - fn cloudabi_sys_file_create(_: fd, _: *const u8, _: usize, _: filetype) -> errno; - fn cloudabi_sys_file_link( - _: lookup, - _: *const u8, - _: usize, - _: fd, - _: *const u8, - _: usize, - ) -> errno; - fn cloudabi_sys_file_open( - _: lookup, - _: *const u8, - _: usize, - _: oflags, - _: *const fdstat, - _: *mut fd, - ) -> errno; - fn cloudabi_sys_file_readdir(_: fd, _: *mut (), _: usize, _: dircookie, _: *mut usize) - -> errno; - fn cloudabi_sys_file_readlink( - _: fd, - _: *const u8, - _: usize, - _: *mut u8, - _: usize, - _: *mut usize, - ) -> errno; - fn cloudabi_sys_file_rename( - _: fd, - _: *const u8, - _: usize, - _: fd, - _: *const u8, - _: usize, - ) -> errno; - fn cloudabi_sys_file_stat_fget(_: fd, _: *mut filestat) -> errno; - fn cloudabi_sys_file_stat_fput(_: fd, _: *const filestat, _: fsflags) -> errno; - fn cloudabi_sys_file_stat_get(_: lookup, _: *const u8, _: usize, _: *mut filestat) -> errno; - fn cloudabi_sys_file_stat_put( - _: lookup, - _: *const u8, - _: usize, - _: *const filestat, - _: fsflags, - ) -> errno; - fn cloudabi_sys_file_symlink(_: *const u8, _: usize, _: fd, _: *const u8, _: usize) -> errno; - fn cloudabi_sys_file_unlink(_: fd, _: *const u8, _: usize, _: ulflags) -> errno; - fn cloudabi_sys_lock_unlock(_: *mut lock, _: scope) -> errno; - fn cloudabi_sys_mem_advise(_: *mut (), _: usize, _: advice) -> errno; - fn cloudabi_sys_mem_map( - _: *mut (), - _: usize, - _: mprot, - _: mflags, - _: fd, - _: filesize, - _: *mut *mut (), - ) -> errno; - fn cloudabi_sys_mem_protect(_: *mut (), _: usize, _: mprot) -> errno; - fn cloudabi_sys_mem_sync(_: *mut (), _: usize, _: msflags) -> errno; - fn cloudabi_sys_mem_unmap(_: *mut (), _: usize) -> errno; - fn cloudabi_sys_poll(_: *const subscription, _: *mut event, _: usize, _: *mut usize) -> errno; - fn cloudabi_sys_proc_exec(_: fd, _: *const (), _: usize, _: *const fd, _: usize) -> errno; - fn cloudabi_sys_proc_exit(_: exitcode) -> !; - fn cloudabi_sys_proc_fork(_: *mut fd, _: *mut tid) -> errno; - fn cloudabi_sys_proc_raise(_: signal) -> errno; - fn cloudabi_sys_random_get(_: *mut (), _: usize) -> errno; - fn cloudabi_sys_sock_recv(_: fd, _: *const recv_in, _: *mut recv_out) -> errno; - fn cloudabi_sys_sock_send(_: fd, _: *const send_in, _: *mut send_out) -> errno; - fn cloudabi_sys_sock_shutdown(_: fd, _: sdflags) -> errno; - fn cloudabi_sys_thread_create(_: *mut threadattr, _: *mut tid) -> errno; - fn cloudabi_sys_thread_exit(_: *mut lock, _: scope) -> !; - fn cloudabi_sys_thread_yield() -> errno; -} - -/// Obtains the resolution of a clock. -/// -/// ## Parameters -/// -/// **clock_id**: -/// The clock for which the resolution needs to be -/// returned. -/// -/// **resolution**: -/// The resolution of the clock. -#[inline] -pub unsafe fn clock_res_get(clock_id_: clockid, resolution_: &mut timestamp) -> errno { - unsafe { cloudabi_sys_clock_res_get(clock_id_, resolution_) } -} - -/// Obtains the time value of a clock. -/// -/// ## Parameters -/// -/// **clock_id**: -/// The clock for which the time needs to be -/// returned. -/// -/// **precision**: -/// The maximum lag (exclusive) that the returned -/// time value may have, compared to its actual -/// value. -/// -/// **time**: -/// The time value of the clock. -#[inline] -pub unsafe fn clock_time_get( - clock_id_: clockid, - precision_: timestamp, - time_: *mut timestamp, -) -> errno { - unsafe { cloudabi_sys_clock_time_get(clock_id_, precision_, time_) } -} - -/// Wakes up threads waiting on a userspace condition variable. -/// -/// If an invocation of this system call causes all waiting -/// threads to be woken up, the value of the condition variable -/// is set to [`CONDVAR_HAS_NO_WAITERS`](constant.CONDVAR_HAS_NO_WAITERS.html). As long as the condition -/// variable is set to this value, it is not needed to invoke this -/// system call. -/// -/// ## Parameters -/// -/// **condvar**: -/// The userspace condition variable that has -/// waiting threads. -/// -/// **scope**: -/// Whether the condition variable is stored in -/// private or shared memory. -/// -/// **nwaiters**: -/// The number of threads that need to be woken -/// up. If it exceeds the number of waiting -/// threads, all threads are woken up. -#[inline] -pub unsafe fn condvar_signal(condvar_: *mut condvar, scope_: scope, nwaiters_: nthreads) -> errno { - unsafe { cloudabi_sys_condvar_signal(condvar_, scope_, nwaiters_) } -} - -/// Closes a file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor that needs to be closed. -#[inline] -pub unsafe fn fd_close(fd_: fd) -> errno { - unsafe { cloudabi_sys_fd_close(fd_) } -} - -/// Creates a file descriptor. -/// -/// ## Parameters -/// -/// **type**: -/// Possible values: -/// -/// - [`SHARED_MEMORY`](enum.filetype.html#variant.SHARED_MEMORY): -/// Creates an anonymous shared memory -/// object. -/// -/// **fd**: -/// The file descriptor that has been created. -#[inline] -pub unsafe fn fd_create1(type_: filetype, fd_: &mut fd) -> errno { - unsafe { cloudabi_sys_fd_create1(type_, fd_) } -} - -/// Creates a pair of file descriptors. -/// -/// ## Parameters -/// -/// **type**: -/// Possible values: -/// -/// - [`SOCKET_DGRAM`](enum.filetype.html#variant.SOCKET_DGRAM): -/// Creates a UNIX datagram socket pair. -/// - [`SOCKET_STREAM`](enum.filetype.html#variant.SOCKET_STREAM): -/// Creates a UNIX byte-stream socket -/// pair. -/// -/// **fd1**: -/// The first file descriptor of the pair. -/// -/// **fd2**: -/// The second file descriptor of the pair. -#[inline] -pub unsafe fn fd_create2(type_: filetype, fd1_: &mut fd, fd2_: &mut fd) -> errno { - // SAFETY: the caller must uphold the safety contract for `cloudabi_sys_fd_create2`. - unsafe { cloudabi_sys_fd_create2(type_, fd1_, fd2_) } -} - -/// Synchronizes the data of a file to disk. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor of the file whose data -/// needs to be synchronized to disk. -#[inline] -pub unsafe fn fd_datasync(fd_: fd) -> errno { - // SAFETY: the caller must guarantee that `fd` is valid - // for synchronization. - unsafe { cloudabi_sys_fd_datasync(fd_) } -} - -/// Duplicates a file descriptor. -/// -/// ## Parameters -/// -/// **from**: -/// The file descriptor that needs to be -/// duplicated. -/// -/// **fd**: -/// The new file descriptor. -#[inline] -pub unsafe fn fd_dup(from_: fd, fd_: &mut fd) -> errno { - unsafe { cloudabi_sys_fd_dup(from_, fd_) } -} - -/// Reads from a file descriptor, without using and updating the -/// file descriptor's offset. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor from which data should be -/// read. -/// -/// **iovs**: -/// List of scatter/gather vectors where data -/// should be stored. -/// -/// **offset**: -/// The offset within the file at which reading -/// should start. -/// -/// **nread**: -/// The number of bytes read. -#[inline] -pub unsafe fn fd_pread(fd_: fd, iovs_: &[iovec], offset_: filesize, nread_: &mut usize) -> errno { - unsafe { cloudabi_sys_fd_pread(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nread_) } -} - -/// Writes to a file descriptor, without using and updating the -/// file descriptor's offset. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor to which data should be -/// written. -/// -/// **iovs**: -/// List of scatter/gather vectors where data -/// should be retrieved. -/// -/// **offset**: -/// The offset within the file at which writing -/// should start. -/// -/// **nwritten**: -/// The number of bytes written. -#[inline] -pub unsafe fn fd_pwrite( - fd_: fd, - iovs_: &[ciovec], - offset_: filesize, - nwritten_: &mut usize, -) -> errno { - unsafe { cloudabi_sys_fd_pwrite(fd_, iovs_.as_ptr(), iovs_.len(), offset_, nwritten_) } -} - -/// Reads from a file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor from which data should be -/// read. -/// -/// **iovs**: -/// List of scatter/gather vectors where data -/// should be stored. -/// -/// **nread**: -/// The number of bytes read. -#[inline] -pub unsafe fn fd_read(fd_: fd, iovs_: &[iovec], nread_: &mut usize) -> errno { - unsafe { cloudabi_sys_fd_read(fd_, iovs_.as_ptr(), iovs_.len(), nread_) } -} - -/// Atomically replaces a file descriptor by a copy of another -/// file descriptor. -/// -/// Due to the strong focus on thread safety, this environment -/// does not provide a mechanism to duplicate a file descriptor to -/// an arbitrary number, like dup2(). This would be prone to race -/// conditions, as an actual file descriptor with the same number -/// could be allocated by a different thread at the same time. -/// -/// This system call provides a way to atomically replace file -/// descriptors, which would disappear if dup2() were to be -/// removed entirely. -/// -/// ## Parameters -/// -/// **from**: -/// The file descriptor that needs to be copied. -/// -/// **to**: -/// The file descriptor that needs to be -/// overwritten. -#[inline] -pub unsafe fn fd_replace(from_: fd, to_: fd) -> errno { - unsafe { cloudabi_sys_fd_replace(from_, to_) } -} - -/// Moves the offset of the file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor whose offset has to be -/// moved. -/// -/// **offset**: -/// The number of bytes to move. -/// -/// **whence**: -/// Relative to which position the move should -/// take place. -/// -/// **newoffset**: -/// The new offset of the file descriptor, -/// relative to the start of the file. -#[inline] -pub unsafe fn fd_seek( - fd_: fd, - offset_: filedelta, - whence_: whence, - newoffset_: &mut filesize, -) -> errno { - unsafe { cloudabi_sys_fd_seek(fd_, offset_, whence_, newoffset_) } -} - -/// Gets attributes of a file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor whose attributes have to -/// be obtained. -/// -/// **buf**: -/// The buffer where the file descriptor's -/// attributes are stored. -#[inline] -pub unsafe fn fd_stat_get(fd_: fd, buf_: *mut fdstat) -> errno { - unsafe { cloudabi_sys_fd_stat_get(fd_, buf_) } -} - -/// Adjusts attributes of a file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor whose attributes have to -/// be adjusted. -/// -/// **buf**: -/// The desired values of the file descriptor -/// attributes that are adjusted. -/// -/// **flags**: -/// A bitmask indicating which attributes have to -/// be adjusted. -#[inline] -pub unsafe fn fd_stat_put(fd_: fd, buf_: *const fdstat, flags_: fdsflags) -> errno { - unsafe { cloudabi_sys_fd_stat_put(fd_, buf_, flags_) } -} - -/// Synchronizes the data and metadata of a file to disk. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor of the file whose data -/// and metadata needs to be synchronized to disk. -#[inline] -pub unsafe fn fd_sync(fd_: fd) -> errno { - unsafe { cloudabi_sys_fd_sync(fd_) } -} - -/// Writes to a file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor to which data should be -/// written. -/// -/// **iovs**: -/// List of scatter/gather vectors where data -/// should be retrieved. -/// -/// **nwritten**: -/// The number of bytes written. -#[inline] -pub unsafe fn fd_write(fd_: fd, iovs_: &[ciovec], nwritten_: &mut usize) -> errno { - unsafe { cloudabi_sys_fd_write(fd_, iovs_.as_ptr(), iovs_.len(), nwritten_) } -} - -/// Provides file advisory information on a file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor for which to provide file -/// advisory information. -/// -/// **offset**: -/// The offset within the file to which the -/// advisory applies. -/// -/// **len**: -/// The length of the region to which the advisory -/// applies. -/// -/// **advice**: -/// The advice. -#[inline] -pub unsafe fn file_advise(fd_: fd, offset_: filesize, len_: filesize, advice_: advice) -> errno { - unsafe { cloudabi_sys_file_advise(fd_, offset_, len_, advice_) } -} - -/// Forces the allocation of space in a file. -/// -/// ## Parameters -/// -/// **fd**: -/// The file in which the space should be -/// allocated. -/// -/// **offset**: -/// The offset at which the allocation should -/// start. -/// -/// **len**: -/// The length of the area that is allocated. -#[inline] -pub unsafe fn file_allocate(fd_: fd, offset_: filesize, len_: filesize) -> errno { - unsafe { cloudabi_sys_file_allocate(fd_, offset_, len_) } -} - -/// Creates a file of a specified type. -/// -/// ## Parameters -/// -/// **fd**: -/// The working directory at which the resolution -/// of the file to be created starts. -/// -/// **path**: -/// The path at which the file should be created. -/// -/// **type**: -/// Possible values: -/// -/// - [`DIRECTORY`](enum.filetype.html#variant.DIRECTORY): -/// Creates a directory. -#[inline] -pub unsafe fn file_create(fd_: fd, path_: &[u8], type_: filetype) -> errno { - unsafe { cloudabi_sys_file_create(fd_, path_.as_ptr(), path_.len(), type_)} -} - -/// Creates a hard link. -/// -/// ## Parameters -/// -/// **fd1**: -/// The working directory at which the resolution -/// of the source path starts. -/// -/// **path1**: -/// The source path of the file that should be -/// hard linked. -/// -/// **fd2**: -/// The working directory at which the resolution -/// of the destination path starts. -/// -/// **path2**: -/// The destination path at which the hard link -/// should be created. -#[inline] -pub unsafe fn file_link(fd1_: lookup, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno { - unsafe { cloudabi_sys_file_link(fd1_, path1_.as_ptr(), path1_.len(), fd2_, path2_.as_ptr(), path2_.len()) } -} - -/// Opens a file. -/// -/// ## Parameters -/// -/// **dirfd**: -/// The working directory at which the resolution -/// of the file to be opened starts. -/// -/// **path**: -/// The path of the file that should be opened. -/// -/// **oflags**: -/// The method at which the file should be opened. -/// -/// **fds**: -/// [`fdstat.fs_rights_base`](struct.fdstat.html#structfield.fs_rights_base) and -/// [`fdstat.fs_rights_inheriting`](struct.fdstat.html#structfield.fs_rights_inheriting) specify the -/// initial rights of the newly created file -/// descriptor. The operating system is allowed to -/// return a file descriptor with fewer rights -/// than specified, if and only if those rights do -/// not apply to the type of file being opened. -/// -/// [`fdstat.fs_flags`](struct.fdstat.html#structfield.fs_flags) specifies the initial flags -/// of the file descriptor. -/// -/// [`fdstat.fs_filetype`](struct.fdstat.html#structfield.fs_filetype) is ignored. -/// -/// **fd**: -/// The file descriptor of the file that has been -/// opened. -#[inline] -pub unsafe fn file_open( - dirfd_: lookup, - path_: &[u8], - oflags_: oflags, - fds_: *const fdstat, - fd_: &mut fd, -) -> errno { - unsafe { cloudabi_sys_file_open(dirfd_, path_.as_ptr(), path_.len(), oflags_, fds_, fd_) } -} - -/// Reads directory entries from a directory. -/// -/// When successful, the contents of the output buffer consist of -/// a sequence of directory entries. Each directory entry consists -/// of a [`dirent`] object, followed by [`dirent.d_namlen`](struct.dirent.html#structfield.d_namlen) bytes -/// holding the name of the directory entry. -/// -/// This system call fills the output buffer as much as possible, -/// potentially truncating the last directory entry. This allows -/// the caller to grow its read buffer size in case it's too small -/// to fit a single large directory entry, or skip the oversized -/// directory entry. -/// -/// ## Parameters -/// -/// **fd**: -/// The directory from which to read the directory -/// entries. -/// -/// **buf**: -/// The buffer where directory entries are stored. -/// -/// **cookie**: -/// The location within the directory to start -/// reading. -/// -/// **bufused**: -/// The number of bytes stored in the read buffer. -/// If less than the size of the read buffer, the -/// end of the directory has been reached. -#[inline] -pub unsafe fn file_readdir( - fd_: fd, - buf_: &mut [u8], - cookie_: dircookie, - bufused_: &mut usize, -) -> errno { - unsafe { cloudabi_sys_file_readdir(fd_, buf_.as_mut_ptr() as *mut (), buf_.len(), cookie_, bufused_) } -} - -/// Reads the contents of a symbolic link. -/// -/// ## Parameters -/// -/// **fd**: -/// The working directory at which the resolution -/// of the path of the symbolic starts. -/// -/// **path**: -/// The path of the symbolic link whose contents -/// should be read. -/// -/// **buf**: -/// The buffer where the contents of the symbolic -/// link should be stored. -/// -/// **bufused**: -/// The number of bytes placed in the buffer. -#[inline] -pub unsafe fn file_readlink(fd_: fd, path_: &[u8], buf_: &mut [u8], bufused_: &mut usize) -> errno { - unsafe { - cloudabi_sys_file_readlink( - fd_, - path_.as_ptr(), - path_.len(), - buf_.as_mut_ptr(), - buf_.len(), - bufused_, - ) - } -} - -/// Renames a file. -/// -/// ## Parameters -/// -/// **fd1**: -/// The working directory at which the resolution -/// of the source path starts. -/// -/// **path1**: -/// The source path of the file that should be -/// renamed. -/// -/// **fd2**: -/// The working directory at which the resolution -/// of the destination path starts. -/// -/// **path2**: -/// The destination path to which the file should -/// be renamed. -#[inline] -pub unsafe fn file_rename(fd1_: fd, path1_: &[u8], fd2_: fd, path2_: &[u8]) -> errno { - unsafe { - cloudabi_sys_file_rename( - fd1_, - path1_.as_ptr(), - path1_.len(), - fd2_, - path2_.as_ptr(), - path2_.len(), - ) - } -} - -/// Gets attributes of a file by file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor whose attributes have to -/// be obtained. -/// -/// **buf**: -/// The buffer where the file's attributes are -/// stored. -#[inline] -pub unsafe fn file_stat_fget(fd_: fd, buf_: *mut filestat) -> errno { - unsafe { cloudabi_sys_file_stat_fget(fd_, buf_) } -} - -/// Adjusts attributes of a file by file descriptor. -/// -/// ## Parameters -/// -/// **fd**: -/// The file descriptor whose attributes have to -/// be adjusted. -/// -/// **buf**: -/// The desired values of the file attributes that -/// are adjusted. -/// -/// **flags**: -/// A bitmask indicating which attributes have to -/// be adjusted. -#[inline] -pub unsafe fn file_stat_fput(fd_: fd, buf_: *const filestat, flags_: fsflags) -> errno { - unsafe { cloudabi_sys_file_stat_fput(fd_, buf_, flags_) } -} - -/// Gets attributes of a file by path. -/// -/// ## Parameters -/// -/// **fd**: -/// The working directory at which the resolution -/// of the path whose attributes have to be -/// obtained starts. -/// -/// **path**: -/// The path of the file whose attributes have to -/// be obtained. -/// -/// **buf**: -/// The buffer where the file's attributes are -/// stored. -#[inline] -pub unsafe fn file_stat_get(fd_: lookup, path_: &[u8], buf_: *mut filestat) -> errno { - unsafe { cloudabi_sys_file_stat_get(fd_, path_.as_ptr(), path_.len(), buf_) } -} - -/// Adjusts attributes of a file by path. -/// -/// ## Parameters -/// -/// **fd**: -/// The working directory at which the resolution -/// of the path whose attributes have to be -/// adjusted starts. -/// -/// **path**: -/// The path of the file whose attributes have to -/// be adjusted. -/// -/// **buf**: -/// The desired values of the file attributes that -/// are adjusted. -/// -/// **flags**: -/// A bitmask indicating which attributes have to -/// be adjusted. -#[inline] -pub unsafe fn file_stat_put( - fd_: lookup, - path_: &[u8], - buf_: *const filestat, - flags_: fsflags, -) -> errno { - unsafe { cloudabi_sys_file_stat_put(fd_, path_.as_ptr(), path_.len(), buf_, flags_) } -} - -/// Creates a symbolic link. -/// -/// ## Parameters -/// -/// **path1**: -/// The contents of the symbolic link. -/// -/// **fd**: -/// The working directory at which the resolution -/// of the destination path starts. -/// -/// **path2**: -/// The destination path at which the symbolic -/// link should be created. -#[inline] -pub unsafe fn file_symlink(path1_: &[u8], fd_: fd, path2_: &[u8]) -> errno { - unsafe { cloudabi_sys_file_symlink(path1_.as_ptr(), path1_.len(), fd_, path2_.as_ptr(), path2_.len()) } -} - -/// Unlinks a file, or removes a directory. -/// -/// ## Parameters -/// -/// **fd**: -/// The working directory at which the resolution -/// of the path starts. -/// -/// **path**: -/// The path that needs to be unlinked or removed. -/// -/// **flags**: -/// Possible values: -/// -/// - [`REMOVEDIR`](struct.ulflags.html#associatedconstant.REMOVEDIR): -/// If set, attempt to remove a directory. -/// Otherwise, unlink a file. -#[inline] -pub unsafe fn file_unlink(fd_: fd, path_: &[u8], flags_: ulflags) -> errno { - unsafe { cloudabi_sys_file_unlink(fd_, path_.as_ptr(), path_.len(), flags_) } -} - -/// Unlocks a write-locked userspace lock. -/// -/// If a userspace lock is unlocked while having its -/// [`LOCK_KERNEL_MANAGED`](constant.LOCK_KERNEL_MANAGED.html) flag set, the lock cannot be unlocked in -/// userspace directly. This system call needs to be performed -/// instead, so that any waiting threads can be woken up. -/// -/// To prevent spurious invocations of this system call, the lock -/// must be locked for writing. This prevents other threads from -/// acquiring additional read locks while the system call is in -/// progress. If the lock is acquired for reading, it must first -/// be upgraded to a write lock. -/// -/// ## Parameters -/// -/// **lock**: -/// The userspace lock that is locked for writing -/// by the calling thread. -/// -/// **scope**: -/// Whether the lock is stored in private or -/// shared memory. -#[inline] -pub unsafe fn lock_unlock(lock_: *mut lock, scope_: scope) -> errno { - unsafe { cloudabi_sys_lock_unlock(lock_, scope_) } -} - -/// Provides memory advisory information on a region of memory. -/// -/// ## Parameters -/// -/// **mapping**: -/// The pages for which to provide memory advisory -/// information. -/// -/// **advice**: -/// The advice. -#[inline] -pub unsafe fn mem_advise(mapping_: &mut [u8], advice_: advice) -> errno { - unsafe { cloudabi_sys_mem_advise(mapping_.as_mut_ptr() as *mut (), mapping_.len(), advice_) } -} - -/// Creates a memory mapping, making the contents of a file -/// accessible through memory. -/// -/// ## Parameters -/// -/// **addr**: -/// If [`FIXED`](struct.mflags.html#associatedconstant.FIXED) is set, specifies to which -/// address the file region is mapped. Otherwise, -/// the mapping is performed at an unused -/// location. -/// -/// **len**: -/// The length of the memory mapping to be -/// created. -/// -/// **prot**: -/// Initial memory protection options for the -/// memory mapping. -/// -/// **flags**: -/// Memory mapping flags. -/// -/// **fd**: -/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be -/// [`MAP_ANON_FD`](constant.MAP_ANON_FD.html). Otherwise, this argument -/// specifies the file whose contents need to be -/// mapped. -/// -/// **off**: -/// If [`ANON`](struct.mflags.html#associatedconstant.ANON) is set, this argument must be -/// zero. Otherwise, this argument specifies the -/// offset within the file at which the mapping -/// starts. -/// -/// **mem**: -/// The starting address of the memory mapping. -#[inline] -pub unsafe fn mem_map( - addr_: *mut (), - len_: usize, - prot_: mprot, - flags_: mflags, - fd_: fd, - off_: filesize, - mem_: &mut *mut (), -) -> errno { - unsafe { cloudabi_sys_mem_map(addr_, len_, prot_, flags_, fd_, off_, mem_) } -} - -/// Changes the protection of a memory mapping. -/// -/// ## Parameters -/// -/// **mapping**: -/// The pages that need their protection changed. -/// -/// **prot**: -/// New protection options. -#[inline] -pub unsafe fn mem_protect(mapping_: &mut [u8], prot_: mprot) -> errno { - unsafe { cloudabi_sys_mem_protect(mapping_.as_mut_ptr() as *mut (), mapping_.len(), prot_) } -} - -/// Synchronizes a region of memory with its physical storage. -/// -/// ## Parameters -/// -/// **mapping**: -/// The pages that need to be synchronized. -/// -/// **flags**: -/// The method of synchronization. -#[inline] -pub unsafe fn mem_sync(mapping_: &mut [u8], flags_: msflags) -> errno { - unsafe { cloudabi_sys_mem_sync(mapping_.as_mut_ptr() as *mut (), mapping_.len(), flags_) } -} - -/// Unmaps a region of memory. -/// -/// ## Parameters -/// -/// **mapping**: -/// The pages that needs to be unmapped. -#[inline] -pub unsafe fn mem_unmap(mapping_: &mut [u8]) -> errno { - unsafe { cloudabi_sys_mem_unmap(mapping_.as_mut_ptr() as *mut (), mapping_.len()) } -} - -/// Concurrently polls for the occurrence of a set of events. -/// -/// ## Parameters -/// -/// **in**: -/// The events to which to subscribe. -/// -/// **out**: -/// The events that have occurred. -/// -/// **nsubscriptions**: -/// Both the number of subscriptions and events. -/// -/// **nevents**: -/// The number of events stored. -#[inline] -pub unsafe fn poll( - in_: *const subscription, - out_: *mut event, - nsubscriptions_: usize, - nevents_: *mut usize, -) -> errno { - unsafe { cloudabi_sys_poll(in_, out_, nsubscriptions_, nevents_) } -} - -/// Replaces the process by a new executable. -/// -/// Process execution in CloudABI differs from POSIX in two ways: -/// handling of arguments and inheritance of file descriptors. -/// -/// CloudABI does not use string command line arguments. Instead, -/// a buffer with binary data is copied into the address space of -/// the new executable. The kernel does not enforce any specific -/// structure to this data, although CloudABI's C library uses it -/// to store a tree structure that is semantically identical to -/// YAML. -/// -/// Due to the strong focus on thread safety, file descriptors -/// aren't inherited through close-on-exec flags. An explicit -/// list of file descriptors that need to be retained needs to be -/// provided. After execution, file descriptors are placed in the -/// order in which they are stored in the array. This not only -/// makes the execution process deterministic. It also prevents -/// potential information disclosures about the layout of the -/// original process. -/// -/// ## Parameters -/// -/// **fd**: -/// A file descriptor of the new executable. -/// -/// **data**: -/// Binary argument data that is passed on to the -/// new executable. -/// -/// **fds**: -/// The layout of the file descriptor table after -/// execution. -#[inline] -pub unsafe fn proc_exec(fd_: fd, data_: &[u8], fds_: &[fd]) -> errno { - unsafe { cloudabi_sys_proc_exec(fd_, data_.as_ptr() as *const (), data_.len(), fds_.as_ptr(), fds_.len()) } -} - -/// Terminates the process normally. -/// -/// ## Parameters -/// -/// **rval**: -/// The exit code returned by the process. The -/// exit code can be obtained by other processes -/// through [`event.union.proc_terminate.exitcode`](struct.event_proc_terminate.html#structfield.exitcode). -#[inline] -pub unsafe fn proc_exit(rval_: exitcode) -> ! { - unsafe { cloudabi_sys_proc_exit(rval_) } -} - -/// Forks the process of the calling thread. -/// -/// After forking, a new process shall be created, having only a -/// copy of the calling thread. The parent process will obtain a -/// process descriptor. When closed, the child process is -/// automatically signaled with [`KILL`](enum.signal.html#variant.KILL). -/// -/// ## Parameters -/// -/// **fd**: -/// In the parent process: the file descriptor -/// number of the process descriptor. -/// -/// In the child process: [`PROCESS_CHILD`](constant.PROCESS_CHILD.html). -/// -/// **tid**: -/// In the parent process: undefined. -/// -/// In the child process: the thread ID of the -/// initial thread of the child process. -#[inline] -pub unsafe fn proc_fork(fd_: &mut fd, tid_: &mut tid) -> errno { - unsafe { cloudabi_sys_proc_fork(fd_, tid_) } -} - -/// Sends a signal to the process of the calling thread. -/// -/// ## Parameters -/// -/// **sig**: -/// The signal condition that should be triggered. -/// If the signal causes the process to terminate, -/// its condition can be obtained by other -/// processes through -/// [`event.union.proc_terminate.signal`](struct.event_proc_terminate.html#structfield.signal). -#[inline] -pub unsafe fn proc_raise(sig_: signal) -> errno { - unsafe { cloudabi_sys_proc_raise(sig_) } -} - -/// Obtains random data from the kernel random number generator. -/// -/// As this interface is not guaranteed to be fast, it is advised -/// that the random data obtained through this system call is used -/// as the seed for a userspace pseudo-random number generator. -/// -/// ## Parameters -/// -/// **buf**: -/// The buffer that needs to be filled with random -/// data. -#[inline] -pub unsafe fn random_get(buf_: &mut [u8]) -> errno { - unsafe { cloudabi_sys_random_get(buf_.as_mut_ptr() as *mut (), buf_.len()) } -} - -/// Receives a message on a socket. -/// -/// ## Parameters -/// -/// **sock**: -/// The socket on which a message should be -/// received. -/// -/// **in**: -/// Input parameters. -/// -/// **out**: -/// Output parameters. -#[inline] -pub unsafe fn sock_recv(sock_: fd, in_: *const recv_in, out_: *mut recv_out) -> errno { - unsafe { cloudabi_sys_sock_recv(sock_, in_, out_) } -} - -/// Sends a message on a socket. -/// -/// ## Parameters -/// -/// **sock**: -/// The socket on which a message should be sent. -/// -/// **in**: -/// Input parameters. -/// -/// **out**: -/// Output parameters. -#[inline] -pub unsafe fn sock_send(sock_: fd, in_: *const send_in, out_: *mut send_out) -> errno { - unsafe { cloudabi_sys_sock_send(sock_, in_, out_) } -} - -/// Shuts down socket send and receive channels. -/// -/// ## Parameters -/// -/// **sock**: -/// The socket that needs its channels shut down. -/// -/// **how**: -/// Which channels on the socket need to be shut -/// down. -#[inline] -pub unsafe fn sock_shutdown(sock_: fd, how_: sdflags) -> errno { - unsafe { cloudabi_sys_sock_shutdown(sock_, how_) } -} - -/// Creates a new thread within the current process. -/// -/// ## Parameters -/// -/// **attr**: -/// The desired attributes of the new thread. -/// -/// **tid**: -/// The thread ID of the new thread. -#[inline] -pub unsafe fn thread_create(attr_: *mut threadattr, tid_: &mut tid) -> errno { - unsafe { cloudabi_sys_thread_create(attr_, tid_) } -} - -/// Terminates the calling thread. -/// -/// This system call can also unlock a single userspace lock -/// after termination, which can be used to implement thread -/// joining. -/// -/// ## Parameters -/// -/// **lock**: -/// Userspace lock that is locked for writing by -/// the calling thread. -/// -/// **scope**: -/// Whether the lock is stored in private or -/// shared memory. -#[inline] -pub unsafe fn thread_exit(lock_: *mut lock, scope_: scope) -> ! { - unsafe { cloudabi_sys_thread_exit(lock_, scope_) } -} - -/// Temporarily yields execution of the calling thread. -#[inline] -pub unsafe fn thread_yield() -> errno { - unsafe { cloudabi_sys_thread_yield() } -} diff --git a/library/std/src/sys/cloudabi/abi/mod.rs b/library/std/src/sys/cloudabi/abi/mod.rs deleted file mode 100644 index 9d01d24ea83..00000000000 --- a/library/std/src/sys/cloudabi/abi/mod.rs +++ /dev/null @@ -1,3 +0,0 @@ -#[allow(warnings)] -mod cloudabi; -pub use self::cloudabi::*; diff --git a/library/std/src/sys/cloudabi/args.rs b/library/std/src/sys/cloudabi/args.rs deleted file mode 100644 index dea562abad3..00000000000 --- a/library/std/src/sys/cloudabi/args.rs +++ /dev/null @@ -1,7 +0,0 @@ -pub use crate::sys::cloudabi::shims::args::*; - -#[allow(dead_code)] -pub fn init(_: isize, _: *const *const u8) {} - -#[allow(dead_code)] -pub fn cleanup() {} diff --git a/library/std/src/sys/cloudabi/condvar.rs b/library/std/src/sys/cloudabi/condvar.rs deleted file mode 100644 index f09bc01701b..00000000000 --- a/library/std/src/sys/cloudabi/condvar.rs +++ /dev/null @@ -1,149 +0,0 @@ -use crate::mem; -use crate::sync::atomic::{AtomicU32, Ordering}; -use crate::sys::cloudabi::abi; -use crate::sys::mutex::{self, Mutex}; -use crate::sys::time::checked_dur2intervals; -use crate::time::Duration; - -extern "C" { - #[thread_local] - static __pthread_thread_id: abi::tid; -} - -pub struct Condvar { - condvar: AtomicU32, -} - -pub type MovableCondvar = Condvar; - -unsafe impl Send for Condvar {} -unsafe impl Sync for Condvar {} - -impl Condvar { - pub const fn new() -> Condvar { - Condvar { condvar: AtomicU32::new(abi::CONDVAR_HAS_NO_WAITERS.0) } - } - - pub unsafe fn init(&mut self) {} - - pub unsafe fn notify_one(&self) { - if self.condvar.load(Ordering::Relaxed) != abi::CONDVAR_HAS_NO_WAITERS.0 { - let ret = abi::condvar_signal( - &self.condvar as *const AtomicU32 as *mut abi::condvar, - abi::scope::PRIVATE, - 1, - ); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to signal on condition variable"); - } - } - - pub unsafe fn notify_all(&self) { - if self.condvar.load(Ordering::Relaxed) != abi::CONDVAR_HAS_NO_WAITERS.0 { - let ret = abi::condvar_signal( - &self.condvar as *const AtomicU32 as *mut abi::condvar, - abi::scope::PRIVATE, - abi::nthreads::MAX, - ); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to broadcast on condition variable"); - } - } - - pub unsafe fn wait(&self, mutex: &Mutex) { - let mutex = mutex::raw(mutex); - assert_eq!( - mutex.load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - "This lock is not write-locked by this thread" - ); - - // Call into the kernel to wait on the condition variable. - let subscription = abi::subscription { - type_: abi::eventtype::CONDVAR, - union: abi::subscription_union { - condvar: abi::subscription_condvar { - condvar: &self.condvar as *const AtomicU32 as *mut abi::condvar, - condvar_scope: abi::scope::PRIVATE, - lock: mutex as *const AtomicU32 as *mut abi::lock, - lock_scope: abi::scope::PRIVATE, - }, - }, - ..mem::zeroed() - }; - let mut event: mem::MaybeUninit = mem::MaybeUninit::uninit(); - let mut nevents: mem::MaybeUninit = mem::MaybeUninit::uninit(); - let ret = abi::poll(&subscription, event.as_mut_ptr(), 1, nevents.as_mut_ptr()); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to wait on condition variable"); - assert_eq!( - event.assume_init().error, - abi::errno::SUCCESS, - "Failed to wait on condition variable" - ); - } - - pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool { - let mutex = mutex::raw(mutex); - assert_eq!( - mutex.load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - "This lock is not write-locked by this thread" - ); - - // Call into the kernel to wait on the condition variable. - let timeout = - checked_dur2intervals(&dur).expect("overflow converting duration to nanoseconds"); - let subscriptions = [ - abi::subscription { - type_: abi::eventtype::CONDVAR, - union: abi::subscription_union { - condvar: abi::subscription_condvar { - condvar: &self.condvar as *const AtomicU32 as *mut abi::condvar, - condvar_scope: abi::scope::PRIVATE, - lock: mutex as *const AtomicU32 as *mut abi::lock, - lock_scope: abi::scope::PRIVATE, - }, - }, - ..mem::zeroed() - }, - abi::subscription { - type_: abi::eventtype::CLOCK, - union: abi::subscription_union { - clock: abi::subscription_clock { - clock_id: abi::clockid::MONOTONIC, - timeout, - ..mem::zeroed() - }, - }, - ..mem::zeroed() - }, - ]; - let mut events: [mem::MaybeUninit; 2] = [mem::MaybeUninit::uninit(); 2]; - let mut nevents: mem::MaybeUninit = mem::MaybeUninit::uninit(); - let ret = abi::poll( - subscriptions.as_ptr(), - mem::MaybeUninit::slice_as_mut_ptr(&mut events), - 2, - nevents.as_mut_ptr(), - ); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to wait on condition variable"); - let nevents = nevents.assume_init(); - for i in 0..nevents { - assert_eq!( - events[i].assume_init().error, - abi::errno::SUCCESS, - "Failed to wait on condition variable" - ); - if events[i].assume_init().type_ == abi::eventtype::CONDVAR { - return true; - } - } - false - } - - pub unsafe fn destroy(&self) { - assert_eq!( - self.condvar.load(Ordering::Relaxed), - abi::CONDVAR_HAS_NO_WAITERS.0, - "Attempted to destroy a condition variable with blocked threads" - ); - } -} diff --git a/library/std/src/sys/cloudabi/io.rs b/library/std/src/sys/cloudabi/io.rs deleted file mode 100644 index d5f475b4310..00000000000 --- a/library/std/src/sys/cloudabi/io.rs +++ /dev/null @@ -1,47 +0,0 @@ -use crate::mem; - -#[derive(Copy, Clone)] -pub struct IoSlice<'a>(&'a [u8]); - -impl<'a> IoSlice<'a> { - #[inline] - pub fn new(buf: &'a [u8]) -> IoSlice<'a> { - IoSlice(buf) - } - - #[inline] - pub fn advance(&mut self, n: usize) { - self.0 = &self.0[n..] - } - - #[inline] - pub fn as_slice(&self) -> &[u8] { - self.0 - } -} - -pub struct IoSliceMut<'a>(&'a mut [u8]); - -impl<'a> IoSliceMut<'a> { - #[inline] - pub fn new(buf: &'a mut [u8]) -> IoSliceMut<'a> { - IoSliceMut(buf) - } - - #[inline] - pub fn advance(&mut self, n: usize) { - let slice = mem::replace(&mut self.0, &mut []); - let (_, remaining) = slice.split_at_mut(n); - self.0 = remaining; - } - - #[inline] - pub fn as_slice(&self) -> &[u8] { - self.0 - } - - #[inline] - pub fn as_mut_slice(&mut self) -> &mut [u8] { - self.0 - } -} diff --git a/library/std/src/sys/cloudabi/mod.rs b/library/std/src/sys/cloudabi/mod.rs deleted file mode 100644 index b4a9246ca4e..00000000000 --- a/library/std/src/sys/cloudabi/mod.rs +++ /dev/null @@ -1,73 +0,0 @@ -#![deny(unsafe_op_in_unsafe_fn)] - -use crate::io::ErrorKind; -use crate::mem; - -#[path = "../unix/alloc.rs"] -pub mod alloc; -pub mod args; -#[path = "../unix/cmath.rs"] -pub mod cmath; -pub mod condvar; -pub mod io; -#[path = "../unix/memchr.rs"] -pub mod memchr; -pub mod mutex; -pub mod os; -pub mod rwlock; -pub mod stack_overflow; -pub mod stdio; -pub mod thread; -#[path = "../unix/thread_local_key.rs"] -pub mod thread_local_key; -pub mod time; - -pub use crate::sys_common::os_str_bytes as os_str; - -mod abi; - -mod shims; -pub use self::shims::*; - -#[allow(dead_code)] -pub fn init() {} - -pub fn decode_error_kind(errno: i32) -> ErrorKind { - match errno { - x if x == abi::errno::ACCES as i32 => ErrorKind::PermissionDenied, - x if x == abi::errno::ADDRINUSE as i32 => ErrorKind::AddrInUse, - x if x == abi::errno::ADDRNOTAVAIL as i32 => ErrorKind::AddrNotAvailable, - x if x == abi::errno::AGAIN as i32 => ErrorKind::WouldBlock, - x if x == abi::errno::CONNABORTED as i32 => ErrorKind::ConnectionAborted, - x if x == abi::errno::CONNREFUSED as i32 => ErrorKind::ConnectionRefused, - x if x == abi::errno::CONNRESET as i32 => ErrorKind::ConnectionReset, - x if x == abi::errno::EXIST as i32 => ErrorKind::AlreadyExists, - x if x == abi::errno::INTR as i32 => ErrorKind::Interrupted, - x if x == abi::errno::INVAL as i32 => ErrorKind::InvalidInput, - x if x == abi::errno::NOENT as i32 => ErrorKind::NotFound, - x if x == abi::errno::NOTCONN as i32 => ErrorKind::NotConnected, - x if x == abi::errno::PERM as i32 => ErrorKind::PermissionDenied, - x if x == abi::errno::PIPE as i32 => ErrorKind::BrokenPipe, - x if x == abi::errno::TIMEDOUT as i32 => ErrorKind::TimedOut, - _ => ErrorKind::Other, - } -} - -pub fn abort_internal() -> ! { - core::intrinsics::abort(); -} - -pub use libc::strlen; - -pub fn hashmap_random_keys() -> (u64, u64) { - unsafe { - let mut v: mem::MaybeUninit<(u64, u64)> = mem::MaybeUninit::uninit(); - libc::arc4random_buf(v.as_mut_ptr() as *mut libc::c_void, mem::size_of_val(&v)); - v.assume_init() - } -} - -#[cfg_attr(feature = "backtrace", link(name = "unwind"))] -#[link(name = "c")] -#[link(name = "compiler_rt")] -extern "C" {} diff --git a/library/std/src/sys/cloudabi/mutex.rs b/library/std/src/sys/cloudabi/mutex.rs deleted file mode 100644 index 9dafcbc1fba..00000000000 --- a/library/std/src/sys/cloudabi/mutex.rs +++ /dev/null @@ -1,153 +0,0 @@ -use crate::cell::Cell; -use crate::mem; -use crate::mem::MaybeUninit; -use crate::sync::atomic::{AtomicU32, Ordering}; -use crate::sys::cloudabi::abi; -use crate::sys::rwlock::{self, RWLock}; - -extern "C" { - #[thread_local] - static __pthread_thread_id: abi::tid; -} - -// Implement Mutex using an RWLock. This doesn't introduce any -// performance overhead in this environment, as the operations would be -// implemented identically. -pub struct Mutex(RWLock); - -pub type MovableMutex = Mutex; - -pub unsafe fn raw(m: &Mutex) -> &AtomicU32 { - rwlock::raw(&m.0) -} - -impl Mutex { - pub const fn new() -> Mutex { - Mutex(RWLock::new()) - } - - pub unsafe fn init(&mut self) { - // This function should normally reinitialize the mutex after - // moving it to a different memory address. This implementation - // does not require adjustments after moving. - } - - pub unsafe fn try_lock(&self) -> bool { - self.0.try_write() - } - - pub unsafe fn lock(&self) { - self.0.write() - } - - pub unsafe fn unlock(&self) { - self.0.write_unlock() - } - - pub unsafe fn destroy(&self) { - self.0.destroy() - } -} - -pub struct ReentrantMutex { - lock: AtomicU32, - recursion: Cell, -} - -unsafe impl Send for ReentrantMutex {} -unsafe impl Sync for ReentrantMutex {} - -impl ReentrantMutex { - pub const unsafe fn uninitialized() -> ReentrantMutex { - ReentrantMutex { lock: AtomicU32::new(abi::LOCK_UNLOCKED.0), recursion: Cell::new(0) } - } - - pub unsafe fn init(&self) {} - - pub unsafe fn try_lock(&self) -> bool { - // Attempt to acquire the lock. - if let Err(old) = self.lock.compare_exchange( - abi::LOCK_UNLOCKED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - Ordering::Acquire, - Ordering::Relaxed, - ) { - // If we fail to acquire the lock, it may be the case - // that we've already acquired it and may need to recurse. - if old & !abi::LOCK_KERNEL_MANAGED.0 == __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0 { - self.recursion.set(self.recursion.get() + 1); - true - } else { - false - } - } else { - // Success. - assert_eq!(self.recursion.get(), 0, "Mutex has invalid recursion count"); - true - } - } - - pub unsafe fn lock(&self) { - if !self.try_lock() { - // Call into the kernel to acquire a write lock. - let lock = &self.lock as *const AtomicU32; - let subscription = abi::subscription { - type_: abi::eventtype::LOCK_WRLOCK, - union: abi::subscription_union { - lock: abi::subscription_lock { - lock: lock as *mut abi::lock, - lock_scope: abi::scope::PRIVATE, - }, - }, - ..mem::zeroed() - }; - let mut event = MaybeUninit::::uninit(); - let mut nevents = MaybeUninit::::uninit(); - // SAFE: The caller must to ensure that `event` and `nevents` are initialized. - let ret = - unsafe { abi::poll(&subscription, event.as_mut_ptr(), 1, nevents.as_mut_ptr()) }; - assert_eq!(ret, abi::errno::SUCCESS, "Failed to acquire mutex"); - let event = event.assume_init(); - assert_eq!(event.error, abi::errno::SUCCESS, "Failed to acquire mutex"); - } - } - - pub unsafe fn unlock(&self) { - assert_eq!( - self.lock.load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - "This mutex is locked by a different thread" - ); - - let r = self.recursion.get(); - if r > 0 { - self.recursion.set(r - 1); - } else if !self - .lock - .compare_exchange( - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - abi::LOCK_UNLOCKED.0, - Ordering::Release, - Ordering::Relaxed, - ) - .is_ok() - { - // Lock is managed by kernelspace. Call into the kernel - // to unblock waiting threads. - let ret = abi::lock_unlock( - &self.lock as *const AtomicU32 as *mut abi::lock, - abi::scope::PRIVATE, - ); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to unlock a mutex"); - } - } - - pub unsafe fn destroy(&self) { - assert_eq!( - self.lock.load(Ordering::Relaxed), - abi::LOCK_UNLOCKED.0, - "Attempted to destroy locked mutex" - ); - assert_eq!(self.recursion.get(), 0, "Recursion counter invalid"); - } -} diff --git a/library/std/src/sys/cloudabi/os.rs b/library/std/src/sys/cloudabi/os.rs deleted file mode 100644 index 326faaa852a..00000000000 --- a/library/std/src/sys/cloudabi/os.rs +++ /dev/null @@ -1,26 +0,0 @@ -use crate::ffi::CStr; -use crate::str; - -use libc::c_int; - -pub use crate::sys::cloudabi::shims::os::*; - -pub fn errno() -> i32 { - extern "C" { - #[thread_local] - static errno: c_int; - } - - unsafe { errno as i32 } -} - -/// Gets a detailed string description for the given error number. -pub fn error_string(errno: i32) -> String { - // cloudlibc's strerror() is guaranteed to be thread-safe. There is - // thus no need to use strerror_r(). - str::from_utf8(unsafe { CStr::from_ptr(libc::strerror(errno)) }.to_bytes()).unwrap().to_owned() -} - -pub fn exit(code: i32) -> ! { - unsafe { libc::exit(code as c_int) } -} diff --git a/library/std/src/sys/cloudabi/rwlock.rs b/library/std/src/sys/cloudabi/rwlock.rs deleted file mode 100644 index 508de8ba47c..00000000000 --- a/library/std/src/sys/cloudabi/rwlock.rs +++ /dev/null @@ -1,215 +0,0 @@ -use crate::mem; -use crate::mem::MaybeUninit; -use crate::sync::atomic::{AtomicU32, Ordering}; -use crate::sys::cloudabi::abi; - -extern "C" { - #[thread_local] - static __pthread_thread_id: abi::tid; -} - -#[thread_local] -static mut RDLOCKS_ACQUIRED: u32 = 0; - -pub struct RWLock { - lock: AtomicU32, -} - -pub unsafe fn raw(r: &RWLock) -> &AtomicU32 { - &r.lock -} - -unsafe impl Send for RWLock {} -unsafe impl Sync for RWLock {} - -impl RWLock { - pub const fn new() -> RWLock { - RWLock { lock: AtomicU32::new(abi::LOCK_UNLOCKED.0) } - } - - pub unsafe fn try_read(&self) -> bool { - let mut old = abi::LOCK_UNLOCKED.0; - while let Err(cur) = - self.lock.compare_exchange_weak(old, old + 1, Ordering::Acquire, Ordering::Relaxed) - { - if (cur & abi::LOCK_WRLOCKED.0) != 0 { - // Another thread already has a write lock. - assert_ne!( - old & !abi::LOCK_KERNEL_MANAGED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - "Attempted to acquire a read lock while holding a write lock" - ); - return false; - } else if (old & abi::LOCK_KERNEL_MANAGED.0) != 0 && RDLOCKS_ACQUIRED == 0 { - // Lock has threads waiting for the lock. Only acquire - // the lock if we have already acquired read locks. In - // that case, it is justified to acquire this lock to - // prevent a deadlock. - return false; - } - old = cur; - } - - RDLOCKS_ACQUIRED += 1; - true - } - - pub unsafe fn read(&self) { - if !self.try_read() { - // Call into the kernel to acquire a read lock. - let subscription = abi::subscription { - type_: abi::eventtype::LOCK_RDLOCK, - union: abi::subscription_union { - lock: abi::subscription_lock { - lock: &self.lock as *const AtomicU32 as *mut abi::lock, - lock_scope: abi::scope::PRIVATE, - }, - }, - ..mem::zeroed() - }; - let mut event = MaybeUninit::::uninit(); - let mut nevents = MaybeUninit::::uninit(); - let ret = abi::poll(&subscription, event.as_mut_ptr(), 1, nevents.as_mut_ptr()); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to acquire read lock"); - let event = event.assume_init(); - assert_eq!(event.error, abi::errno::SUCCESS, "Failed to acquire read lock"); - - RDLOCKS_ACQUIRED += 1; - } - } - - pub unsafe fn read_unlock(&self) { - // Perform a read unlock. We can do this in userspace, except when - // other threads are blocked and we are performing the last unlock. - // In that case, call into the kernel. - // - // Other threads may attempt to increment the read lock count, - // meaning that the call into the kernel could be spurious. To - // prevent this from happening, upgrade to a write lock first. This - // allows us to call into the kernel, having the guarantee that the - // lock value will not change in the meantime. - assert!(RDLOCKS_ACQUIRED > 0, "Bad lock count"); - let mut old = 1; - loop { - if old == 1 | abi::LOCK_KERNEL_MANAGED.0 { - // Last read lock while threads are waiting. Attempt to upgrade - // to a write lock before calling into the kernel to unlock. - if let Err(cur) = self.lock.compare_exchange_weak( - old, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0 | abi::LOCK_KERNEL_MANAGED.0, - Ordering::Acquire, - Ordering::Relaxed, - ) { - old = cur; - } else { - // Call into the kernel to unlock. - let ret = abi::lock_unlock( - &self.lock as *const AtomicU32 as *mut abi::lock, - abi::scope::PRIVATE, - ); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to write unlock a rwlock"); - break; - } - } else { - // No threads waiting or not the last read lock. Just decrement - // the read lock count. - assert_ne!(old & !abi::LOCK_KERNEL_MANAGED.0, 0, "This rwlock is not locked"); - assert_eq!( - old & abi::LOCK_WRLOCKED.0, - 0, - "Attempted to read-unlock a write-locked rwlock" - ); - if let Err(cur) = self.lock.compare_exchange_weak( - old, - old - 1, - Ordering::Acquire, - Ordering::Relaxed, - ) { - old = cur; - } else { - break; - } - } - } - - RDLOCKS_ACQUIRED -= 1; - } - - pub unsafe fn try_write(&self) -> bool { - // Attempt to acquire the lock. - if let Err(old) = self.lock.compare_exchange( - abi::LOCK_UNLOCKED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - Ordering::Acquire, - Ordering::Relaxed, - ) { - // Failure. Crash upon recursive acquisition. - assert_ne!( - old & !abi::LOCK_KERNEL_MANAGED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - "Attempted to recursive write-lock a rwlock", - ); - false - } else { - // Success. - true - } - } - - pub unsafe fn write(&self) { - if !self.try_write() { - // Call into the kernel to acquire a write lock. - let subscription = abi::subscription { - type_: abi::eventtype::LOCK_WRLOCK, - union: abi::subscription_union { - lock: abi::subscription_lock { - lock: &self.lock as *const AtomicU32 as *mut abi::lock, - lock_scope: abi::scope::PRIVATE, - }, - }, - ..mem::zeroed() - }; - let mut event = MaybeUninit::::uninit(); - let mut nevents = MaybeUninit::::uninit(); - let ret = abi::poll(&subscription, event.as_mut_ptr(), 1, nevents.as_mut_ptr()); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to acquire write lock"); - let event = event.assume_init(); - assert_eq!(event.error, abi::errno::SUCCESS, "Failed to acquire write lock"); - } - } - - pub unsafe fn write_unlock(&self) { - assert_eq!( - self.lock.load(Ordering::Relaxed) & !abi::LOCK_KERNEL_MANAGED.0, - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - "This rwlock is not write-locked by this thread" - ); - - if !self - .lock - .compare_exchange( - __pthread_thread_id.0 | abi::LOCK_WRLOCKED.0, - abi::LOCK_UNLOCKED.0, - Ordering::Release, - Ordering::Relaxed, - ) - .is_ok() - { - // Lock is managed by kernelspace. Call into the kernel - // to unblock waiting threads. - let ret = abi::lock_unlock( - &self.lock as *const AtomicU32 as *mut abi::lock, - abi::scope::PRIVATE, - ); - assert_eq!(ret, abi::errno::SUCCESS, "Failed to write unlock a rwlock"); - } - } - - pub unsafe fn destroy(&self) { - assert_eq!( - self.lock.load(Ordering::Relaxed), - abi::LOCK_UNLOCKED.0, - "Attempted to destroy locked rwlock" - ); - } -} diff --git a/library/std/src/sys/cloudabi/shims/args.rs b/library/std/src/sys/cloudabi/shims/args.rs deleted file mode 100644 index f5cf71caf6c..00000000000 --- a/library/std/src/sys/cloudabi/shims/args.rs +++ /dev/null @@ -1,35 +0,0 @@ -use crate::ffi::OsString; - -pub struct Args(()); - -impl Args { - pub fn inner_debug(&self) -> &[OsString] { - &[] - } -} - -impl Iterator for Args { - type Item = OsString; - fn next(&mut self) -> Option { - None - } - fn size_hint(&self) -> (usize, Option) { - (0, Some(0)) - } -} - -impl ExactSizeIterator for Args { - fn len(&self) -> usize { - 0 - } -} - -impl DoubleEndedIterator for Args { - fn next_back(&mut self) -> Option { - None - } -} - -pub fn args() -> Args { - Args(()) -} diff --git a/library/std/src/sys/cloudabi/shims/env.rs b/library/std/src/sys/cloudabi/shims/env.rs deleted file mode 100644 index de165a864b9..00000000000 --- a/library/std/src/sys/cloudabi/shims/env.rs +++ /dev/null @@ -1,9 +0,0 @@ -pub mod os { - pub const FAMILY: &str = "cloudabi"; - pub const OS: &str = "cloudabi"; - pub const DLL_PREFIX: &str = "lib"; - pub const DLL_SUFFIX: &str = ".so"; - pub const DLL_EXTENSION: &str = "so"; - pub const EXE_SUFFIX: &str = ""; - pub const EXE_EXTENSION: &str = ""; -} diff --git a/library/std/src/sys/cloudabi/shims/fs.rs b/library/std/src/sys/cloudabi/shims/fs.rs deleted file mode 100644 index a11cde9aea3..00000000000 --- a/library/std/src/sys/cloudabi/shims/fs.rs +++ /dev/null @@ -1,308 +0,0 @@ -use crate::ffi::OsString; -use crate::fmt; -use crate::hash::{Hash, Hasher}; -use crate::io::{self, IoSlice, IoSliceMut, SeekFrom}; -use crate::path::{Path, PathBuf}; -use crate::sys::time::SystemTime; -use crate::sys::{unsupported, Void}; - -pub struct File(Void); - -pub struct FileAttr(Void); - -pub struct ReadDir(Void); - -pub struct DirEntry(Void); - -#[derive(Clone, Debug)] -pub struct OpenOptions {} - -pub struct FilePermissions(Void); - -pub struct FileType(Void); - -#[derive(Debug)] -pub struct DirBuilder {} - -impl FileAttr { - pub fn size(&self) -> u64 { - match self.0 {} - } - - pub fn perm(&self) -> FilePermissions { - match self.0 {} - } - - pub fn file_type(&self) -> FileType { - match self.0 {} - } - - pub fn modified(&self) -> io::Result { - match self.0 {} - } - - pub fn accessed(&self) -> io::Result { - match self.0 {} - } - - pub fn created(&self) -> io::Result { - match self.0 {} - } -} - -impl Clone for FileAttr { - fn clone(&self) -> FileAttr { - match self.0 {} - } -} - -impl FilePermissions { - pub fn readonly(&self) -> bool { - match self.0 {} - } - - pub fn set_readonly(&mut self, _readonly: bool) { - match self.0 {} - } -} - -impl Clone for FilePermissions { - fn clone(&self) -> FilePermissions { - match self.0 {} - } -} - -impl PartialEq for FilePermissions { - fn eq(&self, _other: &FilePermissions) -> bool { - match self.0 {} - } -} - -impl Eq for FilePermissions {} - -impl fmt::Debug for FilePermissions { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -impl FileType { - pub fn is_dir(&self) -> bool { - match self.0 {} - } - - pub fn is_file(&self) -> bool { - match self.0 {} - } - - pub fn is_symlink(&self) -> bool { - match self.0 {} - } -} - -impl Clone for FileType { - fn clone(&self) -> FileType { - match self.0 {} - } -} - -impl Copy for FileType {} - -impl PartialEq for FileType { - fn eq(&self, _other: &FileType) -> bool { - match self.0 {} - } -} - -impl Eq for FileType {} - -impl Hash for FileType { - fn hash(&self, _h: &mut H) { - match self.0 {} - } -} - -impl fmt::Debug for FileType { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -impl fmt::Debug for ReadDir { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -impl Iterator for ReadDir { - type Item = io::Result; - - fn next(&mut self) -> Option> { - match self.0 {} - } -} - -impl DirEntry { - pub fn path(&self) -> PathBuf { - match self.0 {} - } - - pub fn file_name(&self) -> OsString { - match self.0 {} - } - - pub fn metadata(&self) -> io::Result { - match self.0 {} - } - - pub fn file_type(&self) -> io::Result { - match self.0 {} - } -} - -impl OpenOptions { - pub fn new() -> OpenOptions { - OpenOptions {} - } - - pub fn read(&mut self, _read: bool) {} - pub fn write(&mut self, _write: bool) {} - pub fn append(&mut self, _append: bool) {} - pub fn truncate(&mut self, _truncate: bool) {} - pub fn create(&mut self, _create: bool) {} - pub fn create_new(&mut self, _create_new: bool) {} -} - -impl File { - pub fn open(_path: &Path, _opts: &OpenOptions) -> io::Result { - unsupported() - } - - pub fn file_attr(&self) -> io::Result { - match self.0 {} - } - - pub fn fsync(&self) -> io::Result<()> { - match self.0 {} - } - - pub fn datasync(&self) -> io::Result<()> { - match self.0 {} - } - - pub fn truncate(&self, _size: u64) -> io::Result<()> { - match self.0 {} - } - - pub fn read(&self, _buf: &mut [u8]) -> io::Result { - match self.0 {} - } - - pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result { - match self.0 {} - } - - pub fn is_read_vectored(&self) -> bool { - match self.0 {} - } - - pub fn write(&self, _buf: &[u8]) -> io::Result { - match self.0 {} - } - - pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result { - match self.0 {} - } - - pub fn is_write_vectored(&self) -> bool { - match self.0 {} - } - - pub fn flush(&self) -> io::Result<()> { - match self.0 {} - } - - pub fn seek(&self, _pos: SeekFrom) -> io::Result { - match self.0 {} - } - - pub fn duplicate(&self) -> io::Result { - match self.0 {} - } - - pub fn set_permissions(&self, _perm: FilePermissions) -> io::Result<()> { - match self.0 {} - } - - pub fn diverge(&self) -> ! { - match self.0 {} - } -} - -impl DirBuilder { - pub fn new() -> DirBuilder { - DirBuilder {} - } - - pub fn mkdir(&self, _p: &Path) -> io::Result<()> { - unsupported() - } -} - -impl fmt::Debug for File { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -pub fn readdir(_p: &Path) -> io::Result { - unsupported() -} - -pub fn unlink(_p: &Path) -> io::Result<()> { - unsupported() -} - -pub fn rename(_old: &Path, _new: &Path) -> io::Result<()> { - unsupported() -} - -pub fn set_perm(_p: &Path, perm: FilePermissions) -> io::Result<()> { - match perm.0 {} -} - -pub fn rmdir(_p: &Path) -> io::Result<()> { - unsupported() -} - -pub fn remove_dir_all(_path: &Path) -> io::Result<()> { - unsupported() -} - -pub fn readlink(_p: &Path) -> io::Result { - unsupported() -} - -pub fn symlink(_original: &Path, _link: &Path) -> io::Result<()> { - unsupported() -} - -pub fn link(_src: &Path, _dst: &Path) -> io::Result<()> { - unsupported() -} - -pub fn stat(_p: &Path) -> io::Result { - unsupported() -} - -pub fn lstat(_p: &Path) -> io::Result { - unsupported() -} - -pub fn canonicalize(_p: &Path) -> io::Result { - unsupported() -} - -pub fn copy(_from: &Path, _to: &Path) -> io::Result { - unsupported() -} diff --git a/library/std/src/sys/cloudabi/shims/mod.rs b/library/std/src/sys/cloudabi/shims/mod.rs deleted file mode 100644 index b1b5f142f45..00000000000 --- a/library/std/src/sys/cloudabi/shims/mod.rs +++ /dev/null @@ -1,19 +0,0 @@ -use crate::io; - -pub mod args; -pub mod env; -pub mod fs; -pub mod net; -pub mod os; -#[path = "../../unix/path.rs"] -pub mod path; -pub mod pipe; -pub mod process; - -// This enum is used as the storage for a bunch of types which can't actually exist. -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub enum Void {} - -pub fn unsupported() -> io::Result { - Err(io::Error::new(io::ErrorKind::Other, "This function is not available on CloudABI.")) -} diff --git a/library/std/src/sys/cloudabi/shims/net.rs b/library/std/src/sys/cloudabi/shims/net.rs deleted file mode 100644 index 375aaab405d..00000000000 --- a/library/std/src/sys/cloudabi/shims/net.rs +++ /dev/null @@ -1,326 +0,0 @@ -use crate::convert::TryFrom; -use crate::fmt; -use crate::io::{self, IoSlice, IoSliceMut}; -use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; -use crate::sys::{unsupported, Void}; -use crate::time::Duration; - -#[allow(unused_extern_crates)] -pub extern crate libc as netc; - -pub struct TcpStream(Void); - -impl TcpStream { - pub fn connect(_: io::Result<&SocketAddr>) -> io::Result { - unsupported() - } - - pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result { - unsupported() - } - - pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} - } - - pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} - } - - pub fn read_timeout(&self) -> io::Result> { - match self.0 {} - } - - pub fn write_timeout(&self) -> io::Result> { - match self.0 {} - } - - pub fn peek(&self, _: &mut [u8]) -> io::Result { - match self.0 {} - } - - pub fn read(&self, _: &mut [u8]) -> io::Result { - match self.0 {} - } - - pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result { - match self.0 {} - } - - pub fn is_read_vectored(&self) -> bool { - match self.0 {} - } - - pub fn write(&self, _: &[u8]) -> io::Result { - match self.0 {} - } - - pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result { - match self.0 {} - } - - pub fn is_write_vectored(&self) -> bool { - match self.0 {} - } - - pub fn peer_addr(&self) -> io::Result { - match self.0 {} - } - - pub fn socket_addr(&self) -> io::Result { - match self.0 {} - } - - pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { - match self.0 {} - } - - pub fn duplicate(&self) -> io::Result { - match self.0 {} - } - - pub fn set_nodelay(&self, _: bool) -> io::Result<()> { - match self.0 {} - } - - pub fn nodelay(&self) -> io::Result { - match self.0 {} - } - - pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} - } - - pub fn ttl(&self) -> io::Result { - match self.0 {} - } - - pub fn take_error(&self) -> io::Result> { - match self.0 {} - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} - } -} - -impl fmt::Debug for TcpStream { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -pub struct TcpListener(Void); - -impl TcpListener { - pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { - unsupported() - } - - pub fn socket_addr(&self) -> io::Result { - match self.0 {} - } - - pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { - match self.0 {} - } - - pub fn duplicate(&self) -> io::Result { - match self.0 {} - } - - pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} - } - - pub fn ttl(&self) -> io::Result { - match self.0 {} - } - - pub fn set_only_v6(&self, _: bool) -> io::Result<()> { - match self.0 {} - } - - pub fn only_v6(&self) -> io::Result { - match self.0 {} - } - - pub fn take_error(&self) -> io::Result> { - match self.0 {} - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} - } -} - -impl fmt::Debug for TcpListener { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -pub struct UdpSocket(Void); - -impl UdpSocket { - pub fn bind(_: io::Result<&SocketAddr>) -> io::Result { - unsupported() - } - - pub fn peer_addr(&self) -> io::Result { - match self.0 {} - } - - pub fn socket_addr(&self) -> io::Result { - match self.0 {} - } - - pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - match self.0 {} - } - - pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { - match self.0 {} - } - - pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result { - match self.0 {} - } - - pub fn duplicate(&self) -> io::Result { - match self.0 {} - } - - pub fn set_read_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} - } - - pub fn set_write_timeout(&self, _: Option) -> io::Result<()> { - match self.0 {} - } - - pub fn read_timeout(&self) -> io::Result> { - match self.0 {} - } - - pub fn write_timeout(&self) -> io::Result> { - match self.0 {} - } - - pub fn set_broadcast(&self, _: bool) -> io::Result<()> { - match self.0 {} - } - - pub fn broadcast(&self) -> io::Result { - match self.0 {} - } - - pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> { - match self.0 {} - } - - pub fn multicast_loop_v4(&self) -> io::Result { - match self.0 {} - } - - pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> { - match self.0 {} - } - - pub fn multicast_ttl_v4(&self) -> io::Result { - match self.0 {} - } - - pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> { - match self.0 {} - } - - pub fn multicast_loop_v6(&self) -> io::Result { - match self.0 {} - } - - pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - match self.0 {} - } - - pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - match self.0 {} - } - - pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { - match self.0 {} - } - - pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { - match self.0 {} - } - - pub fn set_ttl(&self, _: u32) -> io::Result<()> { - match self.0 {} - } - - pub fn ttl(&self) -> io::Result { - match self.0 {} - } - - pub fn take_error(&self) -> io::Result> { - match self.0 {} - } - - pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { - match self.0 {} - } - - pub fn recv(&self, _: &mut [u8]) -> io::Result { - match self.0 {} - } - - pub fn peek(&self, _: &mut [u8]) -> io::Result { - match self.0 {} - } - - pub fn send(&self, _: &[u8]) -> io::Result { - match self.0 {} - } - - pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { - match self.0 {} - } -} - -impl fmt::Debug for UdpSocket { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -pub struct LookupHost(Void); - -impl LookupHost { - pub fn port(&self) -> u16 { - match self.0 {} - } -} - -impl Iterator for LookupHost { - type Item = SocketAddr; - fn next(&mut self) -> Option { - match self.0 {} - } -} - -impl TryFrom<&str> for LookupHost { - type Error = io::Error; - - fn try_from(_v: &str) -> io::Result { - unsupported() - } -} - -impl<'a> TryFrom<(&'a str, u16)> for LookupHost { - type Error = io::Error; - - fn try_from(_v: (&'a str, u16)) -> io::Result { - unsupported() - } -} diff --git a/library/std/src/sys/cloudabi/shims/os.rs b/library/std/src/sys/cloudabi/shims/os.rs deleted file mode 100644 index 779e6d54b7c..00000000000 --- a/library/std/src/sys/cloudabi/shims/os.rs +++ /dev/null @@ -1,86 +0,0 @@ -use crate::error::Error as StdError; -use crate::ffi::{OsStr, OsString}; -use crate::fmt; -use crate::io; -use crate::iter; -use crate::path::{self, PathBuf}; -use crate::sys::{unsupported, Void}; - -pub fn getcwd() -> io::Result { - unsupported() -} - -pub fn chdir(_: &path::Path) -> io::Result<()> { - unsupported() -} - -pub type Env = iter::Empty<(OsString, OsString)>; - -pub fn env() -> Env { - iter::empty() -} - -pub fn getenv(_: &OsStr) -> io::Result> { - Ok(None) -} - -pub fn setenv(_: &OsStr, _: &OsStr) -> io::Result<()> { - unsupported() -} - -pub fn unsetenv(_: &OsStr) -> io::Result<()> { - unsupported() -} - -pub struct SplitPaths<'a>(&'a Void); - -pub fn split_paths(_unparsed: &OsStr) -> SplitPaths<'_> { - panic!("unsupported") -} - -impl<'a> Iterator for SplitPaths<'a> { - type Item = PathBuf; - fn next(&mut self) -> Option { - match *self.0 {} - } -} - -#[derive(Debug)] -pub struct JoinPathsError; - -pub fn join_paths(_paths: I) -> Result -where - I: Iterator, - T: AsRef, -{ - Err(JoinPathsError) -} - -impl fmt::Display for JoinPathsError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - "not supported on CloudABI yet".fmt(f) - } -} - -impl StdError for JoinPathsError { - #[allow(deprecated)] - fn description(&self) -> &str { - "not supported on CloudABI yet" - } -} - -pub fn home_dir() -> Option { - None -} - -pub fn temp_dir() -> PathBuf { - PathBuf::from("/tmp") -} - -pub fn current_exe() -> io::Result { - unsupported() -} - -pub fn getpid() -> u32 { - 1 -} diff --git a/library/std/src/sys/cloudabi/shims/pipe.rs b/library/std/src/sys/cloudabi/shims/pipe.rs deleted file mode 100644 index 10d0925823e..00000000000 --- a/library/std/src/sys/cloudabi/shims/pipe.rs +++ /dev/null @@ -1,38 +0,0 @@ -use crate::io::{self, IoSlice, IoSliceMut}; -use crate::sys::Void; - -pub struct AnonPipe(Void); - -impl AnonPipe { - pub fn read(&self, _buf: &mut [u8]) -> io::Result { - match self.0 {} - } - - pub fn read_vectored(&self, _bufs: &mut [IoSliceMut<'_>]) -> io::Result { - match self.0 {} - } - - pub fn is_read_vectored(&self) -> bool { - match self.0 {} - } - - pub fn write(&self, _buf: &[u8]) -> io::Result { - match self.0 {} - } - - pub fn write_vectored(&self, _bufs: &[IoSlice<'_>]) -> io::Result { - match self.0 {} - } - - pub fn is_write_vectored(&self) -> bool { - match self.0 {} - } - - pub fn diverge(&self) -> ! { - match self.0 {} - } -} - -pub fn read2(p1: AnonPipe, _v1: &mut Vec, _p2: AnonPipe, _v2: &mut Vec) -> io::Result<()> { - match p1.0 {} -} diff --git a/library/std/src/sys/cloudabi/shims/process.rs b/library/std/src/sys/cloudabi/shims/process.rs deleted file mode 100644 index 4702e5c5492..00000000000 --- a/library/std/src/sys/cloudabi/shims/process.rs +++ /dev/null @@ -1,149 +0,0 @@ -use crate::ffi::OsStr; -use crate::fmt; -use crate::io; -use crate::sys::fs::File; -use crate::sys::pipe::AnonPipe; -use crate::sys::{unsupported, Void}; -use crate::sys_common::process::CommandEnv; - -pub use crate::ffi::OsString as EnvKey; - -//////////////////////////////////////////////////////////////////////////////// -// Command -//////////////////////////////////////////////////////////////////////////////// - -pub struct Command { - env: CommandEnv, -} - -// passed back to std::process with the pipes connected to the child, if any -// were requested -pub struct StdioPipes { - pub stdin: Option, - pub stdout: Option, - pub stderr: Option, -} - -pub enum Stdio { - Inherit, - Null, - MakePipe, -} - -impl Command { - pub fn new(_program: &OsStr) -> Command { - Command { env: Default::default() } - } - - pub fn arg(&mut self, _arg: &OsStr) {} - - pub fn env_mut(&mut self) -> &mut CommandEnv { - &mut self.env - } - - pub fn cwd(&mut self, _dir: &OsStr) {} - - pub fn stdin(&mut self, _stdin: Stdio) {} - - pub fn stdout(&mut self, _stdout: Stdio) {} - - pub fn stderr(&mut self, _stderr: Stdio) {} - - pub fn spawn( - &mut self, - _default: Stdio, - _needs_stdin: bool, - ) -> io::Result<(Process, StdioPipes)> { - unsupported() - } -} - -impl From for Stdio { - fn from(pipe: AnonPipe) -> Stdio { - pipe.diverge() - } -} - -impl From for Stdio { - fn from(file: File) -> Stdio { - file.diverge() - } -} - -impl fmt::Debug for Command { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - Ok(()) - } -} - -pub struct ExitStatus(Void); - -impl ExitStatus { - pub fn success(&self) -> bool { - match self.0 {} - } - - pub fn code(&self) -> Option { - match self.0 {} - } -} - -impl Clone for ExitStatus { - fn clone(&self) -> ExitStatus { - match self.0 {} - } -} - -impl Copy for ExitStatus {} - -impl PartialEq for ExitStatus { - fn eq(&self, _other: &ExitStatus) -> bool { - match self.0 {} - } -} - -impl Eq for ExitStatus {} - -impl fmt::Debug for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -impl fmt::Display for ExitStatus { - fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { - match self.0 {} - } -} - -#[derive(PartialEq, Eq, Clone, Copy, Debug)] -pub struct ExitCode(bool); - -impl ExitCode { - pub const SUCCESS: ExitCode = ExitCode(false); - pub const FAILURE: ExitCode = ExitCode(true); - - pub fn as_i32(&self) -> i32 { - self.0 as i32 - } -} - -pub struct Process(Void); - -impl Process { - pub fn id(&self) -> u32 { - match self.0 {} - } - - pub fn kill(&mut self) -> io::Result<()> { - match self.0 {} - } - - pub fn wait(&mut self) -> io::Result { - match self.0 {} - } - - pub fn try_wait(&mut self) -> io::Result> { - match self.0 {} - } -} diff --git a/library/std/src/sys/cloudabi/stack_overflow.rs b/library/std/src/sys/cloudabi/stack_overflow.rs deleted file mode 100644 index 9339b143731..00000000000 --- a/library/std/src/sys/cloudabi/stack_overflow.rs +++ /dev/null @@ -1,5 +0,0 @@ -#![cfg_attr(test, allow(dead_code))] - -pub unsafe fn init() {} - -pub unsafe fn cleanup() {} diff --git a/library/std/src/sys/cloudabi/stdio.rs b/library/std/src/sys/cloudabi/stdio.rs deleted file mode 100644 index 7fec4731a46..00000000000 --- a/library/std/src/sys/cloudabi/stdio.rs +++ /dev/null @@ -1,66 +0,0 @@ -use crate::io; -use crate::sys::cloudabi::abi; - -pub struct Stdin(()); -pub struct Stdout(()); -pub struct Stderr(()); - -impl Stdin { - pub const fn new() -> Stdin { - Stdin(()) - } -} - -impl io::Read for Stdin { - fn read(&mut self, _buf: &mut [u8]) -> io::Result { - Ok(0) - } -} - -impl Stdout { - pub const fn new() -> Stdout { - Stdout(()) - } -} - -impl io::Write for Stdout { - fn write(&mut self, _buf: &[u8]) -> io::Result { - Err(io::Error::new( - io::ErrorKind::BrokenPipe, - "Stdout is not connected to any output in this environment", - )) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -impl Stderr { - pub const fn new() -> Stderr { - Stderr(()) - } -} - -impl io::Write for Stderr { - fn write(&mut self, _buf: &[u8]) -> io::Result { - Err(io::Error::new( - io::ErrorKind::BrokenPipe, - "Stderr is not connected to any output in this environment", - )) - } - - fn flush(&mut self) -> io::Result<()> { - Ok(()) - } -} - -pub fn is_ebadf(err: &io::Error) -> bool { - err.raw_os_error() == Some(abi::errno::BADF as i32) -} - -pub const STDIN_BUF_SIZE: usize = crate::sys_common::io::DEFAULT_BUF_SIZE; - -pub fn panic_output() -> Option { - Some(Stderr::new()) -} diff --git a/library/std/src/sys/cloudabi/thread.rs b/library/std/src/sys/cloudabi/thread.rs deleted file mode 100644 index a15dc8653e8..00000000000 --- a/library/std/src/sys/cloudabi/thread.rs +++ /dev/null @@ -1,118 +0,0 @@ -use crate::cmp; -use crate::ffi::CStr; -use crate::io; -use crate::mem; -use crate::ptr; -use crate::sys::cloudabi::abi; -use crate::sys::time::checked_dur2intervals; -use crate::time::Duration; - -pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024; - -pub struct Thread { - id: libc::pthread_t, -} - -// CloudABI has pthread_t as a pointer in which case we still want -// a thread to be Send/Sync -unsafe impl Send for Thread {} -unsafe impl Sync for Thread {} - -impl Thread { - // unsafe: see thread::Builder::spawn_unchecked for safety requirements - pub unsafe fn new(stack: usize, p: Box) -> io::Result { - let p = Box::into_raw(box p); - let mut native: libc::pthread_t = mem::zeroed(); - let mut attr: libc::pthread_attr_t = mem::zeroed(); - assert_eq!(libc::pthread_attr_init(&mut attr), 0); - - let stack_size = cmp::max(stack, min_stack_size(&attr)); - assert_eq!(libc::pthread_attr_setstacksize(&mut attr, stack_size), 0); - - let ret = libc::pthread_create(&mut native, &attr, thread_start, p as *mut _); - // Note: if the thread creation fails and this assert fails, then p will - // be leaked. However, an alternative design could cause double-free - // which is clearly worse. - assert_eq!(libc::pthread_attr_destroy(&mut attr), 0); - - return if ret != 0 { - // The thread failed to start and as a result p was not consumed. Therefore, it is - // safe to reconstruct the box so that it gets deallocated. - drop(Box::from_raw(p)); - Err(io::Error::from_raw_os_error(ret)) - } else { - Ok(Thread { id: native }) - }; - - extern "C" fn thread_start(main: *mut libc::c_void) -> *mut libc::c_void { - unsafe { - // Let's run some code. - Box::from_raw(main as *mut Box)(); - } - ptr::null_mut() - } - } - - pub fn yield_now() { - let ret = unsafe { abi::thread_yield() }; - debug_assert_eq!(ret, abi::errno::SUCCESS); - } - - pub fn set_name(_name: &CStr) { - // CloudABI has no way to set a thread name. - } - - pub fn sleep(dur: Duration) { - let timeout = - checked_dur2intervals(&dur).expect("overflow converting duration to nanoseconds"); - unsafe { - let subscription = abi::subscription { - type_: abi::eventtype::CLOCK, - union: abi::subscription_union { - clock: abi::subscription_clock { - clock_id: abi::clockid::MONOTONIC, - timeout, - ..mem::zeroed() - }, - }, - ..mem::zeroed() - }; - let mut event = mem::MaybeUninit::::uninit(); - let mut nevents = mem::MaybeUninit::::uninit(); - let ret = abi::poll(&subscription, event.as_mut_ptr(), 1, nevents.as_mut_ptr()); - assert_eq!(ret, abi::errno::SUCCESS); - let event = event.assume_init(); - assert_eq!(event.error, abi::errno::SUCCESS); - } - } - - pub fn join(self) { - unsafe { - let ret = libc::pthread_join(self.id, ptr::null_mut()); - mem::forget(self); - assert!(ret == 0, "failed to join thread: {}", io::Error::from_raw_os_error(ret)); - } - } -} - -impl Drop for Thread { - fn drop(&mut self) { - let ret = unsafe { libc::pthread_detach(self.id) }; - debug_assert_eq!(ret, 0); - } -} - -#[cfg_attr(test, allow(dead_code))] -pub mod guard { - pub type Guard = !; - pub unsafe fn current() -> Option { - None - } - pub unsafe fn init() -> Option { - None - } -} - -fn min_stack_size(_: *const libc::pthread_attr_t) -> usize { - libc::PTHREAD_STACK_MIN -} diff --git a/library/std/src/sys/cloudabi/time.rs b/library/std/src/sys/cloudabi/time.rs deleted file mode 100644 index c209231cf8c..00000000000 --- a/library/std/src/sys/cloudabi/time.rs +++ /dev/null @@ -1,82 +0,0 @@ -use crate::mem; -use crate::sys::cloudabi::abi; -use crate::time::Duration; - -const NSEC_PER_SEC: abi::timestamp = 1_000_000_000; - -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct Instant { - t: abi::timestamp, -} - -pub fn checked_dur2intervals(dur: &Duration) -> Option { - dur.as_secs().checked_mul(NSEC_PER_SEC)?.checked_add(dur.subsec_nanos() as abi::timestamp) -} - -impl Instant { - pub fn now() -> Instant { - unsafe { - let mut t: mem::MaybeUninit = mem::MaybeUninit::uninit(); - let ret = abi::clock_time_get(abi::clockid::MONOTONIC, 0, t.as_mut_ptr()); - assert_eq!(ret, abi::errno::SUCCESS); - Instant { t: t.assume_init() } - } - } - - pub fn actually_monotonic() -> bool { - true - } - - pub const fn zero() -> Instant { - Instant { t: 0 } - } - - pub fn checked_sub_instant(&self, other: &Instant) -> Option { - let diff = self.t.checked_sub(other.t)?; - Some(Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32)) - } - - pub fn checked_add_duration(&self, other: &Duration) -> Option { - Some(Instant { t: self.t.checked_add(checked_dur2intervals(other)?)? }) - } - - pub fn checked_sub_duration(&self, other: &Duration) -> Option { - Some(Instant { t: self.t.checked_sub(checked_dur2intervals(other)?)? }) - } -} - -#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)] -pub struct SystemTime { - t: abi::timestamp, -} - -impl SystemTime { - pub fn now() -> SystemTime { - unsafe { - let mut t: mem::MaybeUninit = mem::MaybeUninit::uninit(); - let ret = abi::clock_time_get(abi::clockid::REALTIME, 0, t.as_mut_ptr()); - assert_eq!(ret, abi::errno::SUCCESS); - SystemTime { t: t.assume_init() } - } - } - - pub fn sub_time(&self, other: &SystemTime) -> Result { - if self.t >= other.t { - let diff = self.t - other.t; - Ok(Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32)) - } else { - let diff = other.t - self.t; - Err(Duration::new(diff / NSEC_PER_SEC, (diff % NSEC_PER_SEC) as u32)) - } - } - - pub fn checked_add_duration(&self, other: &Duration) -> Option { - Some(SystemTime { t: self.t.checked_add(checked_dur2intervals(other)?)? }) - } - - pub fn checked_sub_duration(&self, other: &Duration) -> Option { - Some(SystemTime { t: self.t.checked_sub(checked_dur2intervals(other)?)? }) - } -} - -pub const UNIX_EPOCH: SystemTime = SystemTime { t: 0 }; diff --git a/library/std/src/sys/mod.rs b/library/std/src/sys/mod.rs index b4628b64911..d48d9cb0efc 100644 --- a/library/std/src/sys/mod.rs +++ b/library/std/src/sys/mod.rs @@ -32,9 +32,6 @@ cfg_if::cfg_if! { } else if #[cfg(windows)] { mod windows; pub use self::windows::*; - } else if #[cfg(target_os = "cloudabi")] { - mod cloudabi; - pub use self::cloudabi::*; } else if #[cfg(target_os = "hermit")] { mod hermit; pub use self::hermit::*; @@ -63,11 +60,10 @@ cfg_if::cfg_if! { // On unix we'll document what's already available #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as unix_ext; - } else if #[cfg(any(target_os = "cloudabi", - target_os = "hermit", + } else if #[cfg(any(target_os = "hermit", target_arch = "wasm32", all(target_vendor = "fortanix", target_env = "sgx")))] { - // On CloudABI and wasm right now the module below doesn't compile + // On wasm right now the module below doesn't compile // (missing things in `libc` which is empty) so just omit everything // with an empty module #[unstable(issue = "none", feature = "std_internals")] @@ -88,11 +84,10 @@ cfg_if::cfg_if! { #[allow(missing_docs)] #[stable(feature = "rust1", since = "1.0.0")] pub use self::ext as windows_ext; - } else if #[cfg(any(target_os = "cloudabi", - target_os = "hermit", + } else if #[cfg(any(target_os = "hermit", target_arch = "wasm32", all(target_vendor = "fortanix", target_env = "sgx")))] { - // On CloudABI and wasm right now the shim below doesn't compile, so + // On wasm right now the shim below doesn't compile, so // just omit it #[unstable(issue = "none", feature = "std_internals")] #[allow(missing_docs)] diff --git a/library/std/src/sys_common/mod.rs b/library/std/src/sys_common/mod.rs index 234b257aa92..660f0e0df97 100644 --- a/library/std/src/sys_common/mod.rs +++ b/library/std/src/sys_common/mod.rs @@ -71,8 +71,7 @@ pub mod util; pub mod wtf8; cfg_if::cfg_if! { - if #[cfg(any(target_os = "cloudabi", - target_os = "l4re", + if #[cfg(any(target_os = "l4re", target_os = "hermit", feature = "restricted-std", all(target_arch = "wasm32", not(target_os = "emscripten")), diff --git a/library/std/src/thread/available_concurrency.rs b/library/std/src/thread/available_concurrency.rs index 4e805e4f599..64a5f89890a 100644 --- a/library/std/src/thread/available_concurrency.rs +++ b/library/std/src/thread/available_concurrency.rs @@ -70,7 +70,6 @@ cfg_if::cfg_if! { } } else if #[cfg(any( target_os = "android", - target_os = "cloudabi", target_os = "emscripten", target_os = "fuchsia", target_os = "ios", diff --git a/library/std/src/time.rs b/library/std/src/time.rs index e433f69a8b0..89addae0789 100644 --- a/library/std/src/time.rs +++ b/library/std/src/time.rs @@ -83,7 +83,6 @@ pub use core::time::Duration; /// /// | Platform | System call | /// |:---------:|:--------------------------------------------------------------------:| -/// | CloudABI | [clock_time_get (Monotonic Clock)] | /// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX | [clock_gettime (Monotonic Clock)] | /// | Darwin | [mach_absolute_time] | @@ -97,7 +96,6 @@ pub use core::time::Duration; /// [__wasi_clock_time_get (Monotonic Clock)]: https://github.com/WebAssembly/WASI/blob/master/phases/snapshot/docs.md#clock_time_get /// [clock_gettime (Monotonic Clock)]: https://linux.die.net/man/3/clock_gettime /// [mach_absolute_time]: https://developer.apple.com/library/archive/documentation/Darwin/Conceptual/KernelProgramming/services/services.html -/// [clock_time_get (Monotonic Clock)]: https://nuxi.nl/cloudabi/#clock_time_get /// /// **Disclaimer:** These system calls might change over time. /// @@ -161,7 +159,6 @@ pub struct Instant(time::Instant); /// /// | Platform | System call | /// |:---------:|:--------------------------------------------------------------------:| -/// | CloudABI | [clock_time_get (Realtime Clock)] | /// | SGX | [`insecure_time` usercall]. More information on [timekeeping in SGX] | /// | UNIX | [clock_gettime (Realtime Clock)] | /// | Darwin | [gettimeofday] | @@ -169,7 +166,6 @@ pub struct Instant(time::Instant); /// | WASI | [__wasi_clock_time_get (Realtime Clock)] | /// | Windows | [GetSystemTimePreciseAsFileTime] / [GetSystemTimeAsFileTime] | /// -/// [clock_time_get (Realtime Clock)]: https://nuxi.nl/cloudabi/#clock_time_get /// [`insecure_time` usercall]: https://edp.fortanix.com/docs/api/fortanix_sgx_abi/struct.Usercalls.html#method.insecure_time /// [timekeeping in SGX]: https://edp.fortanix.com/docs/concepts/rust-std/#codestdtimecode /// [gettimeofday]: http://man7.org/linux/man-pages/man2/gettimeofday.2.html diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 816b4d51188..e48ca892122 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -20,7 +20,7 @@ #![crate_name = "test"] #![unstable(feature = "test", issue = "50297")] #![doc(html_root_url = "https://doc.rust-lang.org/nightly/", test(attr(deny(warnings))))] -#![cfg_attr(any(unix, target_os = "cloudabi"), feature(libc))] +#![cfg_attr(unix, feature(libc))] #![feature(rustc_private)] #![feature(nll)] #![feature(bool_to_option)] diff --git a/library/unwind/build.rs b/library/unwind/build.rs index 24bcd40c3a8..fae760c4a4e 100644 --- a/library/unwind/build.rs +++ b/library/unwind/build.rs @@ -44,8 +44,6 @@ fn main() { println!("cargo:rustc-link-lib=gcc_s"); } else if target.contains("redox") { // redox is handled in lib.rs - } else if target.contains("cloudabi") { - println!("cargo:rustc-link-lib=unwind"); } } diff --git a/library/unwind/src/lib.rs b/library/unwind/src/lib.rs index dbdefa471a9..d145c6767ec 100644 --- a/library/unwind/src/lib.rs +++ b/library/unwind/src/lib.rs @@ -20,7 +20,6 @@ cfg_if::cfg_if! { unix, windows, target_os = "psp", - target_os = "cloudabi", all(target_vendor = "fortanix", target_env = "sgx"), ))] { mod libunwind; diff --git a/rustfmt.toml b/rustfmt.toml index 2b1c516cf77..45cce186c09 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -32,7 +32,4 @@ ignore = [ "src/tools/rust-analyzer", "src/tools/rustfmt", "src/tools/rust-installer", - - # We do not format this file as it is externally sourced and auto-generated. - "library/std/src/sys/cloudabi/abi/cloudabi.rs", ] diff --git a/src/ci/docker/host-x86_64/dist-various-2/build-cloudabi-toolchain.sh b/src/ci/docker/host-x86_64/dist-various-2/build-cloudabi-toolchain.sh deleted file mode 100755 index b7ff6cd4e4f..00000000000 --- a/src/ci/docker/host-x86_64/dist-various-2/build-cloudabi-toolchain.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -set -eux - -# Install prerequisites. -apt-get update -apt-get install -y --no-install-recommends \ - apt-transport-https \ - ca-certificates \ - clang-5.0 \ - cmake \ - curl \ - file \ - g++ \ - gdb \ - git \ - lld-5.0 \ - make \ - ninja-build \ - python \ - sudo \ - xz-utils - -# Set up a Clang-based cross compiler toolchain. -# Based on the steps described at https://nuxi.nl/cloudabi/debian/ -target=$1 -for tool in ar nm objdump ranlib size; do - ln -s ../lib/llvm-5.0/bin/llvm-${tool} /usr/bin/${target}-${tool} -done -ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-cc -ln -s ../lib/llvm-5.0/bin/clang /usr/bin/${target}-c++ -ln -s ../lib/llvm-5.0/bin/lld /usr/bin/${target}-ld -ln -s ../../${target} /usr/lib/llvm-5.0/${target} - -# Install the C++ runtime libraries from CloudABI Ports. -apt-key adv --batch --yes --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0DA51B8531344B15 -add-apt-repository -y 'deb https://nuxi.nl/distfiles/cloudabi-ports/debian/ cloudabi cloudabi' - -apt-get update -apt-get install -y "${target//_/-}-cxx-runtime" diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 215e5d3d104..8eb4821396d 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -153,7 +153,6 @@ not available. target | std | host | notes -------|-----|------|------- `aarch64-apple-tvos` | * | | ARM64 tvOS -`aarch64-unknown-cloudabi` | ✓ | | ARM64 CloudABI `aarch64-unknown-freebsd` | ✓ | ✓ | ARM64 FreeBSD `aarch64-unknown-hermit` | ? | | `aarch64-unknown-netbsd` | ? | | @@ -165,7 +164,6 @@ target | std | host | notes `armv6-unknown-freebsd` | ✓ | ✓ | ARMv6 FreeBSD `armv6-unknown-netbsd-eabihf` | ? | | `armv7-apple-ios` | ✓ | | ARMv7 iOS, Cortex-a8 -`armv7-unknown-cloudabi-eabihf` | ✓ | | ARMv7 CloudABI, hardfloat `armv7-unknown-freebsd` | ✓ | ✓ | ARMv7 FreeBSD `armv7-unknown-netbsd-eabihf` | ? | | `armv7-wrs-vxworks-eabihf` | ? | | @@ -176,7 +174,6 @@ target | std | host | notes `i386-apple-ios` | ✓ | | 32-bit x86 iOS `i686-apple-darwin` | ✓ | ✓ | 32-bit macOS (10.7+, Lion+) `i686-pc-windows-msvc` | ✓ | | 32-bit Windows XP support -`i686-unknown-cloudabi` | ✓ | | 32-bit CloudABI `i686-unknown-uefi` | ? | | 32-bit UEFI `i686-unknown-haiku` | ✓ | ✓ | 32-bit Haiku `i686-unknown-netbsd` | ✓ | | NetBSD/i386 with SSE2 @@ -215,7 +212,6 @@ target | std | host | notes `x86_64-linux-kernel` | * | | Linux kernel modules `x86_64-pc-solaris` | ? | | `x86_64-pc-windows-msvc` | ✓ | | 64-bit Windows XP support -`x86_64-unknown-cloudabi` | ✓ | | 64-bit CloudABI `x86_64-unknown-dragonfly` | ✓ | ✓ | 64-bit DragonFlyBSD `x86_64-unknown-haiku` | ✓ | ✓ | 64-bit Haiku `x86_64-unknown-hermit` | ? | | diff --git a/src/test/codegen/dllimports/main.rs b/src/test/codegen/dllimports/main.rs index 73631b92c1f..bb3134e81c9 100644 --- a/src/test/codegen/dllimports/main.rs +++ b/src/test/codegen/dllimports/main.rs @@ -1,6 +1,5 @@ // This test is for *-windows-msvc only. // ignore-android -// ignore-cloudabi // ignore-dragonfly // ignore-emscripten // ignore-freebsd diff --git a/src/test/codegen/panic-abort-windows.rs b/src/test/codegen/panic-abort-windows.rs index 8e38245267d..9ee4bfc4711 100644 --- a/src/test/codegen/panic-abort-windows.rs +++ b/src/test/codegen/panic-abort-windows.rs @@ -1,6 +1,5 @@ // This test is for *-windows-msvc only. // ignore-android -// ignore-cloudabi // ignore-dragonfly // ignore-emscripten // ignore-freebsd diff --git a/src/test/run-pass-valgrind/exit-flushes.rs b/src/test/run-pass-valgrind/exit-flushes.rs index a68c6f33556..9daf487d39f 100644 --- a/src/test/run-pass-valgrind/exit-flushes.rs +++ b/src/test/run-pass-valgrind/exit-flushes.rs @@ -1,4 +1,3 @@ -// ignore-cloudabi // ignore-emscripten // ignore-sgx no processes // ignore-macos this needs valgrind 3.11 or higher; see diff --git a/src/test/ui/abi/segfault-no-out-of-stack.rs b/src/test/ui/abi/segfault-no-out-of-stack.rs index 626de4ed5b6..0128e5e636d 100644 --- a/src/test/ui/abi/segfault-no-out-of-stack.rs +++ b/src/test/ui/abi/segfault-no-out-of-stack.rs @@ -1,7 +1,6 @@ // run-pass #![allow(unused_imports)] -// ignore-cloudabi can't run commands // ignore-emscripten can't run commands // ignore-sgx no processes diff --git a/src/test/ui/abi/stack-probes-lto.rs b/src/test/ui/abi/stack-probes-lto.rs index 9018ff4bfc2..90df1f3f53e 100644 --- a/src/test/ui/abi/stack-probes-lto.rs +++ b/src/test/ui/abi/stack-probes-lto.rs @@ -8,7 +8,6 @@ // ignore-sparc // ignore-sparc64 // ignore-wasm -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-musl FIXME #31506 diff --git a/src/test/ui/abi/stack-probes.rs b/src/test/ui/abi/stack-probes.rs index a52c285f9f0..6c83e01d4cd 100644 --- a/src/test/ui/abi/stack-probes.rs +++ b/src/test/ui/abi/stack-probes.rs @@ -8,7 +8,6 @@ // ignore-sparc // ignore-sparc64 // ignore-wasm -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs b/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs index f09fafbc98a..4d40c7d0d22 100644 --- a/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs +++ b/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android no libc -// ignore-cloudabi no libc // ignore-emscripten no libc // ignore-sgx no libc // ignore-wasm32 no libc diff --git a/src/test/ui/allocator/no_std-alloc-error-handler-default.rs b/src/test/ui/allocator/no_std-alloc-error-handler-default.rs index 4d68160379d..4f8c44f1763 100644 --- a/src/test/ui/allocator/no_std-alloc-error-handler-default.rs +++ b/src/test/ui/allocator/no_std-alloc-error-handler-default.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android no libc -// ignore-cloudabi no libc // ignore-emscripten no libc // ignore-sgx no libc // ignore-wasm32 no libc diff --git a/src/test/ui/atomic-print.rs b/src/test/ui/atomic-print.rs index ef3453da689..fe57910530f 100644 --- a/src/test/ui/atomic-print.rs +++ b/src/test/ui/atomic-print.rs @@ -2,7 +2,6 @@ #![allow(unused_must_use)] #![allow(deprecated)] -// ignore-cloudabi no process support // ignore-emscripten no threads support // ignore-sgx no processes diff --git a/src/test/ui/backtrace-debuginfo.rs b/src/test/ui/backtrace-debuginfo.rs index 0f31842b3b7..4862883fd96 100644 --- a/src/test/ui/backtrace-debuginfo.rs +++ b/src/test/ui/backtrace-debuginfo.rs @@ -9,7 +9,6 @@ // compile-flags:-g -Cllvm-args=-enable-tail-merge=0 -Cllvm-args=-opt-bisect-limit=0 // compile-flags:-Cforce-frame-pointers=yes // ignore-pretty issue #37195 -// ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported // ignore-sgx no processes // normalize-stderr-test ".*\n" -> "" diff --git a/src/test/ui/backtrace.rs b/src/test/ui/backtrace.rs index 234a7f801c0..a7d17c43f05 100644 --- a/src/test/ui/backtrace.rs +++ b/src/test/ui/backtrace.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android FIXME #17520 -// ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported // ignore-openbsd no support for libbacktrace without filename // ignore-sgx no processes diff --git a/src/test/ui/cfg/cfg-family.rs b/src/test/ui/cfg/cfg-family.rs index 9fb7c766921..912bda4b5e5 100644 --- a/src/test/ui/cfg/cfg-family.rs +++ b/src/test/ui/cfg/cfg-family.rs @@ -1,6 +1,5 @@ // run-pass // pretty-expanded FIXME #23616 -// ignore-cloudabi no target_family // ignore-wasm32-bare no target_family // ignore-sgx diff --git a/src/test/ui/cfg/cfg-target-family.rs b/src/test/ui/cfg/cfg-target-family.rs index ecf802f7281..b4dc1b73863 100644 --- a/src/test/ui/cfg/cfg-target-family.rs +++ b/src/test/ui/cfg/cfg-target-family.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no target_family // ignore-wasm32-bare no target_family // ignore-sgx diff --git a/src/test/ui/cleanup-shortcircuit.rs b/src/test/ui/cleanup-shortcircuit.rs index 19d774079ab..4f5197a5ba9 100644 --- a/src/test/ui/cleanup-shortcircuit.rs +++ b/src/test/ui/cleanup-shortcircuit.rs @@ -2,7 +2,6 @@ // Test that cleanups for the RHS of shortcircuiting operators work. // pretty-expanded FIXME #23616 -// ignore-cloudabi no std::env support use std::env; diff --git a/src/test/ui/command/command-argv0-debug.rs b/src/test/ui/command/command-argv0-debug.rs index cb948a91c10..4aba1229f29 100644 --- a/src/test/ui/command/command-argv0-debug.rs +++ b/src/test/ui/command/command-argv0-debug.rs @@ -1,7 +1,6 @@ // run-pass // ignore-windows - this is a unix-specific test -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes use std::os::unix::process::CommandExt; diff --git a/src/test/ui/command/command-argv0.rs b/src/test/ui/command/command-argv0.rs index e3394e0567c..b782a4fd3d1 100644 --- a/src/test/ui/command/command-argv0.rs +++ b/src/test/ui/command/command-argv0.rs @@ -1,7 +1,6 @@ // run-pass // ignore-windows - this is a unix-specific test -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes use std::env; diff --git a/src/test/ui/command/command-exec.rs b/src/test/ui/command/command-exec.rs index 568be67abe3..0af87214f95 100644 --- a/src/test/ui/command/command-exec.rs +++ b/src/test/ui/command/command-exec.rs @@ -3,7 +3,6 @@ #![allow(stable_features)] // ignore-windows - this is a unix-specific test // ignore-pretty issue #37199 -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/command/command-pre-exec.rs b/src/test/ui/command/command-pre-exec.rs index c0fc554183a..8fc6a220331 100644 --- a/src/test/ui/command/command-pre-exec.rs +++ b/src/test/ui/command/command-pre-exec.rs @@ -2,7 +2,6 @@ #![allow(stable_features)] // ignore-windows - this is a unix-specific test -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes #![feature(process_exec, rustc_private)] diff --git a/src/test/ui/command/command-uid-gid.rs b/src/test/ui/command/command-uid-gid.rs index f867106c35d..e1eb4b1405b 100644 --- a/src/test/ui/command/command-uid-gid.rs +++ b/src/test/ui/command/command-uid-gid.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android -// ignore-cloudabi // ignore-emscripten // ignore-sgx diff --git a/src/test/ui/core-run-destroy.rs b/src/test/ui/core-run-destroy.rs index b3614bfd5b6..5fd418e6c86 100644 --- a/src/test/ui/core-run-destroy.rs +++ b/src/test/ui/core-run-destroy.rs @@ -5,7 +5,6 @@ #![allow(deprecated)] #![allow(unused_imports)] // compile-flags:--test -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-vxworks no 'cat' and 'sleep' diff --git a/src/test/ui/default-alloc-error-hook.rs b/src/test/ui/default-alloc-error-hook.rs index 6871977c798..100e974977c 100644 --- a/src/test/ui/default-alloc-error-hook.rs +++ b/src/test/ui/default-alloc-error-hook.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/env-args-reverse-iterator.rs b/src/test/ui/env-args-reverse-iterator.rs index 0ffd74f87ab..7f06718c038 100644 --- a/src/test/ui/env-args-reverse-iterator.rs +++ b/src/test/ui/env-args-reverse-iterator.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/env-funky-keys.rs b/src/test/ui/env-funky-keys.rs index c5c824ac58d..4548d333947 100644 --- a/src/test/ui/env-funky-keys.rs +++ b/src/test/ui/env-funky-keys.rs @@ -3,7 +3,6 @@ // ignore-android // ignore-windows -// ignore-cloudabi no execve // ignore-emscripten no execve // ignore-sgx no execve // ignore-vxworks no execve diff --git a/src/test/ui/env-home-dir.rs b/src/test/ui/env-home-dir.rs index a75be48fd55..c597b4732d1 100644 --- a/src/test/ui/env-home-dir.rs +++ b/src/test/ui/env-home-dir.rs @@ -2,7 +2,6 @@ #![allow(unused_variables)] #![allow(deprecated)] -// ignore-cloudabi no environment variables present // ignore-emscripten env vars don't work? // ignore-sgx env vars cannot be modified diff --git a/src/test/ui/env-vars.rs b/src/test/ui/env-vars.rs index 2ea906788e8..f73902c4006 100644 --- a/src/test/ui/env-vars.rs +++ b/src/test/ui/env-vars.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no env vars // ignore-wasm32-bare no env vars use std::env::*; diff --git a/src/test/ui/error-codes/E0277.rs b/src/test/ui/error-codes/E0277.rs index e60d83098b9..f0de4e3deb1 100644 --- a/src/test/ui/error-codes/E0277.rs +++ b/src/test/ui/error-codes/E0277.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::path - use std::path::Path; trait Foo { diff --git a/src/test/ui/error-codes/E0277.stderr b/src/test/ui/error-codes/E0277.stderr index 647e0c7d76f..1f54af4d154 100644 --- a/src/test/ui/error-codes/E0277.stderr +++ b/src/test/ui/error-codes/E0277.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/E0277.rs:13:6 + --> $DIR/E0277.rs:11:6 | LL | fn f(p: Path) { } | ^ doesn't have a size known at compile-time @@ -13,7 +13,7 @@ LL | fn f(&p: Path) { } | ^ error[E0277]: the trait bound `i32: Foo` is not satisfied - --> $DIR/E0277.rs:17:15 + --> $DIR/E0277.rs:15:15 | LL | fn some_func(foo: T) { | --- required by this bound in `some_func` diff --git a/src/test/ui/exec-env.rs b/src/test/ui/exec-env.rs index 230fac10d33..d7f15bcae7d 100644 --- a/src/test/ui/exec-env.rs +++ b/src/test/ui/exec-env.rs @@ -1,6 +1,5 @@ // run-pass // exec-env:TEST_EXEC_ENV=22 -// ignore-cloudabi no env vars // ignore-emscripten FIXME: issue #31622 // ignore-sgx unsupported diff --git a/src/test/ui/fds-are-cloexec.rs b/src/test/ui/fds-are-cloexec.rs index 2010b5b6680..4482b7032a7 100644 --- a/src/test/ui/fds-are-cloexec.rs +++ b/src/test/ui/fds-are-cloexec.rs @@ -1,7 +1,6 @@ // run-pass // ignore-windows // ignore-android -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-haiku // ignore-sgx no processes diff --git a/src/test/ui/intrinsics/intrinsic-alignment.rs b/src/test/ui/intrinsics/intrinsic-alignment.rs index 896651361be..2bf40db5ad2 100644 --- a/src/test/ui/intrinsics/intrinsic-alignment.rs +++ b/src/test/ui/intrinsics/intrinsic-alignment.rs @@ -11,7 +11,6 @@ mod rusti { } #[cfg(any(target_os = "android", - target_os = "cloudabi", target_os = "dragonfly", target_os = "emscripten", target_os = "freebsd", diff --git a/src/test/ui/issues/issue-10626.rs b/src/test/ui/issues/issue-10626.rs index 78fa8b7c6fb..696a2dd1657 100644 --- a/src/test/ui/issues/issue-10626.rs +++ b/src/test/ui/issues/issue-10626.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-12133-3.rs b/src/test/ui/issues/issue-12133-3.rs index c8aa9bf4649..e6b16e2da1d 100644 --- a/src/test/ui/issues/issue-12133-3.rs +++ b/src/test/ui/issues/issue-12133-3.rs @@ -2,7 +2,6 @@ // aux-build:issue-12133-rlib.rs // aux-build:issue-12133-dylib.rs // aux-build:issue-12133-dylib2.rs -// ignore-cloudabi no dylib support // ignore-emscripten no dylib support // ignore-musl // ignore-sgx no dylib support diff --git a/src/test/ui/issues/issue-13304.rs b/src/test/ui/issues/issue-13304.rs index 5698536ab5d..b10f6d57255 100644 --- a/src/test/ui/issues/issue-13304.rs +++ b/src/test/ui/issues/issue-13304.rs @@ -1,6 +1,5 @@ // run-pass #![allow(unused_mut)] -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-14456.rs b/src/test/ui/issues/issue-14456.rs index 164d7ef8af2..52a56eb77f7 100644 --- a/src/test/ui/issues/issue-14456.rs +++ b/src/test/ui/issues/issue-14456.rs @@ -1,6 +1,5 @@ // run-pass #![allow(unused_mut)] -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-14940.rs b/src/test/ui/issues/issue-14940.rs index 785ad6a2c49..98a4af0c467 100644 --- a/src/test/ui/issues/issue-14940.rs +++ b/src/test/ui/issues/issue-14940.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-16272.rs b/src/test/ui/issues/issue-16272.rs index 3ba2483f430..5cf3fd94928 100644 --- a/src/test/ui/issues/issue-16272.rs +++ b/src/test/ui/issues/issue-16272.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-17121.rs b/src/test/ui/issues/issue-17121.rs index 34b1e2099be..1e7b9f015b9 100644 --- a/src/test/ui/issues/issue-17121.rs +++ b/src/test/ui/issues/issue-17121.rs @@ -1,7 +1,6 @@ // check-pass #![allow(dead_code)] // pretty-expanded FIXME #23616 -// ignore-cloudabi no std::fs use std::fs::File; use std::io::{self, BufReader, Read}; diff --git a/src/test/ui/issues/issue-20091.rs b/src/test/ui/issues/issue-20091.rs index 90db44fa02d..86cc79d6b42 100644 --- a/src/test/ui/issues/issue-20091.rs +++ b/src/test/ui/issues/issue-20091.rs @@ -1,7 +1,6 @@ // run-pass #![allow(stable_features)] -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-20644.rs b/src/test/ui/issues/issue-20644.rs index 36eac382496..71c6746e0e0 100644 --- a/src/test/ui/issues/issue-20644.rs +++ b/src/test/ui/issues/issue-20644.rs @@ -7,7 +7,6 @@ // had to do with codegen ignoring binders. // pretty-expanded FIXME #23616 -// ignore-cloudabi no std::fs #![feature(os)] diff --git a/src/test/ui/issues/issue-20797.rs b/src/test/ui/issues/issue-20797.rs index 5d82592e5ea..ef0e72571ef 100644 --- a/src/test/ui/issues/issue-20797.rs +++ b/src/test/ui/issues/issue-20797.rs @@ -1,5 +1,4 @@ // build-pass -// ignore-cloudabi no std::fs // Regression test for #20797. diff --git a/src/test/ui/issues/issue-2214.rs b/src/test/ui/issues/issue-2214.rs index 9b7c4485418..52ab29f4235 100644 --- a/src/test/ui/issues/issue-2214.rs +++ b/src/test/ui/issues/issue-2214.rs @@ -24,7 +24,7 @@ mod m { use libc::{c_double, c_int}; extern { - #[cfg(any(all(unix, not(target_os = "vxworks")), target_os = "cloudabi"))] + #[cfg(all(unix, not(target_os = "vxworks")))] #[link_name="lgamma_r"] pub fn lgamma(n: c_double, sign: &mut c_int) -> c_double; #[cfg(windows)] diff --git a/src/test/ui/issues/issue-22577.rs b/src/test/ui/issues/issue-22577.rs index 24f4f60aa2f..8aca21bf10f 100644 --- a/src/test/ui/issues/issue-22577.rs +++ b/src/test/ui/issues/issue-22577.rs @@ -1,7 +1,6 @@ // run-pass #![allow(dead_code)] // pretty-expanded FIXME #23616 -// ignore-cloudabi no std::fs use std::{fs, net}; diff --git a/src/test/ui/issues/issue-23036.rs b/src/test/ui/issues/issue-23036.rs index a307e7eed95..d67f184720e 100644 --- a/src/test/ui/issues/issue-23036.rs +++ b/src/test/ui/issues/issue-23036.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no std::path use std::collections::HashMap; use std::path::Path; diff --git a/src/test/ui/issues/issue-23649-2.rs b/src/test/ui/issues/issue-23649-2.rs index f5fb8b65020..ce7d8e3a755 100644 --- a/src/test/ui/issues/issue-23649-2.rs +++ b/src/test/ui/issues/issue-23649-2.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no std::path use std::collections::HashMap; use std::path::{Path, PathBuf}; diff --git a/src/test/ui/issues/issue-24313.rs b/src/test/ui/issues/issue-24313.rs index 2c420dc056f..c28b4ca9601 100644 --- a/src/test/ui/issues/issue-24313.rs +++ b/src/test/ui/issues/issue-24313.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no threads // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-27859.rs b/src/test/ui/issues/issue-27859.rs index 259d706fa2a..233670681f3 100644 --- a/src/test/ui/issues/issue-27859.rs +++ b/src/test/ui/issues/issue-27859.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no std::env // ignore-wasm32 issue 42629 #[inline(never)] diff --git a/src/test/ui/issues/issue-30490.rs b/src/test/ui/issues/issue-30490.rs index 76e72246887..47c17e362ae 100644 --- a/src/test/ui/issues/issue-30490.rs +++ b/src/test/ui/issues/issue-30490.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-33770.rs b/src/test/ui/issues/issue-33770.rs index 39ae009c996..f3c99015b6d 100644 --- a/src/test/ui/issues/issue-33770.rs +++ b/src/test/ui/issues/issue-33770.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-37665.rs b/src/test/ui/issues/issue-37665.rs index c20782a7eb4..81ff478aabc 100644 --- a/src/test/ui/issues/issue-37665.rs +++ b/src/test/ui/issues/issue-37665.rs @@ -1,5 +1,4 @@ // compile-flags: -Z unpretty=mir -// ignore-cloudabi no std::path use std::path::MAIN_SEPARATOR; diff --git a/src/test/ui/issues/issue-37665.stderr b/src/test/ui/issues/issue-37665.stderr index 1e191a620af..1e1f451b450 100644 --- a/src/test/ui/issues/issue-37665.stderr +++ b/src/test/ui/issues/issue-37665.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-37665.rs:10:17 + --> $DIR/issue-37665.rs:9:17 | LL | let x: () = 0; | -- ^ expected `()`, found integer diff --git a/src/test/ui/issues/issue-39175.rs b/src/test/ui/issues/issue-39175.rs index 3ba2a9d40be..3866e0651c3 100644 --- a/src/test/ui/issues/issue-39175.rs +++ b/src/test/ui/issues/issue-39175.rs @@ -4,7 +4,6 @@ // these platforms also. // ignore-windows -// ignore-cloudabi // ignore-emscripten // ignore-sgx no processes diff --git a/src/test/ui/issues/issue-39175.stderr b/src/test/ui/issues/issue-39175.stderr index dbb334e7b95..afceae82e68 100644 --- a/src/test/ui/issues/issue-39175.stderr +++ b/src/test/ui/issues/issue-39175.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `exec` found for mutable reference `&mut Command` in the current scope - --> $DIR/issue-39175.rs:15:39 + --> $DIR/issue-39175.rs:14:39 | LL | Command::new("echo").arg("hello").exec(); | ^^^^ method not found in `&mut Command` diff --git a/src/test/ui/issues/issue-4541.rs b/src/test/ui/issues/issue-4541.rs index 1f871fcf613..e7f26d02151 100644 --- a/src/test/ui/issues/issue-4541.rs +++ b/src/test/ui/issues/issue-4541.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no std::env fn parse_args() -> String { let args: Vec<_> = ::std::env::args().collect(); diff --git a/src/test/ui/issues/issue-4542.rs b/src/test/ui/issues/issue-4542.rs index 24752114e9f..2386561c39d 100644 --- a/src/test/ui/issues/issue-4542.rs +++ b/src/test/ui/issues/issue-4542.rs @@ -1,6 +1,5 @@ // run-pass // pretty-expanded FIXME #23616 -// ignore-cloudabi no std::env use std::env; diff --git a/src/test/ui/issues/issue-46576.rs b/src/test/ui/issues/issue-46576.rs index 821d2724bc3..15f458f3844 100644 --- a/src/test/ui/issues/issue-46576.rs +++ b/src/test/ui/issues/issue-46576.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::fs support - #![allow(dead_code)] #![deny(unused_imports)] diff --git a/src/test/ui/issues/issue-46576.stderr b/src/test/ui/issues/issue-46576.stderr index 1e5e730ee64..6f4d97068b3 100644 --- a/src/test/ui/issues/issue-46576.stderr +++ b/src/test/ui/issues/issue-46576.stderr @@ -1,11 +1,11 @@ error: unused import: `BufRead` - --> $DIR/issue-46576.rs:7:15 + --> $DIR/issue-46576.rs:5:15 | LL | use std::io::{BufRead, BufReader, Read}; | ^^^^^^^ | note: the lint level is defined here - --> $DIR/issue-46576.rs:4:9 + --> $DIR/issue-46576.rs:2:9 | LL | #![deny(unused_imports)] | ^^^^^^^^^^^^^^ diff --git a/src/test/ui/lint/use_suggestion_json.rs b/src/test/ui/lint/use_suggestion_json.rs index d7efa4aac65..7d641e08bf0 100644 --- a/src/test/ui/lint/use_suggestion_json.rs +++ b/src/test/ui/lint/use_suggestion_json.rs @@ -1,4 +1,3 @@ -// ignore-cloudabi // ignore-windows // ignore-sgx std::os::fortanix_sgx::usercalls::alloc::Iter changes compiler suggestions // compile-flags: --error-format pretty-json --json=diagnostic-rendered-ansi diff --git a/src/test/ui/lint/use_suggestion_json.stderr b/src/test/ui/lint/use_suggestion_json.stderr index d0d91bb61f4..21342e2ef37 100644 --- a/src/test/ui/lint/use_suggestion_json.stderr +++ b/src/test/ui/lint/use_suggestion_json.stderr @@ -72,10 +72,10 @@ mod foo { "spans": [ { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 560, - "byte_end": 564, - "line_start": 13, - "line_end": 13, + "byte_start": 541, + "byte_end": 545, + "line_start": 12, + "line_end": 12, "column_start": 12, "column_end": 16, "is_primary": true, @@ -100,10 +100,10 @@ mod foo { "spans": [ { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -123,10 +123,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -146,10 +146,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -169,10 +169,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -192,10 +192,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -215,10 +215,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -238,10 +238,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -261,10 +261,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -284,10 +284,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -307,10 +307,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -330,10 +330,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -353,10 +353,10 @@ mod foo { }, { "file_name": "$DIR/use_suggestion_json.rs", - "byte_start": 537, - "byte_end": 537, - "line_start": 12, - "line_end": 12, + "byte_start": 518, + "byte_end": 518, + "line_start": 11, + "line_end": 11, "column_start": 1, "column_end": 1, "is_primary": true, @@ -380,7 +380,7 @@ mod foo { } ], "rendered": "\u001b[0m\u001b[1m\u001b[38;5;9merror[E0412]\u001b[0m\u001b[0m\u001b[1m: cannot find type `Iter` in this scope\u001b[0m -\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m$DIR/use_suggestion_json.rs:13:12\u001b[0m +\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m--> \u001b[0m\u001b[0m$DIR/use_suggestion_json.rs:12:12\u001b[0m \u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m|\u001b[0m \u001b[0m\u001b[1m\u001b[38;5;12mLL\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m let x: Iter;\u001b[0m \u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;12m| \u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9m^^^^\u001b[0m\u001b[0m \u001b[0m\u001b[0m\u001b[1m\u001b[38;5;9mnot found in this scope\u001b[0m diff --git a/src/test/ui/mir/issue-77911.rs b/src/test/ui/mir/issue-77911.rs index b24faa6f885..fff303495e7 100644 --- a/src/test/ui/mir/issue-77911.rs +++ b/src/test/ui/mir/issue-77911.rs @@ -1,5 +1,4 @@ // compile-flags: -Z mir-opt-level=2 -// ignore-cloudabi no std::fs // build-pass use std::fs::File; diff --git a/src/test/ui/mir/mir_dynamic_drops_1.rs b/src/test/ui/mir/mir_dynamic_drops_1.rs index a77b2368d3b..2b33b616600 100644 --- a/src/test/ui/mir/mir_dynamic_drops_1.rs +++ b/src/test/ui/mir/mir_dynamic_drops_1.rs @@ -1,7 +1,6 @@ // run-fail // error-pattern:drop 1 // error-pattern:drop 2 -// ignore-cloudabi no std::process // ignore-emscripten no processes /// Structure which will not allow to be dropped twice. diff --git a/src/test/ui/mir/mir_dynamic_drops_2.rs b/src/test/ui/mir/mir_dynamic_drops_2.rs index 088a16d3387..c883efdabc3 100644 --- a/src/test/ui/mir/mir_dynamic_drops_2.rs +++ b/src/test/ui/mir/mir_dynamic_drops_2.rs @@ -1,6 +1,5 @@ // run-fail // error-pattern:drop 1 -// ignore-cloudabi no std::process // ignore-emscripten no processes /// Structure which will not allow to be dropped twice. diff --git a/src/test/ui/mir/mir_dynamic_drops_3.rs b/src/test/ui/mir/mir_dynamic_drops_3.rs index 029bdcd9a15..eb76fdff886 100644 --- a/src/test/ui/mir/mir_dynamic_drops_3.rs +++ b/src/test/ui/mir/mir_dynamic_drops_3.rs @@ -3,7 +3,6 @@ // error-pattern:drop 3 // error-pattern:drop 2 // error-pattern:drop 1 -// ignore-cloudabi no std::process // ignore-emscripten no processes /// Structure which will not allow to be dropped twice. diff --git a/src/test/ui/mismatched_types/recovered-block.rs b/src/test/ui/mismatched_types/recovered-block.rs index cb8ad8092dd..b230b47d35d 100644 --- a/src/test/ui/mismatched_types/recovered-block.rs +++ b/src/test/ui/mismatched_types/recovered-block.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::env support - use std::env; pub struct Foo { diff --git a/src/test/ui/mismatched_types/recovered-block.stderr b/src/test/ui/mismatched_types/recovered-block.stderr index 525d09b8fc1..f2b8404a328 100644 --- a/src/test/ui/mismatched_types/recovered-block.stderr +++ b/src/test/ui/mismatched_types/recovered-block.stderr @@ -1,5 +1,5 @@ error: missing `struct` for struct definition - --> $DIR/recovered-block.rs:13:8 + --> $DIR/recovered-block.rs:11:8 | LL | pub Foo { text } | ^ @@ -10,7 +10,7 @@ LL | pub struct Foo { text } | ^^^^^^ error: expected one of `(` or `<`, found `{` - --> $DIR/recovered-block.rs:19:9 + --> $DIR/recovered-block.rs:17:9 | LL | Foo { text: "".to_string() } | ^ expected one of `(` or `<` diff --git a/src/test/ui/multi-panic.rs b/src/test/ui/multi-panic.rs index 0f8bddf27fe..37e8b99c2f6 100644 --- a/src/test/ui/multi-panic.rs +++ b/src/test/ui/multi-panic.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/never_type/issue-13352.rs b/src/test/ui/never_type/issue-13352.rs index e6995be27d2..9c884a33c5f 100644 --- a/src/test/ui/never_type/issue-13352.rs +++ b/src/test/ui/never_type/issue-13352.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::process - fn foo(_: Box) {} fn main() { diff --git a/src/test/ui/never_type/issue-13352.stderr b/src/test/ui/never_type/issue-13352.stderr index 93c792a72ec..b98f6c93923 100644 --- a/src/test/ui/never_type/issue-13352.stderr +++ b/src/test/ui/never_type/issue-13352.stderr @@ -1,5 +1,5 @@ error[E0277]: cannot add `()` to `usize` - --> $DIR/issue-13352.rs:9:13 + --> $DIR/issue-13352.rs:7:13 | LL | 2_usize + (loop {}); | ^ no implementation for `usize + ()` diff --git a/src/test/ui/no-stdio.rs b/src/test/ui/no-stdio.rs index 1b0ad930da6..68e6fa838b4 100644 --- a/src/test/ui/no-stdio.rs +++ b/src/test/ui/no-stdio.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/out-of-stack.rs b/src/test/ui/out-of-stack.rs index 6beafc0732b..2d59c9f29b1 100644 --- a/src/test/ui/out-of-stack.rs +++ b/src/test/ui/out-of-stack.rs @@ -3,7 +3,6 @@ #![allow(unused_must_use)] #![allow(unconditional_recursion)] // ignore-android: FIXME (#20004) -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/panic-runtime/abort-link-to-unwind-dylib.rs b/src/test/ui/panic-runtime/abort-link-to-unwind-dylib.rs index 4b0f92456e0..f8368ff6900 100644 --- a/src/test/ui/panic-runtime/abort-link-to-unwind-dylib.rs +++ b/src/test/ui/panic-runtime/abort-link-to-unwind-dylib.rs @@ -1,7 +1,6 @@ // build-fail // compile-flags:-C panic=abort -C prefer-dynamic // ignore-musl - no dylibs here -// ignore-cloudabi // ignore-emscripten // ignore-sgx no dynamic lib support // error-pattern:`panic_unwind` is not compiled with this crate's panic strategy diff --git a/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs b/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs index 9c099911eab..566626513ef 100644 --- a/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs +++ b/src/test/ui/panic-runtime/abort-link-to-unwinding-crates.rs @@ -3,7 +3,6 @@ // compile-flags:-C panic=abort // aux-build:exit-success-if-unwind.rs // no-prefer-dynamic -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-macos diff --git a/src/test/ui/panic-runtime/abort.rs b/src/test/ui/panic-runtime/abort.rs index f625fe35d72..dcc4061fde7 100644 --- a/src/test/ui/panic-runtime/abort.rs +++ b/src/test/ui/panic-runtime/abort.rs @@ -2,7 +2,6 @@ #![allow(unused_variables)] // compile-flags:-C panic=abort // no-prefer-dynamic -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-macos diff --git a/src/test/ui/panic-runtime/lto-abort.rs b/src/test/ui/panic-runtime/lto-abort.rs index 8fff71a629a..5cc4c013235 100644 --- a/src/test/ui/panic-runtime/lto-abort.rs +++ b/src/test/ui/panic-runtime/lto-abort.rs @@ -2,7 +2,6 @@ #![allow(unused_variables)] // compile-flags:-C lto -C panic=abort // no-prefer-dynamic -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/panic-runtime/lto-unwind.rs b/src/test/ui/panic-runtime/lto-unwind.rs index 94a0b596e4a..6f39b76526b 100644 --- a/src/test/ui/panic-runtime/lto-unwind.rs +++ b/src/test/ui/panic-runtime/lto-unwind.rs @@ -3,7 +3,6 @@ // compile-flags:-C lto -C panic=unwind // no-prefer-dynamic -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/panics/abort-on-panic.rs b/src/test/ui/panics/abort-on-panic.rs index c6e8dbf012c..f34cf6a9cbf 100644 --- a/src/test/ui/panics/abort-on-panic.rs +++ b/src/test/ui/panics/abort-on-panic.rs @@ -5,7 +5,6 @@ // Since we mark some ABIs as "nounwind" to LLVM, we must make sure that // we never unwind through them. -// ignore-cloudabi no env and process // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/panics/issue-47429-short-backtraces.rs b/src/test/ui/panics/issue-47429-short-backtraces.rs index 1e8c38cc342..015ab8fdd80 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.rs +++ b/src/test/ui/panics/issue-47429-short-backtraces.rs @@ -7,7 +7,6 @@ // ignore-msvc see #62897 and `backtrace-debuginfo.rs` test // ignore-android FIXME #17520 -// ignore-cloudabi spawning processes is not supported // ignore-openbsd no support for libbacktrace without filename // ignore-wasm no panic or subprocess support // ignore-emscripten no panic or subprocess support diff --git a/src/test/ui/panics/issue-47429-short-backtraces.run.stderr b/src/test/ui/panics/issue-47429-short-backtraces.run.stderr index 99ee26fe55e..32879638907 100644 --- a/src/test/ui/panics/issue-47429-short-backtraces.run.stderr +++ b/src/test/ui/panics/issue-47429-short-backtraces.run.stderr @@ -1,4 +1,4 @@ -thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:17:5 +thread 'main' panicked at 'explicit panic', $DIR/issue-47429-short-backtraces.rs:16:5 stack backtrace: 0: std::panicking::begin_panic 1: issue_47429_short_backtraces::main diff --git a/src/test/ui/paths-containing-nul.rs b/src/test/ui/paths-containing-nul.rs index e9510b53fea..cb40c4f6fbf 100644 --- a/src/test/ui/paths-containing-nul.rs +++ b/src/test/ui/paths-containing-nul.rs @@ -1,7 +1,6 @@ // run-pass #![allow(deprecated)] -// ignore-cloudabi no files or I/O // ignore-wasm32-bare no files or I/O // ignore-emscripten no files // ignore-sgx no files diff --git a/src/test/ui/print-stdout-eprint-stderr.rs b/src/test/ui/print-stdout-eprint-stderr.rs index 70c083e0800..cfa9aec8068 100644 --- a/src/test/ui/print-stdout-eprint-stderr.rs +++ b/src/test/ui/print-stdout-eprint-stderr.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported // ignore-sgx no processes diff --git a/src/test/ui/process/process-envs.rs b/src/test/ui/process/process-envs.rs index 62a4733f89a..8fc99b23fd2 100644 --- a/src/test/ui/process/process-envs.rs +++ b/src/test/ui/process/process-envs.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-vxworks no 'env' diff --git a/src/test/ui/process/process-exit.rs b/src/test/ui/process/process-exit.rs index da3b4ca85c2..d193e073e7f 100644 --- a/src/test/ui/process/process-exit.rs +++ b/src/test/ui/process/process-exit.rs @@ -1,6 +1,5 @@ // run-pass #![allow(unused_imports)] -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/process/process-remove-from-env.rs b/src/test/ui/process/process-remove-from-env.rs index 3fee9e2abb9..af4e49dfdbb 100644 --- a/src/test/ui/process/process-remove-from-env.rs +++ b/src/test/ui/process/process-remove-from-env.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-vxworks no 'env' diff --git a/src/test/ui/process/process-sigpipe.rs b/src/test/ui/process/process-sigpipe.rs index 36303440ee9..ecf5e93c99e 100644 --- a/src/test/ui/process/process-sigpipe.rs +++ b/src/test/ui/process/process-sigpipe.rs @@ -12,7 +12,6 @@ // (instead of running forever), and that it does not print an error // message about a broken pipe. -// ignore-cloudabi no subprocesses support // ignore-emscripten no threads support // ignore-vxworks no 'sh' diff --git a/src/test/ui/process/process-spawn-nonexistent.rs b/src/test/ui/process/process-spawn-nonexistent.rs index 182cf1748fe..70de7316a81 100644 --- a/src/test/ui/process/process-spawn-nonexistent.rs +++ b/src/test/ui/process/process-spawn-nonexistent.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/process/process-spawn-with-unicode-params.rs b/src/test/ui/process/process-spawn-with-unicode-params.rs index edd3cb26ec3..6e9229b6293 100644 --- a/src/test/ui/process/process-spawn-with-unicode-params.rs +++ b/src/test/ui/process/process-spawn-with-unicode-params.rs @@ -7,7 +7,6 @@ // non-ASCII characters. The child process ensures all the strings are // intact. -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/process/process-status-inherits-stdin.rs b/src/test/ui/process/process-status-inherits-stdin.rs index f9b2da7e401..7719dd9ad85 100644 --- a/src/test/ui/process/process-status-inherits-stdin.rs +++ b/src/test/ui/process/process-status-inherits-stdin.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/process/tls-exit-status.rs b/src/test/ui/process/tls-exit-status.rs index 36d6aff9e77..6296e5042d2 100644 --- a/src/test/ui/process/tls-exit-status.rs +++ b/src/test/ui/process/tls-exit-status.rs @@ -1,7 +1,6 @@ // run-fail // error-pattern:nonzero // exec-env:RUST_NEWRT=1 -// ignore-cloudabi no std::env // ignore-emscripten no processes use std::env; diff --git a/src/test/ui/resolve/token-error-correct-3.rs b/src/test/ui/resolve/token-error-correct-3.rs index 5b08234c0ad..52934085fa1 100644 --- a/src/test/ui/resolve/token-error-correct-3.rs +++ b/src/test/ui/resolve/token-error-correct-3.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::fs support - // Test that we do some basic error correction in the tokeniser (and don't spew // too many bogus errors). diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr index dd0e2597850..31087e394ad 100644 --- a/src/test/ui/resolve/token-error-correct-3.stderr +++ b/src/test/ui/resolve/token-error-correct-3.stderr @@ -1,5 +1,5 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;` - --> $DIR/token-error-correct-3.rs:15:35 + --> $DIR/token-error-correct-3.rs:13:35 | LL | callback(path.as_ref(); | - ^ help: `)` may belong here @@ -7,7 +7,7 @@ LL | callback(path.as_ref(); | unclosed delimiter error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)` - --> $DIR/token-error-correct-3.rs:18:9 + --> $DIR/token-error-correct-3.rs:16:9 | LL | fs::create_dir_all(path.as_ref()).map(|()| true) | - expected one of `.`, `;`, `?`, `}`, or an operator @@ -15,7 +15,7 @@ LL | } else { | ^ unexpected token error[E0425]: cannot find function `is_directory` in this scope - --> $DIR/token-error-correct-3.rs:13:13 + --> $DIR/token-error-correct-3.rs:11:13 | LL | if !is_directory(path.as_ref()) { | ^^^^^^^^^^^^ not found in this scope diff --git a/src/test/ui/resolve/use_suggestion_placement.rs b/src/test/ui/resolve/use_suggestion_placement.rs index 9b8b9d88c79..56d4b8d6d11 100644 --- a/src/test/ui/resolve/use_suggestion_placement.rs +++ b/src/test/ui/resolve/use_suggestion_placement.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::path support - macro_rules! y { () => {} } diff --git a/src/test/ui/resolve/use_suggestion_placement.stderr b/src/test/ui/resolve/use_suggestion_placement.stderr index 3f91760fe21..af0495a57a1 100644 --- a/src/test/ui/resolve/use_suggestion_placement.stderr +++ b/src/test/ui/resolve/use_suggestion_placement.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `Path` in this scope - --> $DIR/use_suggestion_placement.rs:17:16 + --> $DIR/use_suggestion_placement.rs:15:16 | LL | type Bar = Path; | ^^^^ not found in this scope @@ -10,7 +10,7 @@ LL | use std::path::Path; | error[E0425]: cannot find value `A` in this scope - --> $DIR/use_suggestion_placement.rs:22:13 + --> $DIR/use_suggestion_placement.rs:20:13 | LL | let _ = A; | ^ not found in this scope @@ -21,7 +21,7 @@ LL | use m::A; | error[E0412]: cannot find type `HashMap` in this scope - --> $DIR/use_suggestion_placement.rs:27:23 + --> $DIR/use_suggestion_placement.rs:25:23 | LL | type Dict = HashMap; | ^^^^^^^ not found in this scope diff --git a/src/test/ui/rfcs/rfc-1014.rs b/src/test/ui/rfcs/rfc-1014.rs index 53b8fddcf31..c454dfa4eb9 100644 --- a/src/test/ui/rfcs/rfc-1014.rs +++ b/src/test/ui/rfcs/rfc-1014.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -// ignore-cloudabi stdout does not map to file descriptor 1 by default // ignore-wasm32-bare no libc // ignore-sgx no libc diff --git a/src/test/ui/running-with-no-runtime.rs b/src/test/ui/running-with-no-runtime.rs index 3fc631be60e..c321e86dc18 100644 --- a/src/test/ui/running-with-no-runtime.rs +++ b/src/test/ui/running-with-no-runtime.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported // ignore-sgx no processes diff --git a/src/test/ui/signal-alternate-stack-cleanup.rs b/src/test/ui/signal-alternate-stack-cleanup.rs index 8fef66eac8d..15fcf78893e 100644 --- a/src/test/ui/signal-alternate-stack-cleanup.rs +++ b/src/test/ui/signal-alternate-stack-cleanup.rs @@ -3,7 +3,6 @@ // main thread exit while still being in use by signal handlers. This test // triggers this situation by sending signal from atexit handler. // -// ignore-cloudabi no signal handling support // ignore-wasm32-bare no libc // ignore-windows // ignore-sgx no libc diff --git a/src/test/ui/signal-exit-status.rs b/src/test/ui/signal-exit-status.rs index bd34a218160..0963dcc80f6 100644 --- a/src/test/ui/signal-exit-status.rs +++ b/src/test/ui/signal-exit-status.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-windows diff --git a/src/test/ui/sigpipe-should-be-ignored.rs b/src/test/ui/sigpipe-should-be-ignored.rs index f472029b820..144eeca2318 100644 --- a/src/test/ui/sigpipe-should-be-ignored.rs +++ b/src/test/ui/sigpipe-should-be-ignored.rs @@ -4,7 +4,6 @@ // Be sure that when a SIGPIPE would have been received that the entire process // doesn't die in a ball of fire, but rather it's gracefully handled. -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/span/issue-33884.rs b/src/test/ui/span/issue-33884.rs index cef123d697b..5d927a5acc8 100644 --- a/src/test/ui/span/issue-33884.rs +++ b/src/test/ui/span/issue-33884.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::net support - use std::net::TcpListener; use std::net::TcpStream; use std::io::{self, Read, Write}; diff --git a/src/test/ui/span/issue-33884.stderr b/src/test/ui/span/issue-33884.stderr index 46f36679b89..473d36c2ab1 100644 --- a/src/test/ui/span/issue-33884.stderr +++ b/src/test/ui/span/issue-33884.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-33884.rs:8:22 + --> $DIR/issue-33884.rs:6:22 | LL | stream.write_fmt(format!("message received")) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `Arguments`, found struct `String` diff --git a/src/test/ui/sse2.rs b/src/test/ui/sse2.rs index 7726972b95b..172f4079821 100644 --- a/src/test/ui/sse2.rs +++ b/src/test/ui/sse2.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no std::env #![allow(stable_features)] #![feature(cfg_target_feature)] diff --git a/src/test/ui/std-backtrace.rs b/src/test/ui/std-backtrace.rs index 902a2b6f5a0..b5e76666af1 100644 --- a/src/test/ui/std-backtrace.rs +++ b/src/test/ui/std-backtrace.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android FIXME #17520 -// ignore-cloudabi spawning processes is not supported // ignore-emscripten spawning processes is not supported // ignore-openbsd no support for libbacktrace without filename // ignore-sgx no processes diff --git a/src/test/ui/stdio-is-blocking.rs b/src/test/ui/stdio-is-blocking.rs index e96406e46b5..4b67dbf79e0 100644 --- a/src/test/ui/stdio-is-blocking.rs +++ b/src/test/ui/stdio-is-blocking.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/structs-enums/rec-align-u64.rs b/src/test/ui/structs-enums/rec-align-u64.rs index b06e204d31b..69544b1c060 100644 --- a/src/test/ui/structs-enums/rec-align-u64.rs +++ b/src/test/ui/structs-enums/rec-align-u64.rs @@ -32,7 +32,6 @@ struct Outer { #[cfg(any(target_os = "android", - target_os = "cloudabi", target_os = "dragonfly", target_os = "emscripten", target_os = "freebsd", diff --git a/src/test/ui/tcp-stress.rs b/src/test/ui/tcp-stress.rs index 08b47dc5318..17566364340 100644 --- a/src/test/ui/tcp-stress.rs +++ b/src/test/ui/tcp-stress.rs @@ -1,6 +1,5 @@ // run-pass // ignore-android needs extra network permissions -// ignore-cloudabi no global network namespace access // ignore-emscripten no threads or sockets support // ignore-netbsd system ulimit (Too many open files) // ignore-openbsd system ulimit (Too many open files) diff --git a/src/test/ui/threads-sendsync/sync-send-in-std.rs b/src/test/ui/threads-sendsync/sync-send-in-std.rs index 15e10dc250f..b8ae214dc09 100644 --- a/src/test/ui/threads-sendsync/sync-send-in-std.rs +++ b/src/test/ui/threads-sendsync/sync-send-in-std.rs @@ -1,6 +1,5 @@ // run-pass -// ignore-cloudabi networking not available // ignore-wasm32-bare networking not available // ignore-sgx ToSocketAddrs cannot be used for DNS Resolution diff --git a/src/test/ui/try-operator-on-main.rs b/src/test/ui/try-operator-on-main.rs index a8a99a150c1..e1b6cfbe5ae 100644 --- a/src/test/ui/try-operator-on-main.rs +++ b/src/test/ui/try-operator-on-main.rs @@ -1,5 +1,3 @@ -// ignore-cloudabi no std::fs support - #![feature(try_trait)] use std::ops::Try; diff --git a/src/test/ui/try-operator-on-main.stderr b/src/test/ui/try-operator-on-main.stderr index f2e17812aed..be17de2fe7c 100644 --- a/src/test/ui/try-operator-on-main.stderr +++ b/src/test/ui/try-operator-on-main.stderr @@ -1,5 +1,5 @@ error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `Try`) - --> $DIR/try-operator-on-main.rs:9:5 + --> $DIR/try-operator-on-main.rs:7:5 | LL | / fn main() { LL | | // error for a `Try` type on a non-`Try` fn @@ -15,7 +15,7 @@ LL | | } = note: required by `from_error` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/try-operator-on-main.rs:12:5 + --> $DIR/try-operator-on-main.rs:10:5 | LL | ()?; | ^^^ the `?` operator cannot be applied to type `()` @@ -24,7 +24,7 @@ LL | ()?; = note: required by `into_result` error[E0277]: the trait bound `(): Try` is not satisfied - --> $DIR/try-operator-on-main.rs:15:25 + --> $DIR/try-operator-on-main.rs:13:25 | LL | try_trait_generic::<()>(); | ^^ the trait `Try` is not implemented for `()` @@ -33,7 +33,7 @@ LL | fn try_trait_generic() -> T { | --- required by this bound in `try_trait_generic` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/try-operator-on-main.rs:22:5 + --> $DIR/try-operator-on-main.rs:20:5 | LL | ()?; | ^^^ the `?` operator cannot be applied to type `()` diff --git a/src/test/ui/try-operator.rs b/src/test/ui/try-operator.rs index 9118e8e7134..516ae4c4090 100644 --- a/src/test/ui/try-operator.rs +++ b/src/test/ui/try-operator.rs @@ -1,7 +1,6 @@ // run-pass #![allow(dead_code)] -// ignore-cloudabi no std::fs use std::fs::File; use std::io::{Read, self}; diff --git a/src/test/ui/try-wait.rs b/src/test/ui/try-wait.rs index d8a07c55cf2..692197210b1 100644 --- a/src/test/ui/try-wait.rs +++ b/src/test/ui/try-wait.rs @@ -1,7 +1,6 @@ // run-pass #![allow(stable_features)] -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes diff --git a/src/test/ui/wait-forked-but-failed-child.rs b/src/test/ui/wait-forked-but-failed-child.rs index 08b16c0e9ca..26835907759 100644 --- a/src/test/ui/wait-forked-but-failed-child.rs +++ b/src/test/ui/wait-forked-but-failed-child.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-cloudabi no processes // ignore-emscripten no processes // ignore-sgx no processes // ignore-vxworks no 'ps' diff --git a/src/test/ui/x86stdcall.rs b/src/test/ui/x86stdcall.rs index 32a4df87fbe..e1136807b3c 100644 --- a/src/test/ui/x86stdcall.rs +++ b/src/test/ui/x86stdcall.rs @@ -24,7 +24,6 @@ pub fn main() { } #[cfg(any(target_os = "android", - target_os = "cloudabi", target_os = "dragonfly", target_os = "emscripten", target_os = "freebsd", diff --git a/src/tools/build-manifest/src/main.rs b/src/tools/build-manifest/src/main.rs index 687354dc6ae..0462efaa9b0 100644 --- a/src/tools/build-manifest/src/main.rs +++ b/src/tools/build-manifest/src/main.rs @@ -57,7 +57,6 @@ static TARGETS: &[&str] = &[ "aarch64-fuchsia", "aarch64-linux-android", "aarch64-pc-windows-msvc", - "aarch64-unknown-cloudabi", "aarch64-unknown-hermit", "aarch64-unknown-linux-gnu", "aarch64-unknown-linux-musl", @@ -143,7 +142,6 @@ static TARGETS: &[&str] = &[ "x86_64-rumprun-netbsd", "x86_64-sun-solaris", "x86_64-pc-solaris", - "x86_64-unknown-cloudabi", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", diff --git a/src/tools/clippy/clippy_lints/src/attrs.rs b/src/tools/clippy/clippy_lints/src/attrs.rs index 57702dafa6a..9a667aa61b4 100644 --- a/src/tools/clippy/clippy_lints/src/attrs.rs +++ b/src/tools/clippy/clippy_lints/src/attrs.rs @@ -40,7 +40,7 @@ static UNIX_SYSTEMS: &[&str] = &[ ]; // NOTE: windows is excluded from the list because it's also a valid target family. -static NON_UNIX_SYSTEMS: &[&str] = &["cloudabi", "hermit", "none", "wasi"]; +static NON_UNIX_SYSTEMS: &[&str] = &["hermit", "none", "wasi"]; declare_clippy_lint! { /// **What it does:** Checks for items annotated with `#[inline(always)]`, diff --git a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.fixed b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.fixed index 3ee77dcac31..f219a570e7f 100644 --- a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.fixed +++ b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.fixed @@ -3,9 +3,6 @@ #![warn(clippy::mismatched_target_os)] #![allow(unused)] -#[cfg(target_os = "cloudabi")] -fn cloudabi() {} - #[cfg(target_os = "hermit")] fn hermit() {} @@ -16,7 +13,7 @@ fn wasi() {} fn none() {} // list with conditions -#[cfg(all(not(any(windows, target_os = "cloudabi")), target_os = "wasi"))] +#[cfg(all(not(windows), target_os = "wasi"))] fn list() {} // windows is a valid target family, should be ignored diff --git a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.rs b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.rs index 9cc411418e4..8a8ae756a4f 100644 --- a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.rs +++ b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.rs @@ -3,9 +3,6 @@ #![warn(clippy::mismatched_target_os)] #![allow(unused)] -#[cfg(cloudabi)] -fn cloudabi() {} - #[cfg(hermit)] fn hermit() {} @@ -16,7 +13,7 @@ fn wasi() {} fn none() {} // list with conditions -#[cfg(all(not(any(windows, cloudabi)), wasi))] +#[cfg(all(not(windows), wasi))] fn list() {} // windows is a valid target family, should be ignored diff --git a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr index 78fc27752d2..5f1b0908304 100644 --- a/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr +++ b/src/tools/clippy/tests/ui/mismatched_target_os_non_unix.stderr @@ -1,23 +1,15 @@ error: operating system used in target family position --> $DIR/mismatched_target_os_non_unix.rs:6:1 | -LL | #[cfg(cloudabi)] - | ^^^^^^--------^^ - | | - | help: try: `target_os = "cloudabi"` - | - = note: `-D clippy::mismatched-target-os` implied by `-D warnings` - -error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:9:1 - | LL | #[cfg(hermit)] | ^^^^^^------^^ | | | help: try: `target_os = "hermit"` + | + = note: `-D clippy::mismatched-target-os` implied by `-D warnings` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:12:1 + --> $DIR/mismatched_target_os_non_unix.rs:9:1 | LL | #[cfg(wasi)] | ^^^^^^----^^ @@ -25,7 +17,7 @@ LL | #[cfg(wasi)] | help: try: `target_os = "wasi"` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:15:1 + --> $DIR/mismatched_target_os_non_unix.rs:12:1 | LL | #[cfg(none)] | ^^^^^^----^^ @@ -33,19 +25,12 @@ LL | #[cfg(none)] | help: try: `target_os = "none"` error: operating system used in target family position - --> $DIR/mismatched_target_os_non_unix.rs:19:1 + --> $DIR/mismatched_target_os_non_unix.rs:16:1 | -LL | #[cfg(all(not(any(windows, cloudabi)), wasi))] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: try - | -LL | #[cfg(all(not(any(windows, target_os = "cloudabi")), wasi))] - | ^^^^^^^^^^^^^^^^^^^^^^ -help: try - | -LL | #[cfg(all(not(any(windows, cloudabi)), target_os = "wasi"))] - | ^^^^^^^^^^^^^^^^^^ +LL | #[cfg(all(not(windows), wasi))] + | ^^^^^^^^^^^^^^^^^^^^^^^^----^^^ + | | + | help: try: `target_os = "wasi"` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4ca0b2aba0a..1b9f0089dce 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1790,8 +1790,7 @@ impl<'test> TestCx<'test> { let (dylib, crate_type) = if aux_props.no_prefer_dynamic { (true, None) - } else if self.config.target.contains("cloudabi") - || self.config.target.contains("emscripten") + } else if self.config.target.contains("emscripten") || (self.config.target.contains("musl") && !aux_props.force_host && !self.config.host.contains("musl")) diff --git a/src/tools/compiletest/src/util.rs b/src/tools/compiletest/src/util.rs index 1a727fc2b82..4f77e719fba 100644 --- a/src/tools/compiletest/src/util.rs +++ b/src/tools/compiletest/src/util.rs @@ -12,7 +12,6 @@ mod tests; const OS_TABLE: &[(&str, &str)] = &[ ("android", "android"), ("androideabi", "android"), - ("cloudabi", "cloudabi"), ("cuda", "cuda"), ("darwin", "macos"), ("dragonfly", "dragonfly"), diff --git a/src/tools/tidy/src/style.rs b/src/tools/tidy/src/style.rs index bce3cf06b07..6697fbd1be2 100644 --- a/src/tools/tidy/src/style.rs +++ b/src/tools/tidy/src/style.rs @@ -173,7 +173,6 @@ pub fn check(path: &Path, bad: &mut bool) { // parser to tidy. !file.ancestors().any(|a| { a.ends_with("src/test") || - a.ends_with("library/std/src/sys/cloudabi") || a.ends_with("src/doc/book") }); diff --git a/src/tools/tidy/src/unit_tests.rs b/src/tools/tidy/src/unit_tests.rs index 04f2bbaa0d9..f675b78651e 100644 --- a/src/tools/tidy/src/unit_tests.rs +++ b/src/tools/tidy/src/unit_tests.rs @@ -31,8 +31,6 @@ pub fn check(root_path: &Path, bad: &mut bool) { // UI tests with different names || path.ends_with("src/thread/local/dynamic_tests.rs") || path.ends_with("src/sync/mpsc/sync_tests.rs") - // Has copyright banner - || path.ends_with("src/sys/cloudabi/abi/cloudabi.rs") } };