Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c9f7324

Browse files
committedFeb 3, 2025
std: allow weak in item position on Apple platforms
1 parent a5db378 commit c9f7324

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
 

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -284,9 +284,9 @@ impl FileDesc {
284284
super::weak::weak!(fn preadv(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize);
285285

286286
match preadv.get() {
287-
Some(preadv) => {
287+
Some(read) => {
288288
let ret = cvt(unsafe {
289-
preadv(
289+
read(
290290
self.as_raw_fd(),
291291
bufs.as_mut_ptr() as *mut libc::iovec as *const libc::iovec,
292292
cmp::min(bufs.len(), max_iov()) as libc::c_int,
@@ -477,9 +477,9 @@ impl FileDesc {
477477
super::weak::weak!(fn pwritev(libc::c_int, *const libc::iovec, libc::c_int, off64_t) -> isize);
478478

479479
match pwritev.get() {
480-
Some(pwritev) => {
480+
Some(read) => {
481481
let ret = cvt(unsafe {
482-
pwritev(
482+
read(
483483
self.as_raw_fd(),
484484
bufs.as_ptr() as *const libc::iovec,
485485
cmp::min(bufs.len(), max_iov()) as libc::c_int,

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -62,15 +62,16 @@ impl<F: Copy> ExternWeak<F> {
6262
}
6363

6464
pub(crate) macro dlsym {
65-
(fn $name:ident($($t:ty),*) -> $ret:ty) => (
66-
dlsym!(fn $name($($t),*) -> $ret, stringify!($name));
65+
($v:vis fn $name:ident($($t:ty),*) -> $ret:ty) => (
66+
dlsym!($v fn $name($($t),*) -> $ret, stringify!($name));
6767
),
68-
(fn $name:ident($($t:ty),*) -> $ret:ty, $sym:expr) => (
69-
static DLSYM: DlsymWeak<unsafe extern "C" fn($($t),*) -> $ret> =
68+
($v:vis fn $name:ident($($t:ty),*) -> $ret:ty, $sym:expr) => (
69+
#[allow(non_upper_case_globals)]
70+
$v static $name: DlsymWeak<unsafe extern "C" fn($($t),*) -> $ret> =
7071
DlsymWeak::new(concat!($sym, '\0'));
71-
let $name = &DLSYM;
7272
)
7373
}
74+
7475
pub(crate) struct DlsymWeak<F> {
7576
name: &'static str,
7677
func: AtomicPtr<libc::c_void>,

0 commit comments

Comments
 (0)
Failed to load comments.