Skip to content

Commit ef6b970

Browse files
committed
wip: Support Apple tvOS in libstd
1 parent 1716932 commit ef6b970

File tree

21 files changed

+84
-22
lines changed

21 files changed

+84
-22
lines changed

library/std/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ fn main() {
1515
|| target.contains("illumos")
1616
|| target.contains("apple-darwin")
1717
|| target.contains("apple-ios")
18+
|| target.contains("apple-tvos")
1819
|| target.contains("apple-watchos")
1920
|| target.contains("uwp")
2021
|| target.contains("windows")
@@ -42,7 +43,6 @@ fn main() {
4243
// - mipsel-sony-psp
4344
// - nvptx64-nvidia-cuda
4445
// - arch=avr
45-
// - tvos (aarch64-apple-tvos, x86_64-apple-tvos)
4646
// - uefi (x86_64-unknown-uefi, i686-unknown-uefi)
4747
// - JSON targets
4848
// - Any new targets that have not been explicitly added above.

library/std/src/os/ios/fs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use crate::fs::Metadata;
44
use crate::sys_common::AsInner;
55

66
#[allow(deprecated)]
7-
use crate::os::ios::raw;
7+
use super::raw;
88

99
/// OS-specific extensions to [`fs::Metadata`].
1010
///

library/std/src/os/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ pub mod redox;
137137
pub mod solaris;
138138
#[cfg(target_os = "solid_asp3")]
139139
pub mod solid;
140+
#[cfg(target_os = "tvos")]
141+
#[path = "ios/mod.rs"]
142+
pub(crate) mod tvos;
140143
#[cfg(target_os = "vxworks")]
141144
pub mod vxworks;
142145
#[cfg(target_os = "watchos")]

library/std/src/os/unix/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ mod platform {
7373
pub use crate::os::redox::*;
7474
#[cfg(target_os = "solaris")]
7575
pub use crate::os::solaris::*;
76+
#[cfg(target_os = "tvos")]
77+
pub use crate::os::tvos::*;
7678
#[cfg(target_os = "vxworks")]
7779
pub use crate::os::vxworks::*;
7880
#[cfg(target_os = "watchos")]
@@ -94,6 +96,7 @@ pub mod thread;
9496
target_os = "dragonfly",
9597
target_os = "freebsd",
9698
target_os = "ios",
99+
target_os = "tvos",
97100
target_os = "watchos",
98101
target_os = "macos",
99102
target_os = "netbsd",

library/std/src/os/unix/net/stream.rs

+3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ use crate::os::unix::io::{AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, Owned
1111
target_os = "dragonfly",
1212
target_os = "freebsd",
1313
target_os = "ios",
14+
target_os = "tvos",
1415
target_os = "macos",
1516
target_os = "watchos",
1617
target_os = "netbsd",
@@ -30,6 +31,7 @@ use crate::time::Duration;
3031
target_os = "dragonfly",
3132
target_os = "freebsd",
3233
target_os = "ios",
34+
target_os = "tvos",
3335
target_os = "macos",
3436
target_os = "watchos",
3537
target_os = "netbsd",
@@ -239,6 +241,7 @@ impl UnixStream {
239241
target_os = "dragonfly",
240242
target_os = "freebsd",
241243
target_os = "ios",
244+
target_os = "tvos",
242245
target_os = "macos",
243246
target_os = "watchos",
244247
target_os = "netbsd",

library/std/src/os/unix/ucred.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub use self::impl_linux::peer_cred;
3636
))]
3737
pub use self::impl_bsd::peer_cred;
3838

39-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
39+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
4040
pub use self::impl_mac::peer_cred;
4141

4242
#[cfg(any(target_os = "linux", target_os = "android"))]
@@ -98,7 +98,7 @@ pub mod impl_bsd {
9898
}
9999
}
100100

101-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
101+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
102102
pub mod impl_mac {
103103
use super::UCred;
104104
use crate::os::unix::io::AsRawFd;

library/std/src/os/unix/ucred/tests.rs

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use libc::{getegid, geteuid, getpid};
88
target_os = "dragonfly",
99
target_os = "freebsd",
1010
target_os = "ios",
11+
target_os = "tvos",
1112
target_os = "macos",
1213
target_os = "watchos",
1314
target_os = "openbsd"

library/std/src/personality/gcc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const UNWIND_DATA_REG: (i32, i32) = (10, 11); // x10, x11
8282
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
8383

8484
cfg_if::cfg_if! {
85-
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "watchos"), not(target_os = "netbsd")))] {
85+
if #[cfg(all(target_arch = "arm", not(target_os = "ios"), not(target_os = "tvos"), not(target_os = "watchos"), not(target_os = "netbsd")))] {
8686
// ARM EHABI personality routine.
8787
// https://infocenter.arm.com/help/topic/com.arm.doc.ihi0038b/IHI0038B_ehabi.pdf
8888
//

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ mod imp {
168168
}
169169
}
170170

171-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
171+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
172172
mod imp {
173173
use super::Args;
174174
use crate::ffi::CStr;
@@ -209,7 +209,7 @@ mod imp {
209209
// for i in (0..[args count])
210210
// res.push([args objectAtIndex:i])
211211
// res
212-
#[cfg(any(target_os = "ios", target_os = "watchos"))]
212+
#[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))]
213213
pub fn args() -> Args {
214214
use crate::ffi::OsString;
215215
use crate::mem;

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

+11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ pub mod os {
3131
pub const EXE_EXTENSION: &str = "";
3232
}
3333

34+
#[cfg(target_os = "tvos")]
35+
pub mod os {
36+
pub const FAMILY: &str = "unix";
37+
pub const OS: &str = "tvos";
38+
pub const DLL_PREFIX: &str = "lib";
39+
pub const DLL_SUFFIX: &str = ".dylib";
40+
pub const DLL_EXTENSION: &str = "dylib";
41+
pub const EXE_SUFFIX: &str = "";
42+
pub const EXE_EXTENSION: &str = "";
43+
}
44+
3445
#[cfg(target_os = "watchos")]
3546
pub mod os {
3647
pub const FAMILY: &str = "unix";

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

+28-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
3131
all(target_os = "linux", target_env = "gnu"),
3232
target_os = "macos",
3333
target_os = "ios",
34+
target_os = "tvos",
3435
target_os = "watchos",
3536
))]
3637
use crate::sys::weak::syscall;
@@ -42,6 +43,7 @@ use libc::{c_int, mode_t};
4243
#[cfg(any(
4344
target_os = "macos",
4445
target_os = "ios",
46+
target_os = "tvos",
4547
target_os = "watchos",
4648
all(target_os = "linux", target_env = "gnu")
4749
))]
@@ -495,6 +497,7 @@ impl FileAttr {
495497
target_os = "openbsd",
496498
target_os = "macos",
497499
target_os = "ios",
500+
target_os = "tvos",
498501
target_os = "watchos",
499502
))]
500503
pub fn created(&self) -> io::Result<SystemTime> {
@@ -506,6 +509,7 @@ impl FileAttr {
506509
target_os = "openbsd",
507510
target_os = "macos",
508511
target_os = "ios",
512+
target_os = "tvos",
509513
target_os = "watchos",
510514
)))]
511515
pub fn created(&self) -> io::Result<SystemTime> {
@@ -851,6 +855,7 @@ impl DirEntry {
851855
#[cfg(any(
852856
target_os = "macos",
853857
target_os = "ios",
858+
target_os = "tvos",
854859
target_os = "watchos",
855860
target_os = "linux",
856861
target_os = "emscripten",
@@ -883,6 +888,7 @@ impl DirEntry {
883888
#[cfg(any(
884889
target_os = "macos",
885890
target_os = "ios",
891+
target_os = "tvos",
886892
target_os = "watchos",
887893
target_os = "netbsd",
888894
target_os = "openbsd",
@@ -901,6 +907,7 @@ impl DirEntry {
901907
#[cfg(not(any(
902908
target_os = "macos",
903909
target_os = "ios",
910+
target_os = "tvos",
904911
target_os = "watchos",
905912
target_os = "netbsd",
906913
target_os = "openbsd",
@@ -1060,11 +1067,21 @@ impl File {
10601067
cvt_r(|| unsafe { os_fsync(self.as_raw_fd()) })?;
10611068
return Ok(());
10621069

1063-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
1070+
#[cfg(any(
1071+
target_os = "macos",
1072+
target_os = "ios",
1073+
target_os = "tvos",
1074+
target_os = "watchos",
1075+
))]
10641076
unsafe fn os_fsync(fd: c_int) -> c_int {
10651077
libc::fcntl(fd, libc::F_FULLFSYNC)
10661078
}
1067-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos")))]
1079+
#[cfg(not(any(
1080+
target_os = "macos",
1081+
target_os = "ios",
1082+
target_os = "tvos",
1083+
target_os = "watchos",
1084+
)))]
10681085
unsafe fn os_fsync(fd: c_int) -> c_int {
10691086
libc::fsync(fd)
10701087
}
@@ -1074,7 +1091,12 @@ impl File {
10741091
cvt_r(|| unsafe { os_datasync(self.as_raw_fd()) })?;
10751092
return Ok(());
10761093

1077-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
1094+
#[cfg(any(
1095+
target_os = "macos",
1096+
target_os = "ios",
1097+
target_os = "tvos",
1098+
target_os = "watchos",
1099+
))]
10781100
unsafe fn os_datasync(fd: c_int) -> c_int {
10791101
libc::fcntl(fd, libc::F_FULLFSYNC)
10801102
}
@@ -1093,6 +1115,7 @@ impl File {
10931115
target_os = "android",
10941116
target_os = "freebsd",
10951117
target_os = "ios",
1118+
target_os = "tvos",
10961119
target_os = "linux",
10971120
target_os = "macos",
10981121
target_os = "netbsd",
@@ -1627,6 +1650,7 @@ fn open_to_and_set_permissions(
16271650
target_os = "android",
16281651
target_os = "macos",
16291652
target_os = "ios",
1653+
target_os = "tvos",
16301654
target_os = "watchos",
16311655
)))]
16321656
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
@@ -1654,7 +1678,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
16541678
}
16551679
}
16561680

1657-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
1681+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
16581682
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
16591683
use crate::sync::atomic::{AtomicBool, Ordering};
16601684

library/std/src/sys/unix/locks/pthread_condvar.rs

+2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ impl Condvar {
124124
#[cfg(not(any(
125125
target_os = "macos",
126126
target_os = "ios",
127+
target_os = "tvos",
127128
target_os = "watchos",
128129
target_os = "android",
129130
target_os = "espidf",
@@ -158,6 +159,7 @@ impl Condvar {
158159
#[cfg(any(
159160
target_os = "macos",
160161
target_os = "ios",
162+
target_os = "tvos",
161163
target_os = "watchos",
162164
target_os = "android",
163165
target_os = "espidf",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ cfg_if::cfg_if! {
386386
} else if #[cfg(target_os = "macos")] {
387387
#[link(name = "System")]
388388
extern "C" {}
389-
} else if #[cfg(any(target_os = "ios", target_os = "watchos"))] {
389+
} else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))] {
390390
#[link(name = "System")]
391391
#[link(name = "objc")]
392392
#[link(name = "Security", kind = "framework")]

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

+10-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ extern "C" {
6464
#[cfg_attr(any(target_os = "solaris", target_os = "illumos"), link_name = "___errno")]
6565
#[cfg_attr(target_os = "nto", link_name = "__get_errno_ptr")]
6666
#[cfg_attr(
67-
any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "watchos"),
67+
any(
68+
target_os = "macos",
69+
target_os = "ios",
70+
target_os = "tvos",
71+
target_os = "freebsd",
72+
target_os = "watchos"
73+
),
6874
link_name = "__error"
6975
)]
7076
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
@@ -373,7 +379,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
373379
Ok(PathBuf::from(OsString::from_vec(e)))
374380
}
375381

376-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
382+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
377383
pub fn current_exe() -> io::Result<PathBuf> {
378384
unsafe {
379385
let mut sz: u32 = 0;
@@ -607,6 +613,7 @@ pub fn home_dir() -> Option<PathBuf> {
607613
#[cfg(any(
608614
target_os = "android",
609615
target_os = "ios",
616+
target_os = "tvos",
610617
target_os = "watchos",
611618
target_os = "emscripten",
612619
target_os = "redox",
@@ -620,6 +627,7 @@ pub fn home_dir() -> Option<PathBuf> {
620627
#[cfg(not(any(
621628
target_os = "android",
622629
target_os = "ios",
630+
target_os = "tvos",
623631
target_os = "watchos",
624632
target_os = "emscripten",
625633
target_os = "redox",

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ pub fn hashmap_random_keys() -> (u64, u64) {
1414
unix,
1515
not(target_os = "macos"),
1616
not(target_os = "ios"),
17+
not(target_os = "tvos"),
1718
not(target_os = "watchos"),
1819
not(target_os = "openbsd"),
1920
not(target_os = "freebsd"),
@@ -196,7 +197,7 @@ mod imp {
196197
// once per thread in `hashmap_random_keys`. Therefore `SecRandomCopyBytes` is
197198
// only used on iOS where direct access to `/dev/urandom` is blocked by the
198199
// sandbox.
199-
#[cfg(any(target_os = "ios", target_os = "watchos"))]
200+
#[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))]
200201
mod imp {
201202
use crate::io;
202203
use crate::ptr;

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ impl Thread {
150150
}
151151
}
152152

153-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
153+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
154154
pub fn set_name(name: &CStr) {
155155
unsafe {
156156
let name = truncate_cstr::<{ libc::MAXTHREADNAMESIZE }>(name);
@@ -300,6 +300,7 @@ pub fn available_parallelism() -> io::Result<NonZeroUsize> {
300300
target_os = "emscripten",
301301
target_os = "fuchsia",
302302
target_os = "ios",
303+
target_os = "tvos",
303304
target_os = "linux",
304305
target_os = "macos",
305306
target_os = "solaris",

library/std/src/sys/unix/thread_parking/pthread.rs

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ unsafe fn wait_timeout(
4646
#[cfg(any(
4747
target_os = "macos",
4848
target_os = "ios",
49+
target_os = "tvos",
4950
target_os = "watchos",
5051
target_os = "espidf",
5152
target_os = "horizon",
@@ -73,6 +74,7 @@ unsafe fn wait_timeout(
7374
#[cfg(not(any(
7475
target_os = "macos",
7576
target_os = "ios",
77+
target_os = "tvos",
7678
target_os = "watchos",
7779
target_os = "espidf",
7880
target_os = "horizon",
@@ -120,6 +122,7 @@ impl Parker {
120122
if #[cfg(any(
121123
target_os = "macos",
122124
target_os = "ios",
125+
target_os = "tvos",
123126
target_os = "watchos",
124127
target_os = "l4re",
125128
target_os = "android",

0 commit comments

Comments
 (0)