Skip to content

Commit 487b867

Browse files
committed
Auto merge of rust-lang#130816 - matthiaskrgr:rollup-jy25phv, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - rust-lang#130549 (Add RISC-V vxworks targets) - rust-lang#130595 (Initial std library support for NuttX) - rust-lang#130734 (Fix: ices on virtual-function-elimination about principal trait) - rust-lang#130787 (Ban combination of GCE and new solver) - rust-lang#130809 (Update llvm triple for OpenHarmony targets) - rust-lang#130810 (Don't trap into the debugger on panics under Linux) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 699cadb + 685ede6 commit 487b867

File tree

22 files changed

+227
-100
lines changed

22 files changed

+227
-100
lines changed

panic_unwind/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cfg_if::cfg_if! {
4848
target_os = "psp",
4949
target_os = "xous",
5050
target_os = "solid_asp3",
51-
all(target_family = "unix", not(any(target_os = "espidf", target_os = "rtems"))),
51+
all(target_family = "unix", not(any(target_os = "espidf", target_os = "rtems", target_os = "nuttx"))),
5252
all(target_vendor = "fortanix", target_env = "sgx"),
5353
target_family = "wasm",
5454
))] {

std/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn main() {
5454
|| target_os == "teeos"
5555
|| target_os == "zkvm"
5656
|| target_os == "rtems"
57+
|| target_os == "nuttx"
5758

5859
// See src/bootstrap/src/core/build_steps/synthetic_targets.rs
5960
|| env::var("RUSTC_BOOTSTRAP_SYNTHETIC_TARGET").is_ok()

std/src/os/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ pub mod macos;
139139
pub mod netbsd;
140140
#[cfg(target_os = "nto")]
141141
pub mod nto;
142+
#[cfg(target_os = "nuttx")]
143+
pub mod nuttx;
142144
#[cfg(target_os = "openbsd")]
143145
pub mod openbsd;
144146
#[cfg(target_os = "redox")]

std/src/os/nuttx/fs.rs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#![stable(feature = "metadata_ext", since = "1.1.0")]
2+
3+
use crate::fs::Metadata;
4+
use crate::sys_common::AsInner;
5+
6+
#[stable(feature = "metadata_ext", since = "1.1.0")]
7+
pub trait MetadataExt {
8+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
9+
fn st_dev(&self) -> u64;
10+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
11+
fn st_ino(&self) -> u64;
12+
#[stable(feature = "metadata_ext", since = "1.1.0")]
13+
fn st_mode(&self) -> u32;
14+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
15+
fn st_nlink(&self) -> u64;
16+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
17+
fn st_uid(&self) -> u32;
18+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
19+
fn st_gid(&self) -> u32;
20+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
21+
fn st_rdev(&self) -> u64;
22+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
23+
fn st_size(&self) -> u64;
24+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
25+
fn st_atime(&self) -> i64;
26+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
27+
fn st_atime_nsec(&self) -> i64;
28+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
29+
fn st_mtime(&self) -> i64;
30+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
31+
fn st_mtime_nsec(&self) -> i64;
32+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
33+
fn st_ctime(&self) -> i64;
34+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
35+
fn st_ctime_nsec(&self) -> i64;
36+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
37+
fn st_blksize(&self) -> u64;
38+
#[stable(feature = "metadata_ext2", since = "1.8.0")]
39+
fn st_blocks(&self) -> u64;
40+
}
41+
42+
#[stable(feature = "metadata_ext", since = "1.1.0")]
43+
impl MetadataExt for Metadata {
44+
fn st_dev(&self) -> u64 {
45+
self.as_inner().as_inner().st_dev as u64
46+
}
47+
fn st_ino(&self) -> u64 {
48+
self.as_inner().as_inner().st_ino as u64
49+
}
50+
fn st_mode(&self) -> u32 {
51+
self.as_inner().as_inner().st_mode as u32
52+
}
53+
fn st_nlink(&self) -> u64 {
54+
self.as_inner().as_inner().st_nlink as u64
55+
}
56+
fn st_uid(&self) -> u32 {
57+
self.as_inner().as_inner().st_uid as u32
58+
}
59+
fn st_gid(&self) -> u32 {
60+
self.as_inner().as_inner().st_gid as u32
61+
}
62+
fn st_rdev(&self) -> u64 {
63+
self.as_inner().as_inner().st_rdev as u64
64+
}
65+
fn st_size(&self) -> u64 {
66+
self.as_inner().as_inner().st_size as u64
67+
}
68+
fn st_atime(&self) -> i64 {
69+
self.as_inner().as_inner().st_atim.tv_sec as i64
70+
}
71+
fn st_atime_nsec(&self) -> i64 {
72+
self.as_inner().as_inner().st_atim.tv_nsec as i64
73+
}
74+
fn st_mtime(&self) -> i64 {
75+
self.as_inner().as_inner().st_mtim.tv_sec as i64
76+
}
77+
fn st_mtime_nsec(&self) -> i64 {
78+
self.as_inner().as_inner().st_mtim.tv_nsec as i64
79+
}
80+
fn st_ctime(&self) -> i64 {
81+
self.as_inner().as_inner().st_ctim.tv_sec as i64
82+
}
83+
fn st_ctime_nsec(&self) -> i64 {
84+
self.as_inner().as_inner().st_ctim.tv_nsec as i64
85+
}
86+
fn st_blksize(&self) -> u64 {
87+
self.as_inner().as_inner().st_blksize as u64
88+
}
89+
fn st_blocks(&self) -> u64 {
90+
self.as_inner().as_inner().st_blocks as u64
91+
}
92+
}

std/src/os/nuttx/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#![stable(feature = "raw_ext", since = "1.1.0")]
2+
#![forbid(unsafe_op_in_unsafe_fn)]
3+
pub mod fs;
4+
pub(crate) mod raw;

std/src/os/nuttx/raw.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//! rtems raw type definitions
2+
3+
#![stable(feature = "raw_ext", since = "1.1.0")]
4+
#![deprecated(
5+
since = "1.8.0",
6+
note = "these type aliases are no longer supported by \
7+
the standard library, the `libc` crate on \
8+
crates.io should be used instead for the correct \
9+
definitions"
10+
)]
11+
#![allow(deprecated)]
12+
13+
#[stable(feature = "pthread_t", since = "1.8.0")]
14+
pub type pthread_t = libc::pthread_t;
15+
16+
#[stable(feature = "raw_ext", since = "1.1.0")]
17+
pub type blkcnt_t = libc::blkcnt_t;
18+
19+
#[stable(feature = "raw_ext", since = "1.1.0")]
20+
pub type blksize_t = libc::blksize_t;
21+
#[stable(feature = "raw_ext", since = "1.1.0")]
22+
pub type dev_t = libc::dev_t;
23+
#[stable(feature = "raw_ext", since = "1.1.0")]
24+
pub type ino_t = libc::ino_t;
25+
#[stable(feature = "raw_ext", since = "1.1.0")]
26+
pub type mode_t = libc::mode_t;
27+
#[stable(feature = "raw_ext", since = "1.1.0")]
28+
pub type nlink_t = libc::nlink_t;
29+
#[stable(feature = "raw_ext", since = "1.1.0")]
30+
pub type off_t = libc::off_t;
31+
32+
#[stable(feature = "raw_ext", since = "1.1.0")]
33+
pub type time_t = libc::time_t;

std/src/os/unix/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ mod platform {
6969
pub use crate::os::netbsd::*;
7070
#[cfg(target_os = "nto")]
7171
pub use crate::os::nto::*;
72+
#[cfg(target_os = "nuttx")]
73+
pub use crate::os::nuttx::*;
7274
#[cfg(target_os = "openbsd")]
7375
pub use crate::os::openbsd::*;
7476
#[cfg(target_os = "redox")]

std/src/sys/alloc/unix.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ cfg_if::cfg_if! {
7171
}
7272
} else {
7373
#[inline]
74+
#[cfg_attr(target_os = "vxworks", allow(unused_unsafe))]
7475
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
7576
let mut out = ptr::null_mut();
7677
// We prefer posix_memalign over aligned_alloc since it is more widely available, and

std/src/sys/dbg.rs

Lines changed: 1 addition & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -105,84 +105,7 @@ mod os {
105105
}
106106
}
107107

108-
#[cfg(target_os = "linux")]
109-
mod os {
110-
use super::DebuggerPresence;
111-
use crate::fs::File;
112-
use crate::io::Read;
113-
114-
pub(super) fn is_debugger_present() -> Option<DebuggerPresence> {
115-
// This function is crafted with the following goals:
116-
// * Memory efficiency: It avoids crashing the panicking process due to
117-
// out-of-memory (OOM) conditions by not using large heap buffers or
118-
// allocating significant stack space, which could lead to stack overflow.
119-
// * Minimal binary size: The function uses a minimal set of facilities
120-
// from the standard library to avoid increasing the resulting binary size.
121-
//
122-
// To achieve these goals, the function does not use `[std::io::BufReader]`
123-
// and instead reads the file byte by byte using a sliding window approach.
124-
// It's important to note that the "/proc/self/status" pseudo-file is synthesized
125-
// by the Virtual File System (VFS), meaning it is not read from a slow or
126-
// non-volatile storage medium so buffering might not be as beneficial because
127-
// all data is read from memory, though this approach does incur a syscall for
128-
// each byte read.
129-
//
130-
// We cannot make assumptions about the file size or the position of the
131-
// target prefix ("TracerPid:"), so the function does not use
132-
// `[std::fs::read_to_string]` thus not employing UTF-8 to ASCII checking,
133-
// conversion, or parsing as we're looking for an ASCII prefix.
134-
//
135-
// These condiderations make the function deviate from the familiar concise pattern
136-
// of searching for a string in a text file.
137-
138-
fn read_byte(file: &mut File) -> Option<u8> {
139-
let mut buffer = [0];
140-
file.read_exact(&mut buffer).ok()?;
141-
Some(buffer[0])
142-
}
143-
144-
// The ASCII prefix of the datum we're interested in.
145-
const TRACER_PID: &[u8] = b"TracerPid:\t";
146-
147-
let mut file = File::open("/proc/self/status").ok()?;
148-
let mut matched = 0;
149-
150-
// Look for the `TRACER_PID` prefix.
151-
while let Some(byte) = read_byte(&mut file) {
152-
if byte == TRACER_PID[matched] {
153-
matched += 1;
154-
if matched == TRACER_PID.len() {
155-
break;
156-
}
157-
} else {
158-
matched = 0;
159-
}
160-
}
161-
162-
// Was the prefix found?
163-
if matched != TRACER_PID.len() {
164-
return None;
165-
}
166-
167-
// It was; get the ASCII representation of the first digit
168-
// of the PID. That is enough to see if there is a debugger
169-
// attached as the kernel does not pad the PID on the left
170-
// with the leading zeroes.
171-
let byte = read_byte(&mut file)?;
172-
if byte.is_ascii_digit() && byte != b'0' {
173-
Some(DebuggerPresence::Detected)
174-
} else {
175-
Some(DebuggerPresence::NotDetected)
176-
}
177-
}
178-
}
179-
180-
#[cfg(not(any(
181-
target_os = "windows",
182-
target_vendor = "apple",
183-
target_os = "freebsd",
184-
target_os = "linux"
185-
)))]
108+
#[cfg(not(any(target_os = "windows", target_vendor = "apple", target_os = "freebsd")))]
186109
mod os {
187110
pub(super) fn is_debugger_present() -> Option<super::DebuggerPresence> {
188111
None

std/src/sys/pal/unix/args.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl DoubleEndedIterator for Args {
113113
target_os = "nto",
114114
target_os = "hurd",
115115
target_os = "rtems",
116+
target_os = "nuttx",
116117
))]
117118
mod imp {
118119
use crate::ffi::c_char;

0 commit comments

Comments
 (0)