Skip to content

Commit 0398215

Browse files
committed
std: allow weak in item position on Apple platforms
1 parent 1b2c53a commit 0398215

File tree

1 file changed

+6
-5
lines changed
  • library/std/src/sys/pal/unix

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,16 @@ impl<F: Copy> ExternWeak<F> {
6363
}
6464

6565
pub(crate) macro dlsym {
66-
(fn $name:ident($($t:ty),*) -> $ret:ty) => (
67-
dlsym!(fn $name($($t),*) -> $ret, stringify!($name));
66+
($v:vis fn $name:ident($($t:ty),*) -> $ret:ty) => (
67+
dlsym!($v fn $name($($t),*) -> $ret, stringify!($name));
6868
),
69-
(fn $name:ident($($t:ty),*) -> $ret:ty, $sym:expr) => (
70-
static DLSYM: DlsymWeak<unsafe extern "C" fn($($t),*) -> $ret> =
69+
($v:vis fn $name:ident($($t:ty),*) -> $ret:ty, $sym:expr) => (
70+
#[allow(non_upper_case_globals)]
71+
$v static $name: DlsymWeak<unsafe extern "C" fn($($t),*) -> $ret> =
7172
DlsymWeak::new(concat!($sym, '\0'));
72-
let $name = &DLSYM;
7373
)
7474
}
75+
7576
pub(crate) struct DlsymWeak<F> {
7677
name: &'static str,
7778
func: AtomicPtr<libc::c_void>,

0 commit comments

Comments
 (0)