Skip to content

Commit bdc3db9

Browse files
committed
wip: Support Apple tvOS in libstd
1 parent 006a26c commit bdc3db9

File tree

21 files changed

+84
-22
lines changed

21 files changed

+84
-22
lines changed

library/std/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ fn main() {
1818
|| target.contains("illumos")
1919
|| target.contains("apple-darwin")
2020
|| target.contains("apple-ios")
21+
|| target.contains("apple-tvos")
2122
|| target.contains("apple-watchos")
2223
|| target.contains("uwp")
2324
|| target.contains("windows")
@@ -48,7 +49,6 @@ fn main() {
4849
// - mipsel-sony-psp
4950
// - nvptx64-nvidia-cuda
5051
// - arch=avr
51-
// - tvos (aarch64-apple-tvos, x86_64-apple-tvos)
5252
// - uefi (x86_64-unknown-uefi, i686-unknown-uefi)
5353
// - JSON targets
5454
// - Any new targets that have not been explicitly added above.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use crate::sys_common::{AsInner, AsInnerMut, IntoInner};
66
use crate::time::SystemTime;
77

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

1111
/// OS-specific extensions to [`fs::Metadata`].
1212
///

library/std/src/os/mod.rs

Lines changed: 3 additions & 0 deletions
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 = "vita")]
141144
pub mod vita;
142145
#[cfg(target_os = "vxworks")]

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

Lines changed: 3 additions & 0 deletions
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 = "vita")]
7779
pub use crate::os::vita::*;
7880
#[cfg(target_os = "vxworks")]
@@ -96,6 +98,7 @@ pub mod thread;
9698
target_os = "dragonfly",
9799
target_os = "freebsd",
98100
target_os = "ios",
101+
target_os = "tvos",
99102
target_os = "watchos",
100103
target_os = "macos",
101104
target_os = "netbsd",

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

Lines changed: 3 additions & 0 deletions
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",
@@ -238,6 +240,7 @@ impl UnixStream {
238240
target_os = "dragonfly",
239241
target_os = "freebsd",
240242
target_os = "ios",
243+
target_os = "tvos",
241244
target_os = "macos",
242245
target_os = "watchos",
243246
target_os = "netbsd",

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const UNWIND_DATA_REG: (i32, i32) = (4, 5); // a0, a1
8585
// https://github.com/gcc-mirror/gcc/blob/trunk/libgcc/unwind-c.c
8686

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

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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 11 additions & 0 deletions
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

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use crate::sys_common::{AsInner, AsInnerMut, FromInner, IntoInner};
3232
all(target_os = "linux", target_env = "gnu"),
3333
target_os = "macos",
3434
target_os = "ios",
35+
target_os = "tvos",
3536
target_os = "watchos",
3637
))]
3738
use crate::sys::weak::syscall;
@@ -43,6 +44,7 @@ use libc::{c_int, mode_t};
4344
#[cfg(any(
4445
target_os = "macos",
4546
target_os = "ios",
47+
target_os = "tvos",
4648
target_os = "watchos",
4749
target_os = "solaris",
4850
all(target_os = "linux", target_env = "gnu")
@@ -519,6 +521,7 @@ impl FileAttr {
519521
target_os = "openbsd",
520522
target_os = "macos",
521523
target_os = "ios",
524+
target_os = "tvos",
522525
target_os = "watchos",
523526
))]
524527
pub fn created(&self) -> io::Result<SystemTime> {
@@ -530,6 +533,7 @@ impl FileAttr {
530533
target_os = "openbsd",
531534
target_os = "macos",
532535
target_os = "ios",
536+
target_os = "tvos",
533537
target_os = "watchos",
534538
target_os = "vita",
535539
)))]
@@ -895,6 +899,7 @@ impl DirEntry {
895899
#[cfg(any(
896900
target_os = "macos",
897901
target_os = "ios",
902+
target_os = "tvos",
898903
target_os = "watchos",
899904
target_os = "linux",
900905
target_os = "emscripten",
@@ -928,6 +933,7 @@ impl DirEntry {
928933
#[cfg(any(
929934
target_os = "macos",
930935
target_os = "ios",
936+
target_os = "tvos",
931937
target_os = "watchos",
932938
target_os = "netbsd",
933939
target_os = "openbsd",
@@ -946,6 +952,7 @@ impl DirEntry {
946952
#[cfg(not(any(
947953
target_os = "macos",
948954
target_os = "ios",
955+
target_os = "tvos",
949956
target_os = "watchos",
950957
target_os = "netbsd",
951958
target_os = "openbsd",
@@ -1107,11 +1114,21 @@ impl File {
11071114
cvt_r(|| unsafe { os_fsync(self.as_raw_fd()) })?;
11081115
return Ok(());
11091116

1110-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
1117+
#[cfg(any(
1118+
target_os = "macos",
1119+
target_os = "ios",
1120+
target_os = "tvos",
1121+
target_os = "watchos",
1122+
))]
11111123
unsafe fn os_fsync(fd: c_int) -> c_int {
11121124
libc::fcntl(fd, libc::F_FULLFSYNC)
11131125
}
1114-
#[cfg(not(any(target_os = "macos", target_os = "ios", target_os = "watchos")))]
1126+
#[cfg(not(any(
1127+
target_os = "macos",
1128+
target_os = "ios",
1129+
target_os = "tvos",
1130+
target_os = "watchos",
1131+
)))]
11151132
unsafe fn os_fsync(fd: c_int) -> c_int {
11161133
libc::fsync(fd)
11171134
}
@@ -1121,7 +1138,12 @@ impl File {
11211138
cvt_r(|| unsafe { os_datasync(self.as_raw_fd()) })?;
11221139
return Ok(());
11231140

1124-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
1141+
#[cfg(any(
1142+
target_os = "macos",
1143+
target_os = "ios",
1144+
target_os = "tvos",
1145+
target_os = "watchos",
1146+
))]
11251147
unsafe fn os_datasync(fd: c_int) -> c_int {
11261148
libc::fcntl(fd, libc::F_FULLFSYNC)
11271149
}
@@ -1140,6 +1162,7 @@ impl File {
11401162
target_os = "android",
11411163
target_os = "freebsd",
11421164
target_os = "ios",
1165+
target_os = "tvos",
11431166
target_os = "linux",
11441167
target_os = "macos",
11451168
target_os = "netbsd",
@@ -1709,6 +1732,7 @@ fn open_to_and_set_permissions(
17091732
target_os = "android",
17101733
target_os = "macos",
17111734
target_os = "ios",
1735+
target_os = "tvos",
17121736
target_os = "watchos",
17131737
)))]
17141738
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
@@ -1736,7 +1760,7 @@ pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
17361760
}
17371761
}
17381762

1739-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
1763+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
17401764
pub fn copy(from: &Path, to: &Path) -> io::Result<u64> {
17411765
use crate::sync::atomic::{AtomicBool, Ordering};
17421766

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

Lines changed: 2 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ cfg_if::cfg_if! {
387387
} else if #[cfg(target_os = "macos")] {
388388
#[link(name = "System")]
389389
extern "C" {}
390-
} else if #[cfg(any(target_os = "ios", target_os = "watchos"))] {
390+
} else if #[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))] {
391391
#[link(name = "System")]
392392
#[link(name = "objc")]
393393
#[link(name = "Security", kind = "framework")]

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@ extern "C" {
6363
#[cfg_attr(any(target_os = "solaris", target_os = "illumos"), link_name = "___errno")]
6464
#[cfg_attr(target_os = "nto", link_name = "__get_errno_ptr")]
6565
#[cfg_attr(
66-
any(target_os = "macos", target_os = "ios", target_os = "freebsd", target_os = "watchos"),
66+
any(
67+
target_os = "macos",
68+
target_os = "ios",
69+
target_os = "tvos",
70+
target_os = "freebsd",
71+
target_os = "watchos"
72+
),
6773
link_name = "__error"
6874
)]
6975
#[cfg_attr(target_os = "haiku", link_name = "_errnop")]
@@ -375,7 +381,7 @@ pub fn current_exe() -> io::Result<PathBuf> {
375381
Ok(PathBuf::from(OsString::from_vec(e)))
376382
}
377383

378-
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "watchos"))]
384+
#[cfg(any(target_os = "macos", target_os = "ios", target_os = "tvos", target_os = "watchos"))]
379385
pub fn current_exe() -> io::Result<PathBuf> {
380386
unsafe {
381387
let mut sz: u32 = 0;
@@ -609,6 +615,7 @@ pub fn home_dir() -> Option<PathBuf> {
609615
#[cfg(any(
610616
target_os = "android",
611617
target_os = "ios",
618+
target_os = "tvos",
612619
target_os = "watchos",
613620
target_os = "emscripten",
614621
target_os = "redox",
@@ -623,6 +630,7 @@ pub fn home_dir() -> Option<PathBuf> {
623630
#[cfg(not(any(
624631
target_os = "android",
625632
target_os = "ios",
633+
target_os = "tvos",
626634
target_os = "watchos",
627635
target_os = "emscripten",
628636
target_os = "redox",

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

Lines changed: 2 additions & 1 deletion
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"),
@@ -198,7 +199,7 @@ mod imp {
198199
// once per thread in `hashmap_random_keys`. Therefore `SecRandomCopyBytes` is
199200
// only used on iOS where direct access to `/dev/urandom` is blocked by the
200201
// sandbox.
201-
#[cfg(any(target_os = "ios", target_os = "watchos"))]
202+
#[cfg(any(target_os = "ios", target_os = "tvos", target_os = "watchos"))]
202203
mod imp {
203204
use crate::io;
204205
use crate::ptr;

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

Lines changed: 2 additions & 1 deletion
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);
@@ -299,6 +299,7 @@ pub fn available_parallelism() -> io::Result<NonZeroUsize> {
299299
target_os = "emscripten",
300300
target_os = "fuchsia",
301301
target_os = "ios",
302+
target_os = "tvos",
302303
target_os = "linux",
303304
target_os = "macos",
304305
target_os = "solaris",

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

Lines changed: 3 additions & 0 deletions
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)