Skip to content

Commit aaa014d

Browse files
committed
Auto merge of rust-lang#117285 - joboet:move_platforms_to_pal, r=ChrisDenton
Move platform modules into `sys::pal` This is the initial step of rust-lang#117276. `sys` just re-exports everything from the current `sys` for now, I'll move the implementations for the individual features one-by-one after this PR merges.
2 parents 62d7ed4 + 7c436a8 commit aaa014d

File tree

279 files changed

+214
-208
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

279 files changed

+214
-208
lines changed

.reuse/dep5

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Copyright: 2019 The Crossbeam Project Developers
5151
The Rust Project Developers (see https://thanks.rust-lang.org)
5252
License: MIT OR Apache-2.0
5353

54-
Files: library/std/src/sys/unix/locks/fuchsia_mutex.rs
54+
Files: library/std/src/sys/pal/unix/locks/fuchsia_mutex.rs
5555
Copyright: 2016 The Fuchsia Authors
5656
The Rust Project Developers (see https://thanks.rust-lang.org)
5757
License: BSD-2-Clause AND (MIT OR Apache-2.0)

compiler/rustc_session/src/config/sigpipe.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
//! NOTE: Keep these constants in sync with `library/std/src/sys/unix/mod.rs`!
1+
//! NOTE: Keep these constants in sync with `library/std/src/sys/pal/unix/mod.rs`!
22
33
/// The default value if `#[unix_sigpipe]` is not specified. This resolves
4-
/// to `SIG_IGN` in `library/std/src/sys/unix/mod.rs`.
4+
/// to `SIG_IGN` in `library/std/src/sys/pal/unix/mod.rs`.
55
///
66
/// Note that `SIG_IGN` has been the Rust default since 2014. See
77
/// <https://github.com/rust-lang/rust/issues/62569>.

compiler/rustc_target/src/spec/base/illumos.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn opts() -> TargetOptions {
3939
// While we support ELF TLS, rust requires a way to register
4040
// cleanup handlers (in C, this would be something along the lines of:
4141
// void register_callback(void (*fn)(void *), void *arg);
42-
// (see src/libstd/sys/unix/fast_thread_local.rs) that is currently
42+
// (see src/libstd/sys/pal/unix/fast_thread_local.rs) that is currently
4343
// missing in illumos. For now at least, we must fallback to using
4444
// pthread_{get,set}specific.
4545
//has_thread_local: true,

library/core/tests/num/int_log.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! This tests the `Integer::{ilog,log2,log10}` methods. These tests are in a
22
//! separate file because there's both a large number of them, and not all tests
33
//! can be run on Android. This is because in Android `ilog2` uses an imprecise
4-
//! approximation:https://github.com/rust-lang/rust/blob/4825e12fc9c79954aa0fe18f5521efa6c19c7539/src/libstd/sys/unix/android.rs#L27-L53
4+
//! approximation:https://github.com/rust-lang/rust/blob/4825e12fc9c79954aa0fe18f5521efa6c19c7539/src/libstd/sys/pal/unix/android.rs#L27-L53
55
66
#[test]
77
fn checked_ilog() {

library/std/src/sys/mod.rs

+8-124
Original file line numberDiff line numberDiff line change
@@ -1,124 +1,8 @@
1-
//! Platform-dependent platform abstraction.
2-
//!
3-
//! The `std::sys` module is the abstracted interface through which
4-
//! `std` talks to the underlying operating system. It has different
5-
//! implementations for different operating system families, today
6-
//! just Unix and Windows, and initial support for Redox.
7-
//!
8-
//! The centralization of platform-specific code in this module is
9-
//! enforced by the "platform abstraction layer" tidy script in
10-
//! `tools/tidy/src/pal.rs`.
11-
//!
12-
//! This module is closely related to the platform-independent system
13-
//! integration code in `std::sys_common`. See that module's
14-
//! documentation for details.
15-
//!
16-
//! In the future it would be desirable for the independent
17-
//! implementations of this module to be extracted to their own crates
18-
//! that `std` can link to, thus enabling their implementation
19-
//! out-of-tree via crate replacement. Though due to the complex
20-
//! inter-dependencies within `std` that will be a challenging goal to
21-
//! achieve.
22-
23-
#![allow(missing_debug_implementations)]
24-
25-
pub mod common;
26-
mod personality;
27-
28-
cfg_if::cfg_if! {
29-
if #[cfg(unix)] {
30-
mod unix;
31-
pub use self::unix::*;
32-
} else if #[cfg(windows)] {
33-
mod windows;
34-
pub use self::windows::*;
35-
} else if #[cfg(target_os = "solid_asp3")] {
36-
mod solid;
37-
pub use self::solid::*;
38-
} else if #[cfg(target_os = "hermit")] {
39-
mod hermit;
40-
pub use self::hermit::*;
41-
} else if #[cfg(target_os = "wasi")] {
42-
mod wasi;
43-
pub use self::wasi::*;
44-
} else if #[cfg(target_family = "wasm")] {
45-
mod wasm;
46-
pub use self::wasm::*;
47-
} else if #[cfg(target_os = "xous")] {
48-
mod xous;
49-
pub use self::xous::*;
50-
} else if #[cfg(target_os = "uefi")] {
51-
mod uefi;
52-
pub use self::uefi::*;
53-
} else if #[cfg(all(target_vendor = "fortanix", target_env = "sgx"))] {
54-
mod sgx;
55-
pub use self::sgx::*;
56-
} else if #[cfg(target_os = "teeos")] {
57-
mod teeos;
58-
pub use self::teeos::*;
59-
} else {
60-
mod unsupported;
61-
pub use self::unsupported::*;
62-
}
63-
}
64-
65-
cfg_if::cfg_if! {
66-
// Fuchsia components default to full backtrace.
67-
if #[cfg(target_os = "fuchsia")] {
68-
pub const FULL_BACKTRACE_DEFAULT: bool = true;
69-
} else {
70-
pub const FULL_BACKTRACE_DEFAULT: bool = false;
71-
}
72-
}
73-
74-
#[cfg(not(test))]
75-
cfg_if::cfg_if! {
76-
if #[cfg(target_os = "android")] {
77-
pub use self::android::log2f32;
78-
pub use self::android::log2f64;
79-
} else {
80-
#[inline]
81-
pub fn log2f32(n: f32) -> f32 {
82-
unsafe { crate::intrinsics::log2f32(n) }
83-
}
84-
85-
#[inline]
86-
pub fn log2f64(n: f64) -> f64 {
87-
unsafe { crate::intrinsics::log2f64(n) }
88-
}
89-
}
90-
}
91-
92-
// Solaris/Illumos requires a wrapper around log, log2, and log10 functions
93-
// because of their non-standard behavior (e.g., log(-n) returns -Inf instead
94-
// of expected NaN).
95-
#[cfg(not(test))]
96-
#[cfg(any(target_os = "solaris", target_os = "illumos"))]
97-
#[inline]
98-
pub fn log_wrapper<F: Fn(f64) -> f64>(n: f64, log_fn: F) -> f64 {
99-
if n.is_finite() {
100-
if n > 0.0 {
101-
log_fn(n)
102-
} else if n == 0.0 {
103-
f64::NEG_INFINITY // log(0) = -Inf
104-
} else {
105-
f64::NAN // log(-n) = NaN
106-
}
107-
} else if n.is_nan() {
108-
n // log(NaN) = NaN
109-
} else if n > 0.0 {
110-
n // log(Inf) = Inf
111-
} else {
112-
f64::NAN // log(-Inf) = NaN
113-
}
114-
}
115-
116-
#[cfg(not(test))]
117-
#[cfg(not(any(target_os = "solaris", target_os = "illumos")))]
118-
#[inline]
119-
pub fn log_wrapper<F: Fn(f64) -> f64>(n: f64, log_fn: F) -> f64 {
120-
log_fn(n)
121-
}
122-
123-
#[cfg(not(target_os = "uefi"))]
124-
pub type RawOsError = i32;
1+
/// The PAL (platform abstraction layer) contains platform-specific abstractions
2+
/// for implementing the features in the other submodules, e.g. UNIX file
3+
/// descriptors.
4+
mod pal;
5+
6+
// FIXME(117276): remove this, move feature implementations into individual
7+
// submodules.
8+
pub use pal::*;
File renamed without changes.
File renamed without changes.
File renamed without changes.

library/std/src/sys/hermit/alloc.rs library/std/src/sys/pal/hermit/alloc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use super::abi;
12
use crate::alloc::{GlobalAlloc, Layout, System};
23
use crate::ptr;
3-
use crate::sys::hermit::abi;
44

55
#[stable(feature = "alloc_system_type", since = "1.28.0")]
66
unsafe impl GlobalAlloc for System {
File renamed without changes.
File renamed without changes.

library/std/src/sys/hermit/fd.rs library/std/src/sys/pal/hermit/fd.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#![unstable(reason = "not public", issue = "none", feature = "fd")]
22

3+
use super::abi;
34
use crate::io::{self, Read};
45
use crate::os::hermit::io::{FromRawFd, OwnedFd, RawFd};
56
use crate::sys::cvt;
6-
use crate::sys::hermit::abi;
77
use crate::sys::unsupported;
88
use crate::sys_common::{AsInner, FromInner, IntoInner};
99

library/std/src/sys/hermit/fs.rs library/std/src/sys/pal/hermit/fs.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use super::abi::{self, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY};
2+
use super::fd::FileDesc;
13
use crate::ffi::{CStr, OsString};
24
use crate::fmt;
35
use crate::hash::{Hash, Hasher};
@@ -7,10 +9,6 @@ use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, Raw
79
use crate::path::{Path, PathBuf};
810
use crate::sys::common::small_c_string::run_path_with_cstr;
911
use crate::sys::cvt;
10-
use crate::sys::hermit::abi::{
11-
self, O_APPEND, O_CREAT, O_EXCL, O_RDONLY, O_RDWR, O_TRUNC, O_WRONLY,
12-
};
13-
use crate::sys::hermit::fd::FileDesc;
1412
use crate::sys::time::SystemTime;
1513
use crate::sys::unsupported;
1614
use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
File renamed without changes.
File renamed without changes.

library/std/src/sys/hermit/mod.rs library/std/src/sys/pal/hermit/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ pub unsafe extern "C" fn runtime_entry(
115115
argv: *const *const c_char,
116116
env: *const *const c_char,
117117
) -> ! {
118-
use crate::sys::hermit::thread_local_dtor::run_dtors;
118+
use thread_local_dtor::run_dtors;
119119
extern "C" {
120120
fn main(argc: isize, argv: *const *const c_char) -> i32;
121121
}

library/std/src/sys/hermit/net.rs library/std/src/sys/pal/hermit/net.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#![allow(dead_code)]
22

3+
use super::fd::FileDesc;
34
use crate::cmp;
45
use crate::io::{self, BorrowedBuf, BorrowedCursor, IoSlice, IoSliceMut};
56
use crate::mem;
67
use crate::net::{Shutdown, SocketAddr};
78
use crate::os::hermit::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, RawFd};
8-
use crate::sys::hermit::fd::FileDesc;
99
use crate::sys::time::Instant;
1010
use crate::sys_common::net::{getsockopt, setsockopt, sockaddr_to_addr};
1111
use crate::sys_common::{AsInner, FromInner, IntoInner};

library/std/src/sys/hermit/os.rs library/std/src/sys/pal/hermit/os.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use super::abi;
12
use crate::collections::HashMap;
23
use crate::error::Error as StdError;
34
use crate::ffi::{CStr, OsStr, OsString};
@@ -8,7 +9,6 @@ use crate::os::hermit::ffi::OsStringExt;
89
use crate::path::{self, PathBuf};
910
use crate::str;
1011
use crate::sync::Mutex;
11-
use crate::sys::hermit::abi;
1212
use crate::sys::memchr;
1313
use crate::sys::unsupported;
1414
use crate::vec;

library/std/src/sys/hermit/stdio.rs library/std/src/sys/pal/hermit/stdio.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
use super::abi;
12
use crate::io;
23
use crate::io::{IoSlice, IoSliceMut};
3-
use crate::sys::hermit::abi;
44

55
pub struct Stdin;
66
pub struct Stdout;

library/std/src/sys/hermit/thread.rs library/std/src/sys/pal/hermit/thread.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#![allow(dead_code)]
22

3+
use super::abi;
4+
use super::thread_local_dtor::run_dtors;
35
use crate::ffi::CStr;
46
use crate::io;
57
use crate::mem;
68
use crate::num::NonZeroUsize;
79
use crate::ptr;
8-
use crate::sys::hermit::abi;
9-
use crate::sys::hermit::thread_local_dtor::run_dtors;
1010
use crate::time::Duration;
1111

1212
pub type Tid = abi::Tid;

library/std/src/sys/hermit/time.rs library/std/src/sys/pal/hermit/time.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#![allow(dead_code)]
22

3+
use super::abi;
4+
use super::abi::timespec;
5+
use super::abi::{CLOCK_MONOTONIC, CLOCK_REALTIME, NSEC_PER_SEC};
36
use crate::cmp::Ordering;
47
use crate::ops::{Add, AddAssign, Sub, SubAssign};
5-
use crate::sys::hermit::abi;
6-
use crate::sys::hermit::abi::timespec;
7-
use crate::sys::hermit::abi::{CLOCK_MONOTONIC, CLOCK_REALTIME, NSEC_PER_SEC};
88
use crate::time::Duration;
99
use core::hash::{Hash, Hasher};
1010

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)