mirror of
https://github.com/rust-lang/rust
synced 2024-10-04 15:50:51 +00:00
Library changes for Apple WatchOS
This commit is contained in:
parent
c3605f8c80
commit
439d64a83c
|
@ -131,7 +131,7 @@ fn rust_exception_class() -> uw::_Unwind_Exception_Class {
|
|||
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "netbsd")))] {
|
||||
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "watchos"), not(target_os = "netbsd")))] {
|
||||
// ARM EHABI personality routine.
|
||||
// https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
|
||||
//
|
||||
|
|
|
@ -15,6 +15,7 @@ fn main() {
|
|||
|| target.contains("illumos")
|
||||
|| target.contains("apple-darwin")
|
||||
|| target.contains("apple-ios")
|
||||
|| target.contains("apple-watchos")
|
||||
|| target.contains("uwp")
|
||||
|| target.contains("windows")
|
||||
|| target.contains("fuchsia")
|
||||
|
|
|
@ -141,7 +141,6 @@ pub mod windows {}
|
|||
pub mod redox;
|
||||
#[cfg(target_os = "solaris")]
|
||||
pub mod solaris;
|
||||
|
||||
#[cfg(target_os = "solid_asp3")]
|
||||
pub mod solid;
|
||||
#[cfg(target_os = "vxworks")]
|
||||
|
|
|
@ -90,6 +90,7 @@ mod platform {
|
|||
target_os = "dragonfly",
|
||||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
|
@ -30,6 +31,7 @@
|
|||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
|
@ -238,6 +240,7 @@ pub fn peer_addr(&self) -> io::Result<SocketAddr> {
|
|||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
|
|
|
@ -36,7 +36,7 @@ pub struct UCred {
|
|||
))]
|
||||
pub use self::impl_bsd::peer_cred;
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios",))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
pub use self::impl_mac::peer_cred;
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
|
@ -97,7 +97,7 @@ pub fn peer_cred(socket: &UnixStream) -> io::Result<UCred> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios",))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
pub mod impl_mac {
|
||||
use super::UCred;
|
||||
use crate::os::unix::io::AsRawFd;
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
target_os = "freebsd",
|
||||
target_os = "ios",
|
||||
target_os = "macos",
|
||||
target_os = "watchos",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
fn test_socket_pair() {
|
||||
|
@ -25,7 +26,7 @@ fn test_socket_pair() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "ios", target_os = "macos",))]
|
||||
#[cfg(any(target_os = "linux", target_os = "ios", target_os = "macos", target_os = "watchos"))]
|
||||
fn test_socket_pair_pids(arg: Type) -> RetType {
|
||||
// Create two connected sockets and get their peer credentials.
|
||||
let (sock_a, sock_b) = UnixStream::pair().unwrap();
|
||||
|
|
|
@ -151,7 +151,7 @@ fn clone() -> Vec<OsString> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
mod imp {
|
||||
use super::Args;
|
||||
use crate::ffi::CStr;
|
||||
|
@ -192,7 +192,7 @@ pub fn args() -> Args {
|
|||
// for i in (0..[args count])
|
||||
// res.push([args objectAtIndex:i])
|
||||
// res
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(target_os = "ios", target_os = "watchos"))]
|
||||
pub fn args() -> Args {
|
||||
use crate::ffi::OsString;
|
||||
use crate::mem;
|
||||
|
|
|
@ -31,6 +31,17 @@ pub mod os {
|
|||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "watchos")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &str = "unix";
|
||||
pub const OS: &str = "watchos";
|
||||
pub const DLL_PREFIX: &str = "lib";
|
||||
pub const DLL_SUFFIX: &str = ".dylib";
|
||||
pub const DLL_EXTENSION: &str = "dylib";
|
||||
pub const EXE_SUFFIX: &str = "";
|
||||
pub const EXE_EXTENSION: &str = "";
|
||||
}
|
||||
|
||||
#[cfg(target_os = "freebsd")]
|
||||
pub mod os {
|
||||
pub const FAMILY: &str = "unix";
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "watchos",
|
||||
))]
|
||||
const fn max_iov() -> usize {
|
||||
libc::IOV_MAX as usize
|
||||
|
@ -67,7 +68,8 @@ const fn max_iov() -> usize {
|
|||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "horizon"
|
||||
target_os = "horizon",
|
||||
target_os = "watchos",
|
||||
)))]
|
||||
const fn max_iov() -> usize {
|
||||
16 // The minimum value required by POSIX.
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
all(target_os = "linux", target_env = "gnu"),
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
))]
|
||||
use crate::sys::weak::syscall;
|
||||
#[cfg(target_os = "macos")]
|
||||
|
@ -27,6 +28,7 @@
|
|||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
all(target_os = "linux", target_env = "gnu")
|
||||
))]
|
||||
use libc::c_char;
|
||||
|
@ -443,7 +445,8 @@ pub fn accessed(&self) -> io::Result<SystemTime> {
|
|||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "macos",
|
||||
target_os = "ios"
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
))]
|
||||
pub fn created(&self) -> io::Result<SystemTime> {
|
||||
Ok(SystemTime::new(self.stat.st_birthtime as i64, self.stat.st_birthtime_nsec as i64))
|
||||
|
@ -453,7 +456,8 @@ pub fn created(&self) -> io::Result<SystemTime> {
|
|||
target_os = "freebsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "macos",
|
||||
target_os = "ios"
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
)))]
|
||||
pub fn created(&self) -> io::Result<SystemTime> {
|
||||
cfg_has_statx! {
|
||||
|
@ -707,6 +711,7 @@ pub fn file_type(&self) -> io::Result<FileType> {
|
|||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "linux",
|
||||
target_os = "emscripten",
|
||||
target_os = "android",
|
||||
|
@ -737,6 +742,7 @@ pub fn ino(&self) -> u64 {
|
|||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
|
@ -754,6 +760,7 @@ fn name_bytes(&self) -> &[u8] {
|
|||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd",
|
||||
target_os = "freebsd",
|
||||
|
@ -911,11 +918,11 @@ pub fn fsync(&self) -> io::Result<()> {
|
|||
cvt_r(|| unsafe { os_fsync(self.as_raw_fd()) })?;
|
||||
return Ok(());
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
libc::fcntl(fd, libc::F_FULLFSYNC)
|
||||
}
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos")))]
|
||||
unsafe fn os_fsync(fd: c_int) -> c_int {
|
||||
libc::fsync(fd)
|
||||
}
|
||||
|
@ -925,7 +932,7 @@ pub fn datasync(&self) -> io::Result<()> {
|
|||
cvt_r(|| unsafe { os_datasync(self.as_raw_fd()) })?;
|
||||
return Ok(());
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
unsafe fn os_datasync(fd: c_int) -> c_int {
|
||||
libc::fcntl(fd, libc::F_FULLFSYNC)
|
||||
}
|
||||
|
@ -946,7 +953,8 @@ unsafe fn os_datasync(fd: c_int) -> c_int {
|
|||
target_os = "linux",
|
||||
target_os = "macos",
|
||||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
target_os = "openbsd",
|
||||
target_os = "watchos",
|
||||
)))]
|
||||
unsafe fn os_datasync(fd: c_int) -> c_int {
|
||||
libc::fsync(fd)
|
||||
|
@ -1396,7 +1404,8 @@ fn open_to_and_set_permissions(
|
|||
target_os = "linux",
|
||||
target_os = "android",
|
||||
target_os = "macos",
|
||||
target_os = "ios"
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
)))]
|
||||
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
let (mut reader, reader_metadata) = open_from(from)?;
|
||||
|
@ -1423,7 +1432,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
|
||||
use crate::sync::atomic::{AtomicBool, Ordering};
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@ pub const fn new() -> Condvar {
|
|||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox"
|
||||
|
@ -58,6 +59,7 @@ unsafe fn init(&mut self) {
|
|||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox",
|
||||
|
@ -102,6 +104,7 @@ pub unsafe fn wait(&self, mutex: &Mutex) {
|
|||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "android",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon"
|
||||
|
@ -135,6 +138,7 @@ pub unsafe fn wait_timeout(&self, mutex: &Mutex, dur: Duration) -> bool {
|
|||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "android",
|
||||
target_os = "espidf",
|
||||
target_os = "horizon"
|
||||
|
|
|
@ -86,6 +86,7 @@ unsafe fn sanitize_standard_fds() {
|
|||
// The poll on Darwin doesn't set POLLNVAL for closed fds.
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "redox",
|
||||
target_os = "l4re",
|
||||
target_os = "horizon",
|
||||
|
@ -329,7 +330,7 @@ pub fn abort_internal() -> ! {
|
|||
// See #41582 and https://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
|
||||
#[link(name = "resolv")]
|
||||
extern "C" {}
|
||||
} else if #[cfg(target_os = "ios")] {
|
||||
} else if #[cfg(any(target_os = "ios", target_os = "watchos"))] {
|
||||
#[link(name = "System")]
|
||||
#[link(name = "objc")]
|
||||
#[link(name = "Security", kind = "framework")]
|
||||
|
|
|
@ -61,7 +61,7 @@
|
|||
)]
|
||||
#[cfg_attr(any(target_os = "solaris", target_os = "illumos"), link_name = "___errno")]
|
||||
#[cfg_attr(
|
||||
any(target_os = "macos", target_os = "ios", target_os = "freebsd"),
|
||||
any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "watchos"),
|
||||
link_name = "__error"
|
||||
)]
|
||||
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
|
||||
|
@ -361,7 +361,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
pub fn current_exe() -> io::Result<PathBuf> {
|
||||
unsafe {
|
||||
let mut sz: u32 = 0;
|
||||
|
@ -598,6 +598,7 @@ pub fn home_dir() -> Option<PathBuf> {
|
|||
#[cfg(any(
|
||||
target_os = "android",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "emscripten",
|
||||
target_os = "redox",
|
||||
target_os = "vxworks",
|
||||
|
@ -610,6 +611,7 @@ unsafe fn fallback() -> Option<OsString> {
|
|||
#[cfg(not(any(
|
||||
target_os = "android",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "emscripten",
|
||||
target_os = "redox",
|
||||
target_os = "vxworks",
|
||||
|
|
|
@ -14,6 +14,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
|
|||
unix,
|
||||
not(target_os = "macos"),
|
||||
not(target_os = "ios"),
|
||||
not(target_os = "watchos"),
|
||||
not(target_os = "openbsd"),
|
||||
not(target_os = "freebsd"),
|
||||
not(target_os = "netbsd"),
|
||||
|
@ -195,7 +196,7 @@ pub fn fill_bytes(v: &mut [u8]) {
|
|||
// once per thread in `hashmap_random_keys`. Therefore `SecRandomCopyBytes` is
|
||||
// only used on iOS where direct access to `/dev/urandom` is blocked by the
|
||||
// sandbox.
|
||||
#[cfg(target_os = "ios")]
|
||||
#[cfg(any(target_os = "ios", target_os = "watchos"))]
|
||||
mod imp {
|
||||
use crate::io;
|
||||
use crate::ptr;
|
||||
|
|
|
@ -139,7 +139,7 @@ pub fn set_name(name: &CStr) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
pub fn set_name(name: &CStr) {
|
||||
unsafe {
|
||||
libc::pthread_setname_np(name.as_ptr());
|
||||
|
|
|
@ -51,7 +51,12 @@ unsafe fn wait_timeout(
|
|||
) {
|
||||
// Use the system clock on systems that do not support pthread_condattr_setclock.
|
||||
// This unfortunately results in problems when the system time changes.
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "espidf"))]
|
||||
#[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "espidf"
|
||||
))]
|
||||
let (now, dur) = {
|
||||
use super::time::SystemTime;
|
||||
use crate::cmp::min;
|
||||
|
@ -72,7 +77,12 @@ unsafe fn wait_timeout(
|
|||
(now, dur)
|
||||
};
|
||||
// Use the monotonic clock on other systems.
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "espidf")))]
|
||||
#[cfg(not(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "espidf"
|
||||
)))]
|
||||
let (now, dur) = {
|
||||
use super::time::Timespec;
|
||||
|
||||
|
@ -110,6 +120,7 @@ pub unsafe fn new(parker: *mut Parker) {
|
|||
if #[cfg(any(
|
||||
target_os = "macos",
|
||||
target_os = "ios",
|
||||
target_os = "watchos",
|
||||
target_os = "l4re",
|
||||
target_os = "android",
|
||||
target_os = "redox"
|
||||
|
|
|
@ -141,7 +141,7 @@ fn from(t: libc::timespec) -> Timespec {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
|
||||
mod inner {
|
||||
use crate::sync::atomic::{AtomicU64, Ordering};
|
||||
use crate::sys::cvt;
|
||||
|
@ -257,7 +257,7 @@ fn info_from_bits(bits: u64) -> mach_timebase_info {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios")))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos")))]
|
||||
mod inner {
|
||||
use crate::fmt;
|
||||
use crate::mem::MaybeUninit;
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(
|
||||
target_os = "dragonfly", target_os = "freebsd",
|
||||
target_os = "ios", target_os = "macos",
|
||||
target_os = "ios", target_os = "macos", target_os = "watchos",
|
||||
target_os = "openbsd", target_os = "netbsd", target_os = "illumos",
|
||||
target_os = "solaris", target_os = "haiku", target_os = "l4re"))] {
|
||||
use crate::sys::net::netc::IPV6_JOIN_GROUP as IPV6_ADD_MEMBERSHIP;
|
||||
|
|
|
@ -30,10 +30,10 @@ pub enum _Unwind_Reason_Code {
|
|||
#[cfg(target_arch = "x86_64")]
|
||||
pub const unwinder_private_data_size: usize = 6;
|
||||
|
||||
#[cfg(all(target_arch = "arm", not(target_os = "ios")))]
|
||||
#[cfg(all(target_arch = "arm", not(any(target_os = "ios", target_os = "watchos"))))]
|
||||
pub const unwinder_private_data_size: usize = 20;
|
||||
|
||||
#[cfg(all(target_arch = "arm", target_os = "ios"))]
|
||||
#[cfg(all(target_arch = "arm", any(target_os = "ios", target_os = "watchos")))]
|
||||
pub const unwinder_private_data_size: usize = 5;
|
||||
|
||||
#[cfg(all(target_arch = "aarch64", target_pointer_width = "64"))]
|
||||
|
@ -105,7 +105,7 @@ pub enum _Unwind_Context {}
|
|||
}
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(any(target_os = "ios", target_os = "netbsd", not(target_arch = "arm")))] {
|
||||
if #[cfg(any(target_os = "ios", target_os = "watchos", target_os = "netbsd", not(target_arch = "arm")))] {
|
||||
// Not ARM EHABI
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
|
Loading…
Reference in a new issue