Skip to content

Commit 1c82aa7

Browse files
committed
std: allow weak in item position on Apple platforms
1 parent 8e0b68e commit 1c82aa7

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

library/std/src/sys/fd/unix.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,9 +326,9 @@ impl FileDesc {
326326
);
327327

328328
match preadv.get() {
329-
Some(preadv) => {
329+
Some(read) => {
330330
let ret = cvt(unsafe {
331-
preadv(
331+
read(
332332
self.as_raw_fd(),
333333
bufs.as_mut_ptr() as *mut libc::iovec as *const libc::iovec,
334334
cmp::min(bufs.len(), max_iov()) as libc::c_int,
@@ -532,9 +532,9 @@ impl FileDesc {
532532
);
533533

534534
match pwritev.get() {
535-
Some(pwritev) => {
535+
Some(read) => {
536536
let ret = cvt(unsafe {
537-
pwritev(
537+
read(
538538
self.as_raw_fd(),
539539
bufs.as_ptr() as *const libc::iovec,
540540
cmp::min(bufs.len(), max_iov()) as libc::c_int,

library/std/src/sys/pal/unix/weak/dlsym.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ use crate::{mem, ptr};
88
mod tests;
99

1010
pub(crate) macro weak {
11-
(fn $name:ident($($param:ident : $t:ty),* $(,)?) -> $ret:ty;) => (
12-
static DLSYM: DlsymWeak<unsafe extern "C" fn($($t),*) -> $ret> = {
11+
($v:vis fn $name:ident($($param:ident : $t:ty),* $(,)?) -> $ret:ty;) => {
12+
#[allow(non_upper_case_globals)]
13+
$v static $name: DlsymWeak<unsafe extern "C" fn($($t),*) -> $ret> = {
1314
let Ok(name) = CStr::from_bytes_with_nul(concat!(stringify!($name), '\0').as_bytes()) else {
1415
panic!("symbol name may not contain NUL")
1516
};
@@ -20,9 +21,7 @@ pub(crate) macro weak {
2021
// the function pointer be unsafe.
2122
unsafe { DlsymWeak::new(name) }
2223
};
23-
24-
let $name = &DLSYM;
25-
)
24+
}
2625
}
2726

2827
pub(crate) struct DlsymWeak<F> {

library/std/src/sys/pal/unix/weak/tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ fn weak_existing() {
1111
fn strlen(cs: *const c_char) -> usize;
1212
}
1313

14-
let strlen = strlen.get().unwrap();
15-
assert_eq!(unsafe { strlen(TEST_STRING.as_ptr()) }, TEST_STRING.count_bytes());
14+
let len = strlen.get().unwrap();
15+
assert_eq!(unsafe { len(TEST_STRING.as_ptr()) }, TEST_STRING.count_bytes());
1616
}
1717

1818
#[test]

0 commit comments

Comments
 (0)