Change weak!
and linkat!
to macros 2.0
`weak!` is needed in a test in another module. With macros 1.0, importing `weak!` would require reordering module declarations in `std/src/lib.rs`, which is a bit too evil.
This commit is contained in:
parent
5022c0638d
commit
fd0cb0cdc2
8 changed files with 38 additions and 4 deletions
|
@ -21,7 +21,7 @@
|
||||||
use libc::{c_int, c_void, sighandler_t, size_t, ssize_t};
|
use libc::{c_int, c_void, sighandler_t, size_t, ssize_t};
|
||||||
use libc::{ftruncate, pread, pwrite};
|
use libc::{ftruncate, pread, pwrite};
|
||||||
|
|
||||||
use super::{cvt, cvt_r};
|
use super::{cvt, cvt_r, weak::weak};
|
||||||
use crate::io;
|
use crate::io;
|
||||||
|
|
||||||
// The `log2` and `log2f` functions apparently appeared in android-18, or at
|
// The `log2` and `log2f` functions apparently appeared in android-18, or at
|
||||||
|
|
|
@ -12,6 +12,15 @@ use crate::sys::time::SystemTime;
|
||||||
use crate::sys::{cvt, cvt_r};
|
use crate::sys::{cvt, cvt_r};
|
||||||
use crate::sys_common::{AsInner, FromInner};
|
use crate::sys_common::{AsInner, FromInner};
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
all(target_os = "linux", target_env = "gnu"),
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "ios",
|
||||||
|
))]
|
||||||
|
use crate::sys::weak::syscall;
|
||||||
|
#[cfg(target_os = "macos")]
|
||||||
|
use crate::sys::weak::weak;
|
||||||
|
|
||||||
use libc::{c_int, mode_t};
|
use libc::{c_int, mode_t};
|
||||||
|
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
|
|
|
@ -61,6 +61,7 @@ use crate::process::{ChildStderr, ChildStdin, ChildStdout};
|
||||||
use crate::ptr;
|
use crate::ptr;
|
||||||
use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
use crate::sync::atomic::{AtomicBool, AtomicU8, Ordering};
|
||||||
use crate::sys::cvt;
|
use crate::sys::cvt;
|
||||||
|
use crate::sys::weak::syscall;
|
||||||
use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
|
use libc::{EBADF, EINVAL, ENOSYS, EOPNOTSUPP, EOVERFLOW, EPERM, EXDEV};
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|
|
@ -23,6 +23,9 @@ use crate::sys::memchr;
|
||||||
use crate::sys_common::rwlock::{StaticRWLock, StaticRWLockReadGuard};
|
use crate::sys_common::rwlock::{StaticRWLock, StaticRWLockReadGuard};
|
||||||
use crate::vec;
|
use crate::vec;
|
||||||
|
|
||||||
|
#[cfg(all(target_env = "gnu", not(target_os = "vxworks")))]
|
||||||
|
use crate::sys::weak::weak;
|
||||||
|
|
||||||
use libc::{c_char, c_int, c_void};
|
use libc::{c_char, c_int, c_void};
|
||||||
|
|
||||||
const TMPBUF_SZ: usize = 128;
|
const TMPBUF_SZ: usize = 128;
|
||||||
|
|
|
@ -9,6 +9,14 @@ use crate::sys;
|
||||||
use crate::sys::cvt;
|
use crate::sys::cvt;
|
||||||
use crate::sys::process::process_common::*;
|
use crate::sys::process::process_common::*;
|
||||||
|
|
||||||
|
#[cfg(any(
|
||||||
|
target_os = "macos",
|
||||||
|
target_os = "freebsd",
|
||||||
|
all(target_os = "linux", target_env = "gnu"),
|
||||||
|
all(target_os = "linux", target_env = "musl"),
|
||||||
|
))]
|
||||||
|
use crate::sys::weak::weak;
|
||||||
|
|
||||||
#[cfg(target_os = "vxworks")]
|
#[cfg(target_os = "vxworks")]
|
||||||
use libc::RTP_ID as pid_t;
|
use libc::RTP_ID as pid_t;
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@ mod imp {
|
||||||
use crate::fs::File;
|
use crate::fs::File;
|
||||||
use crate::io::Read;
|
use crate::io::Read;
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
|
use crate::sys::weak::syscall;
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
|
fn getrandom(buf: &mut [u8]) -> libc::ssize_t {
|
||||||
// A weak symbol allows interposition, e.g. for perf measurements that want to
|
// A weak symbol allows interposition, e.g. for perf measurements that want to
|
||||||
|
@ -108,6 +111,7 @@ mod imp {
|
||||||
use crate::fs::File;
|
use crate::fs::File;
|
||||||
use crate::io::Read;
|
use crate::io::Read;
|
||||||
use crate::sys::os::errno;
|
use crate::sys::os::errno;
|
||||||
|
use crate::sys::weak::weak;
|
||||||
use libc::{c_int, c_void, size_t};
|
use libc::{c_int, c_void, size_t};
|
||||||
|
|
||||||
fn getentropy_fill_bytes(v: &mut [u8]) -> bool {
|
fn getentropy_fill_bytes(v: &mut [u8]) -> bool {
|
||||||
|
|
|
@ -7,6 +7,8 @@ use crate::ptr;
|
||||||
use crate::sys::{os, stack_overflow};
|
use crate::sys::{os, stack_overflow};
|
||||||
use crate::time::Duration;
|
use crate::time::Duration;
|
||||||
|
|
||||||
|
#[cfg(any(target_os = "linux", target_os = "solaris", target_os = "illumos"))]
|
||||||
|
use crate::sys::weak::weak;
|
||||||
#[cfg(not(any(target_os = "l4re", target_os = "vxworks")))]
|
#[cfg(not(any(target_os = "l4re", target_os = "vxworks")))]
|
||||||
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
|
pub const DEFAULT_MIN_STACK_SIZE: usize = 2 * 1024 * 1024;
|
||||||
#[cfg(target_os = "l4re")]
|
#[cfg(target_os = "l4re")]
|
||||||
|
|
|
@ -26,8 +26,11 @@ use crate::marker;
|
||||||
use crate::mem;
|
use crate::mem;
|
||||||
use crate::sync::atomic::{self, AtomicUsize, Ordering};
|
use crate::sync::atomic::{self, AtomicUsize, Ordering};
|
||||||
|
|
||||||
macro_rules! weak {
|
// Temporary null documentation to work around #57569 until the fix is beta
|
||||||
|
#[cfg_attr(bootstrap, doc = "")]
|
||||||
|
pub(crate) macro weak {
|
||||||
(fn $name:ident($($t:ty),*) -> $ret:ty) => (
|
(fn $name:ident($($t:ty),*) -> $ret:ty) => (
|
||||||
|
#[allow(non_upper_case_globals)]
|
||||||
static $name: crate::sys::weak::Weak<unsafe extern "C" fn($($t),*) -> $ret> =
|
static $name: crate::sys::weak::Weak<unsafe extern "C" fn($($t),*) -> $ret> =
|
||||||
crate::sys::weak::Weak::new(concat!(stringify!($name), '\0'));
|
crate::sys::weak::Weak::new(concat!(stringify!($name), '\0'));
|
||||||
)
|
)
|
||||||
|
@ -100,8 +103,10 @@ unsafe fn fetch(name: &str) -> usize {
|
||||||
libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr()) as usize
|
libc::dlsym(libc::RTLD_DEFAULT, name.as_ptr()) as usize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Temporary null documentation to work around #57569 until the fix is beta
|
||||||
|
#[cfg_attr(bootstrap, doc = "")]
|
||||||
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
#[cfg(not(any(target_os = "linux", target_os = "android")))]
|
||||||
macro_rules! syscall {
|
pub(crate) macro syscall {
|
||||||
(fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
|
(fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
|
||||||
unsafe fn $name($($arg_name: $t),*) -> $ret {
|
unsafe fn $name($($arg_name: $t),*) -> $ret {
|
||||||
use super::os;
|
use super::os;
|
||||||
|
@ -118,10 +123,12 @@ macro_rules! syscall {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg_attr(bootstrap, doc = "")]
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
macro_rules! syscall {
|
pub(crate) macro syscall {
|
||||||
(fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
|
(fn $name:ident($($arg_name:ident: $t:ty),*) -> $ret:ty) => (
|
||||||
unsafe fn $name($($arg_name:$t),*) -> $ret {
|
unsafe fn $name($($arg_name:$t),*) -> $ret {
|
||||||
|
use weak;
|
||||||
// This looks like a hack, but concat_idents only accepts idents
|
// This looks like a hack, but concat_idents only accepts idents
|
||||||
// (not paths).
|
// (not paths).
|
||||||
use libc::*;
|
use libc::*;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue