From ff5a7545285e66cd8400ba428c50cfbfe46321ff Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Thu, 10 Nov 2022 00:34:58 +0000 Subject: [PATCH] Add support for OpenHarmony --- libc-test/build.rs | 4 +- src/unix/linux_like/linux/align.rs | 11 +- src/unix/linux_like/linux/arch/generic/mod.rs | 4 +- src/unix/linux_like/linux/mod.rs | 143 ++++++++++-------- src/unix/linux_like/linux/musl/mod.rs | 27 ++-- src/unix/linux_like/linux/no_align.rs | 12 +- src/unix/linux_like/mod.rs | 30 +++- src/unix/mod.rs | 25 +-- 8 files changed, 154 insertions(+), 102 deletions(-) diff --git a/libc-test/build.rs b/libc-test/build.rs index 4e67c6eb5da9c..80b73e911b54f 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -3081,7 +3081,7 @@ fn test_linux(target: &str) { // target_env let gnu = target.contains("gnu"); - let musl = target.contains("musl"); + let musl = target.contains("musl") || target.contains("ohos"); let uclibc = target.contains("uclibc"); match (gnu, musl, uclibc) { @@ -3946,7 +3946,7 @@ fn test_linux(target: &str) { // are included (e.g. because including both sets of headers clashes) fn test_linux_like_apis(target: &str) { let gnu = target.contains("gnu"); - let musl = target.contains("musl"); + let musl = target.contains("musl") || target.contains("ohos"); let linux = target.contains("linux"); let emscripten = target.contains("emscripten"); let android = target.contains("android"); diff --git a/src/unix/linux_like/linux/align.rs b/src/unix/linux_like/linux/align.rs index 60afbb200c887..cd4bbc7213957 100644 --- a/src/unix/linux_like/linux/align.rs +++ b/src/unix/linux_like/linux/align.rs @@ -28,9 +28,10 @@ macro_rules! expand_align { size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } - #[cfg_attr(any(target_env = "musl", target_pointer_width = "32"), + #[cfg_attr(any(target_env = "musl", target_env = "ohos", target_pointer_width = "32"), repr(align(4)))] #[cfg_attr(all(not(target_env = "musl"), + not(target_env = "ohos"), target_pointer_width = "64"), repr(align(8)))] pub struct pthread_rwlockattr_t { @@ -63,16 +64,16 @@ macro_rules! expand_align { } s_no_extra_traits! { - #[cfg_attr(all(target_env = "musl", + #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), target_pointer_width = "32"), repr(align(4)))] - #[cfg_attr(all(target_env = "musl", + #[cfg_attr(all(any(target_env = "musl", target_env = "ohos"), target_pointer_width = "64"), repr(align(8)))] - #[cfg_attr(all(not(target_env = "musl"), + #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), target_arch = "x86"), repr(align(4)))] - #[cfg_attr(all(not(target_env = "musl"), + #[cfg_attr(all(not(any(target_env = "musl", target_env = "ohos")), not(target_arch = "x86")), repr(align(8)))] pub struct pthread_cond_t { diff --git a/src/unix/linux_like/linux/arch/generic/mod.rs b/src/unix/linux_like/linux/arch/generic/mod.rs index 40bc30a4f336b..cffe748de9676 100644 --- a/src/unix/linux_like/linux/arch/generic/mod.rs +++ b/src/unix/linux_like/linux/arch/generic/mod.rs @@ -95,7 +95,7 @@ cfg_if! { if #[cfg(all(any(target_arch = "x86", target_arch = "x86_64", target_arch = "aarch64"), - not(target_env = "musl")))] { + not(any(target_env = "musl", target_env = "ohos"))))] { pub const SO_TIMESTAMP_NEW: ::c_int = 63; pub const SO_TIMESTAMPNS_NEW: ::c_int = 64; pub const SO_TIMESTAMPING_NEW: ::c_int = 65; @@ -252,7 +252,7 @@ cfg_if! { pub const RLIMIT_RTTIME: ::__rlimit_resource_t = 15; pub const RLIMIT_NLIMITS: ::__rlimit_resource_t = RLIM_NLIMITS; - } else if #[cfg(target_env = "musl")] { + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { pub const RLIMIT_CPU: ::c_int = 0; pub const RLIMIT_FSIZE: ::c_int = 1; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 45177dff46db2..03a68aef39053 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -471,9 +471,9 @@ s! { __pgrp: ::pid_t, __sd: ::sigset_t, __ss: ::sigset_t, - #[cfg(target_env = "musl")] + #[cfg(any(target_env = "musl", target_env = "ohos"))] __prio: ::c_int, - #[cfg(not(target_env = "musl"))] + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] __sp: ::sched_param, __policy: ::c_int, __pad: [::c_int; 16], @@ -1225,7 +1225,7 @@ cfg_if! { } cfg_if! { - if #[cfg(any(target_env = "gnu", target_env = "musl"))] { + if #[cfg(any(target_env = "gnu", target_env = "musl", target_env = "ohos"))] { pub const ABDAY_1: ::nl_item = 0x20000; pub const ABDAY_2: ::nl_item = 0x20001; pub const ABDAY_3: ::nl_item = 0x20002; @@ -3970,7 +3970,7 @@ safe_f! { } cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { + if #[cfg(all(not(target_env = "uclibc"), not(target_env = "ohos")))] { extern "C" { pub fn aio_read(aiocbp: *mut aiocb) -> ::c_int; pub fn aio_write(aiocbp: *mut aiocb) -> ::c_int; @@ -3989,6 +3989,13 @@ cfg_if! { nitems: ::c_int, sevp: *mut ::sigevent, ) -> ::c_int; + } + } +} + +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + extern "C" { pub fn pwritev( fd: ::c_int, iov: *const ::iovec, @@ -4038,8 +4045,76 @@ cfg_if! { } } +// These functions are not available on OpenHarmony +cfg_if! { + if #[cfg(not(target_env = "ohos"))] { + extern "C" { + // Only `getspnam_r` is implemented for musl, out of all of the reenterant + // functions from `shadow.h`. + // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h + pub fn getspnam_r( + name: *const ::c_char, + spbuf: *mut spwd, + buf: *mut ::c_char, + buflen: ::size_t, + spbufp: *mut *mut spwd, + ) -> ::c_int; + + pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; + pub fn shm_unlink(name: *const ::c_char) -> ::c_int; + + pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; + pub fn mq_close(mqd: ::mqd_t) -> ::c_int; + pub fn mq_unlink(name: *const ::c_char) -> ::c_int; + pub fn mq_receive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + ) -> ::ssize_t; + pub fn mq_timedreceive( + mqd: ::mqd_t, + msg_ptr: *mut ::c_char, + msg_len: ::size_t, + msg_prio: *mut ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::ssize_t; + pub fn mq_send( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + ) -> ::c_int; + pub fn mq_timedsend( + mqd: ::mqd_t, + msg_ptr: *const ::c_char, + msg_len: ::size_t, + msg_prio: ::c_uint, + abs_timeout: *const ::timespec, + ) -> ::c_int; + pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; + pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; + + pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; + pub fn pthread_mutexattr_getrobust( + attr: *const pthread_mutexattr_t, + robustness: *mut ::c_int, + ) -> ::c_int; + pub fn pthread_mutexattr_setrobust( + attr: *mut pthread_mutexattr_t, + robustness: ::c_int, + ) -> ::c_int; + } + } +} + + extern "C" { - #[cfg_attr(not(target_env = "musl"), link_name = "__xpg_strerror_r")] + #[cfg_attr( + not(any(target_env = "musl", target_env = "ohos")), + link_name = "__xpg_strerror_r" + )] pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int; pub fn abs(i: ::c_int) -> ::c_int; @@ -4070,18 +4145,6 @@ extern "C" { pub fn getspent() -> *mut spwd; pub fn getspnam(name: *const ::c_char) -> *mut spwd; - // Only `getspnam_r` is implemented for musl, out of all of the reenterant - // functions from `shadow.h`. - // https://git.musl-libc.org/cgit/musl/tree/include/shadow.h - pub fn getspnam_r( - name: *const ::c_char, - spbuf: *mut spwd, - buf: *mut ::c_char, - buflen: ::size_t, - spbufp: *mut *mut spwd, - ) -> ::c_int; - - pub fn shm_open(name: *const c_char, oflag: ::c_int, mode: mode_t) -> ::c_int; // System V IPC pub fn shmget(key: ::key_t, size: ::size_t, shmflg: ::c_int) -> ::c_int; @@ -4187,37 +4250,6 @@ extern "C" { id: ::c_int, data: *mut ::c_char, ) -> ::c_int; - pub fn mq_open(name: *const ::c_char, oflag: ::c_int, ...) -> ::mqd_t; - pub fn mq_close(mqd: ::mqd_t) -> ::c_int; - pub fn mq_unlink(name: *const ::c_char) -> ::c_int; - pub fn mq_receive( - mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msg_prio: *mut ::c_uint, - ) -> ::ssize_t; - pub fn mq_timedreceive( - mqd: ::mqd_t, - msg_ptr: *mut ::c_char, - msg_len: ::size_t, - msg_prio: *mut ::c_uint, - abs_timeout: *const ::timespec, - ) -> ::ssize_t; - pub fn mq_send( - mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msg_prio: ::c_uint, - ) -> ::c_int; - pub fn mq_timedsend( - mqd: ::mqd_t, - msg_ptr: *const ::c_char, - msg_len: ::size_t, - msg_prio: ::c_uint, - abs_timeout: *const ::timespec, - ) -> ::c_int; - pub fn mq_getattr(mqd: ::mqd_t, attr: *mut ::mq_attr) -> ::c_int; - pub fn mq_setattr(mqd: ::mqd_t, newattr: *const ::mq_attr, oldattr: *mut ::mq_attr) -> ::c_int; pub fn epoll_pwait( epfd: ::c_int, events: *mut ::epoll_event, @@ -4284,8 +4316,6 @@ extern "C" { pub fn posix_madvise(addr: *mut ::c_void, len: ::size_t, advice: ::c_int) -> ::c_int; - pub fn shm_unlink(name: *const ::c_char) -> ::c_int; - pub fn seekdir(dirp: *mut ::DIR, loc: ::c_long); pub fn telldir(dirp: *mut ::DIR) -> ::c_long; @@ -4389,7 +4419,7 @@ extern "C" { attr: *mut pthread_mutexattr_t, protocol: ::c_int, ) -> ::c_int; - pub fn pthread_mutex_consistent(mutex: *mut pthread_mutex_t) -> ::c_int; + pub fn pthread_mutex_timedlock( lock: *mut pthread_mutex_t, abstime: *const ::timespec, @@ -4487,7 +4517,6 @@ extern "C" { pub fn pthread_sigmask(how: ::c_int, set: *const sigset_t, oldset: *mut sigset_t) -> ::c_int; pub fn sem_open(name: *const ::c_char, oflag: ::c_int, ...) -> *mut sem_t; pub fn getgrnam(name: *const ::c_char) -> *mut ::group; - pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int; pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int; pub fn sem_unlink(name: *const ::c_char) -> ::c_int; pub fn daemon(nochdir: ::c_int, noclose: ::c_int) -> ::c_int; @@ -4522,14 +4551,6 @@ extern "C" { attr: *const pthread_mutexattr_t, pshared: *mut ::c_int, ) -> ::c_int; - pub fn pthread_mutexattr_getrobust( - attr: *const pthread_mutexattr_t, - robustness: *mut ::c_int, - ) -> ::c_int; - pub fn pthread_mutexattr_setrobust( - attr: *mut pthread_mutexattr_t, - robustness: ::c_int, - ) -> ::c_int; pub fn popen(command: *const c_char, mode: *const c_char) -> *mut ::FILE; pub fn faccessat( dirfd: ::c_int, @@ -4729,7 +4750,7 @@ cfg_if! { if #[cfg(target_env = "uclibc")] { mod uclibc; pub use self::uclibc::*; - } else if #[cfg(target_env = "musl")] { + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { mod musl; pub use self::musl::*; } else if #[cfg(target_env = "gnu")] { diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs index 454ab53eb133c..37a8ca2aff2fe 100644 --- a/src/unix/linux_like/linux/musl/mod.rs +++ b/src/unix/linux_like/linux/musl/mod.rs @@ -287,12 +287,14 @@ s_no_extra_traits! { // FIXME: musl added paddings and adjusted // layout in 1.2.0 but our CI is still 1.1.24. - // So, I'm leaving some fields as comments for now. + // So, I'm leaving some fields as cfg for now. // ref. https://github.com/bminor/musl/commit/ // 1e7f0fcd7ff2096904fd93a2ee6d12a2392be392 + // + // OpenHarmony uses the musl 1.2 layout. pub struct utmpx { pub ut_type: ::c_short, - //__ut_pad1: ::c_short, + __ut_pad1: ::c_short, pub ut_pid: ::pid_t, pub ut_line: [::c_char; 32], pub ut_id: [::c_char; 4], @@ -300,15 +302,22 @@ s_no_extra_traits! { pub ut_host: [::c_char; 256], pub ut_exit: __exit_status, - //#[cfg(target_endian = "little")] + #[cfg(target_env = "musl")] pub ut_session: ::c_long, - //#[cfg(target_endian = "little")] - //__ut_pad2: ::c_long, - //#[cfg(not(target_endian = "little"))] - //__ut_pad2: ::c_int, - //#[cfg(not(target_endian = "little"))] - //pub ut_session: ::c_int, + #[cfg(target_env = "ohos")] + #[cfg(target_endian = "little")] + pub ut_session: ::c_int, + #[cfg(target_env = "ohos")] + #[cfg(target_endian = "little")] + __ut_pad2: ::c_int, + + #[cfg(target_env = "ohos")] + #[cfg(not(target_endian = "little"))] + __ut_pad2: ::c_int, + #[cfg(target_env = "ohos")] + #[cfg(not(target_endian = "little"))] + pub ut_session: ::c_int, pub ut_tv: ::timeval, pub ut_addr_v6: [::c_uint; 4], diff --git a/src/unix/linux_like/linux/no_align.rs b/src/unix/linux_like/linux/no_align.rs index 351340ed243c2..6f5f2f7c015cd 100644 --- a/src/unix/linux_like/linux/no_align.rs +++ b/src/unix/linux_like/linux/no_align.rs @@ -11,7 +11,7 @@ macro_rules! expand_align { target_arch = "riscv32", target_arch = "loongarch64", all(target_arch = "aarch64", - target_env = "musl")))] + any(target_env = "musl", target_env = "ohos"))))] __align: [::c_int; 0], #[cfg(not(any(target_arch = "x86_64", target_arch = "powerpc64", @@ -22,15 +22,15 @@ macro_rules! expand_align { target_arch = "riscv32", target_arch = "loongarch64", all(target_arch = "aarch64", - target_env = "musl"))))] + any(target_env = "musl", target_env = "ohos")))))] __align: [::c_long; 0], size: [u8; ::__SIZEOF_PTHREAD_MUTEXATTR_T], } pub struct pthread_rwlockattr_t { - #[cfg(target_env = "musl")] + #[cfg(any(target_env = "musl", target_env = "ohos"))] __align: [::c_int; 0], - #[cfg(not(target_env = "musl"))] + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] __align: [::c_long; 0], size: [u8; ::__SIZEOF_PTHREAD_RWLOCKATTR_T], } @@ -59,9 +59,9 @@ macro_rules! expand_align { s_no_extra_traits! { pub struct pthread_cond_t { - #[cfg(target_env = "musl")] + #[cfg(any(target_env = "musl", target_env = "ohos"))] __align: [*const ::c_void; 0], - #[cfg(not(target_env = "musl"))] + #[cfg(not(any(target_env = "musl", target_env = "ohos")))] __align: [::c_longlong; 0], size: [u8; ::__SIZEOF_PTHREAD_COND_T], } diff --git a/src/unix/linux_like/mod.rs b/src/unix/linux_like/mod.rs index 20d0006bd4d75..db57745967f79 100644 --- a/src/unix/linux_like/mod.rs +++ b/src/unix/linux_like/mod.rs @@ -108,13 +108,13 @@ s! { pub struct sched_param { pub sched_priority: ::c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] pub sched_ss_low_priority: ::c_int, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] pub sched_ss_repl_period: ::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] pub sched_ss_init_budget: ::timespec, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[cfg(any(target_env = "musl", target_os = "emscripten", target_env = "ohos"))] pub sched_ss_max_repl: ::c_int, } @@ -557,7 +557,21 @@ pub const XATTR_CREATE: ::c_int = 0x1; pub const XATTR_REPLACE: ::c_int = 0x2; cfg_if! { - if #[cfg(not(target_env = "uclibc"))] { + if #[cfg(target_env = "ohos")] { + pub const LC_CTYPE: ::c_int = 0; + pub const LC_NUMERIC: ::c_int = 1; + pub const LC_TIME: ::c_int = 2; + pub const LC_COLLATE: ::c_int = 3; + pub const LC_MONETARY: ::c_int = 4; + pub const LC_MESSAGES: ::c_int = 5; + pub const LC_PAPER: ::c_int = 6; + pub const LC_NAME: ::c_int = 7; + pub const LC_ADDRESS: ::c_int = 8; + pub const LC_TELEPHONE: ::c_int = 9; + pub const LC_MEASUREMENT: ::c_int = 10; + pub const LC_IDENTIFICATION: ::c_int = 11; + pub const LC_ALL: ::c_int = 12; + } else if #[cfg(not(target_env = "uclibc"))] { pub const LC_CTYPE: ::c_int = 0; pub const LC_NUMERIC: ::c_int = 1; pub const LC_TIME: ::c_int = 2; @@ -973,7 +987,11 @@ pub const TCP_QUICKACK: ::c_int = 12; pub const TCP_CONGESTION: ::c_int = 13; pub const TCP_MD5SIG: ::c_int = 14; cfg_if! { - if #[cfg(all(target_os = "linux", any(target_env = "gnu", target_env = "musl")))] { + if #[cfg(all(target_os = "linux", any( + target_env = "gnu", + target_env = "musl", + target_env = "ohos" + )))] { // WARN: deprecated pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15; } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 49c2d5717ad99..b005970b9de41 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -130,7 +130,7 @@ s! { #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] __pad14: u32, - #[cfg(any(target_env = "musl", target_os = "emscripten"))] + #[cfg(any(target_env = "musl", target_env = "ohos", target_os = "emscripten"))] __reserved: [c_long; 16], } @@ -351,7 +351,7 @@ cfg_if! { #[link(name = "dl", cfg(not(target_feature = "crt-static")))] #[link(name = "c", cfg(not(target_feature = "crt-static")))] extern {} - } else if #[cfg(target_env = "musl")] { + } else if #[cfg(any(target_env = "musl", target_env = "ohos"))] { #[cfg_attr(feature = "rustc-dep-of-std", link(name = "c", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static")))] @@ -1217,7 +1217,10 @@ extern "C" { pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; #[cfg_attr( any( - all(target_os = "linux", not(target_env = "musl")), + all( + target_os = "linux", + not(any(target_env = "musl", target_env = "ohos")) + ), target_os = "freebsd", target_os = "dragonfly", target_os = "haiku" @@ -1236,11 +1239,11 @@ extern "C" { pub fn res_init() -> ::c_int; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__localtime_r50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn localtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; #[cfg_attr( @@ -1248,27 +1251,27 @@ extern "C" { link_name = "mktime$UNIX2003" )] #[cfg_attr(target_os = "netbsd", link_name = "__mktime50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn mktime(tm: *mut tm) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__time50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn time(time: *mut time_t) -> time_t; #[cfg_attr(target_os = "netbsd", link_name = "__gmtime50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn gmtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__locatime50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn localtime(time_p: *const time_t) -> *mut tm; #[cfg_attr(target_os = "netbsd", link_name = "__difftime50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn difftime(time1: time_t, time0: time_t) -> ::c_double; #[cfg_attr(target_os = "netbsd", link_name = "__timegm50")] - #[cfg_attr(target_env = "musl", allow(deprecated))] + #[cfg_attr(any(target_env = "musl", target_env = "ohos"), allow(deprecated))] // FIXME: for `time_t` pub fn timegm(tm: *mut ::tm) -> time_t;