Skip to content

Commit 354ca44

Browse files
committed
fix cfgs
1 parent 6b4478a commit 354ca44

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/shims/unix/fd.rs

-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub trait FileDescription: std::fmt::Debug + Any {
3838

3939
/// Reads as much as possible into the given buffer from a given offset,
4040
/// and returns the number of bytes read.
41-
#[cfg(unix)]
4241
fn pread<'tcx>(
4342
&mut self,
4443
_communicate_allowed: bool,
@@ -51,7 +50,6 @@ pub trait FileDescription: std::fmt::Debug + Any {
5150

5251
/// Writes as much as possible from the given buffer starting at a given offset,
5352
/// and returns the number of bytes written.
54-
#[cfg(unix)]
5553
fn pwrite<'tcx>(
5654
&mut self,
5755
_communicate_allowed: bool,
@@ -490,7 +488,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
490488
this.try_unwrap_io_result(result)
491489
}
492490

493-
#[cfg(unix)]
494491
fn pread(
495492
&mut self,
496493
fd: i32,
@@ -559,7 +556,6 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
559556
}
560557
}
561558

562-
#[cfg(unix)]
563559
fn pwrite(
564560
&mut self,
565561
fd: i32,

src/shims/unix/foreign_items.rs

+24-12
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
105105
// Now, `result` is the value we return back to the program.
106106
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
107107
}
108-
#[cfg(unix)]
109108
"pread" => {
109+
if matches!(&*this.tcx.sess.target.os, "windows") {
110+
throw_unsup_format!(
111+
"`pread` is not supported on {}",
112+
this.tcx.sess.target.os
113+
);
114+
}
110115
let [fd, buf, count, offset] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
111116
let fd = this.read_scalar(fd)?.to_i32()?;
112117
let buf = this.read_pointer(buf)?;
@@ -115,8 +120,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
115120
let result = this.pread(fd, buf, count, offset)?;
116121
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
117122
}
118-
#[cfg(unix)]
119123
"pwrite" => {
124+
if matches!(&*this.tcx.sess.target.os, "windows") {
125+
throw_unsup_format!(
126+
"`pwrite` is not supported on {}",
127+
this.tcx.sess.target.os
128+
);
129+
}
120130
let [fd, buf, n, offset] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
121131
let fd = this.read_scalar(fd)?.to_i32()?;
122132
let buf = this.read_pointer(buf)?;
@@ -127,12 +137,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
127137
// Now, `result` is the value we return back to the program.
128138
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
129139
}
130-
#[cfg(any(
131-
all(target_os = "linux", not(target_env = "musl")),
132-
target_os = "android",
133-
target_os = "hurd"
134-
))]
135140
"pread64" => {
141+
if !matches!(&*this.tcx.sess.target.os, "linux" | "android" | "hurd") {
142+
throw_unsup_format!(
143+
"`pread64` is not supported on {}",
144+
this.tcx.sess.target.os
145+
);
146+
}
136147
let [fd, buf, count, offset] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
137148
let fd = this.read_scalar(fd)?.to_i32()?;
138149
let buf = this.read_pointer(buf)?;
@@ -141,12 +152,13 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
141152
let result = this.pread(fd, buf, count, offset)?;
142153
this.write_scalar(Scalar::from_target_isize(result, this), dest)?;
143154
}
144-
#[cfg(any(
145-
all(target_os = "linux", not(target_env = "musl")),
146-
target_os = "android",
147-
target_os = "hurd"
148-
))]
149155
"pwrite64" => {
156+
if !matches!(&*this.tcx.sess.target.os, "linux" | "android" | "hurd") {
157+
throw_unsup_format!(
158+
"`pwrite64` is not supported on {}",
159+
this.tcx.sess.target.os
160+
);
161+
}
150162
let [fd, buf, n, offset] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
151163
let fd = this.read_scalar(fd)?.to_i32()?;
152164
let buf = this.read_pointer(buf)?;

0 commit comments

Comments
 (0)