summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/unix/bsd/apple/mod.rs25
-rw-r--r--src/unix/bsd/netbsdlike/openbsd/mod.rs6
-rw-r--r--src/unix/haiku/mod.rs43
-rw-r--r--src/unix/linux_like/android/mod.rs20
-rw-r--r--src/unix/linux_like/linux/align.rs11
-rw-r--r--src/unix/linux_like/linux/arch/generic/mod.rs4
-rw-r--r--src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs35
-rw-r--r--src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs35
-rw-r--r--src/unix/linux_like/linux/gnu/mod.rs39
-rw-r--r--src/unix/linux_like/linux/mod.rs196
-rw-r--r--src/unix/linux_like/linux/musl/b32/mips/mod.rs3
-rw-r--r--src/unix/linux_like/linux/musl/b32/powerpc.rs2
-rw-r--r--src/unix/linux_like/linux/musl/b64/s390x.rs1
-rw-r--r--src/unix/linux_like/linux/musl/mod.rs27
-rw-r--r--src/unix/linux_like/linux/no_align.rs12
-rw-r--r--src/unix/linux_like/mod.rs30
-rw-r--r--src/unix/mod.rs27
-rw-r--r--src/unix/nto/mod.rs1
-rw-r--r--src/unix/redox/mod.rs20
-rw-r--r--src/wasi.rs5
20 files changed, 409 insertions, 133 deletions
diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs
index 540bf9dcb5..3348a7a8af 100644
--- a/src/unix/bsd/apple/mod.rs
+++ b/src/unix/bsd/apple/mod.rs
@@ -5121,6 +5121,23 @@ extern "C" {
pub fn endutxent();
pub fn utmpxname(file: *const ::c_char) -> ::c_int;
+ pub fn asctime(tm: *const ::tm) -> *mut ::c_char;
+ pub fn ctime(clock: *const time_t) -> *mut ::c_char;
+ pub fn getdate(datestr: *const ::c_char) -> *mut ::tm;
+ pub fn strftime(
+ buf: *mut ::c_char,
+ maxsize: ::size_t,
+ format: *const ::c_char,
+ timeptr: *const ::tm,
+ ) -> ::size_t;
+ pub fn strptime(
+ buf: *const ::c_char,
+ format: *const ::c_char,
+ timeptr: *mut ::tm,
+ ) -> *mut ::c_char;
+ pub fn asctime_r(tm: *const ::tm, result: *mut ::c_char) -> *mut ::c_char;
+ pub fn ctime_r(clock: *const time_t, result: *mut ::c_char) -> *mut ::c_char;
+
pub fn getnameinfo(
sa: *const ::sockaddr,
salen: ::socklen_t,
@@ -5563,6 +5580,14 @@ extern "C" {
subpref: *mut ::cpu_subtype_t,
ocount: *mut ::size_t,
) -> ::c_int;
+ pub fn posix_spawnattr_set_qos_class_np(
+ attr: *mut posix_spawnattr_t,
+ qos_class: ::qos_class_t,
+ ) -> ::c_int;
+ pub fn posix_spawnattr_get_qos_class_np(
+ attr: *const posix_spawnattr_t,
+ qos_class: *mut ::qos_class_t,
+ ) -> ::c_int;
pub fn posix_spawn_file_actions_init(actions: *mut posix_spawn_file_actions_t) -> ::c_int;
pub fn posix_spawn_file_actions_destroy(actions: *mut posix_spawn_file_actions_t) -> ::c_int;
diff --git a/src/unix/bsd/netbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsd/mod.rs
index 87acecb6a7..192413a54a 100644
--- a/src/unix/bsd/netbsdlike/openbsd/mod.rs
+++ b/src/unix/bsd/netbsdlike/openbsd/mod.rs
@@ -1660,6 +1660,12 @@ pub const MNT_WAIT: ::c_int = 1;
pub const MNT_NOWAIT: ::c_int = 2;
pub const MNT_LAZY: ::c_int = 3;
+// sys/_time.h
+pub const CLOCK_PROCESS_CPUTIME_ID: ::clockid_t = 2;
+pub const CLOCK_THREAD_CPUTIME_ID: ::clockid_t = 4;
+pub const CLOCK_UPTIME: ::clockid_t = 5;
+pub const CLOCK_BOOTTIME: ::clockid_t = 6;
+
pub const LC_COLLATE_MASK: ::c_int = 1 << ::LC_COLLATE;
pub const LC_CTYPE_MASK: ::c_int = 1 << ::LC_CTYPE;
pub const LC_MONETARY_MASK: ::c_int = 1 << ::LC_MONETARY;
diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs
index 1c40c51e66..8af90b0de3 100644
--- a/src/unix/haiku/mod.rs
+++ b/src/unix/haiku/mod.rs
@@ -55,6 +55,8 @@ pub type ACTION = ::c_int;
pub type posix_spawnattr_t = *mut ::c_void;
pub type posix_spawn_file_actions_t = *mut ::c_void;
+pub type StringList = _stringlist;
+
#[cfg_attr(feature = "extra_traits", derive(Debug))]
pub enum timezone {}
impl ::Copy for timezone {}
@@ -437,6 +439,19 @@ s! {
pub flag: *mut ::c_int,
pub val: ::c_int,
}
+
+ pub struct _stringlist {
+ pub sl_str: *mut *mut ::c_char,
+ pub sl_max: ::size_t,
+ pub sl_cur: ::size_t,
+ }
+
+ pub struct dl_phdr_info {
+ pub dlpi_addr: ::Elf_Addr,
+ pub dlpi_name: *const ::c_char,
+ pub dlpi_phdr: *const ::Elf_Phdr,
+ pub dlpi_phnum: ::Elf_Half,
+ }
}
s_no_extra_traits! {
@@ -2017,6 +2032,34 @@ extern "C" {
pub fn strsep(string: *mut *mut ::c_char, delimiters: *const ::c_char) -> *mut ::c_char;
pub fn explicit_bzero(buf: *mut ::c_void, len: ::size_t);
pub fn login_tty(_fd: ::c_int) -> ::c_int;
+
+ pub fn sl_init() -> *mut StringList;
+ pub fn sl_add(sl: *mut StringList, n: *mut ::c_char) -> ::c_int;
+ pub fn sl_free(sl: *mut StringList, i: ::c_int);
+ pub fn sl_find(sl: *mut StringList, n: *mut ::c_char) -> *mut ::c_char;
+
+ pub fn getprogname() -> *const ::c_char;
+ pub fn setprogname(progname: *const ::c_char);
+ pub fn dl_iterate_phdr(
+ callback: ::Option<
+ unsafe extern "C" fn(
+ info: *mut dl_phdr_info,
+ size: usize,
+ data: *mut ::c_void,
+ ) -> ::c_int,
+ >,
+ data: *mut ::c_void,
+ ) -> ::c_int;
+}
+
+#[link(name = "unix")]
+extern "C" {
+ pub fn memmem(
+ source: *const ::c_void,
+ sourceLength: ::size_t,
+ search: *const ::c_void,
+ searchLength: ::size_t,
+ ) -> *mut ::c_void;
}
cfg_if! {
diff --git a/src/unix/linux_like/android/mod.rs b/src/unix/linux_like/android/mod.rs
index 2bc748ac4c..e2fa0826f2 100644
--- a/src/unix/linux_like/android/mod.rs
+++ b/src/unix/linux_like/android/mod.rs
@@ -1606,6 +1606,14 @@ pub const AI_ADDRCONFIG: ::c_int = 0x00000400;
pub const AI_V4MAPPED: ::c_int = 0x00000800;
pub const AI_DEFAULT: ::c_int = AI_V4MAPPED_CFG | AI_ADDRCONFIG;
+// linux/kexec.h
+pub const KEXEC_ON_CRASH: ::c_int = 0x00000001;
+pub const KEXEC_PRESERVE_CONTEXT: ::c_int = 0x00000002;
+pub const KEXEC_ARCH_MASK: ::c_int = 0xffff0000;
+pub const KEXEC_FILE_UNLOAD: ::c_int = 0x00000001;
+pub const KEXEC_FILE_ON_CRASH: ::c_int = 0x00000002;
+pub const KEXEC_FILE_NO_INITRAMFS: ::c_int = 0x00000004;
+
pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
pub const LINUX_REBOOT_MAGIC2A: ::c_int = 85072278;
@@ -2732,6 +2740,18 @@ pub const SCHED_RESET_ON_FORK: ::c_int = 0x40000000;
pub const CLONE_PIDFD: ::c_int = 0x1000;
+// linux/membarrier.h
+pub const MEMBARRIER_CMD_QUERY: ::c_int = 0;
+pub const MEMBARRIER_CMD_GLOBAL: ::c_int = 1 << 0;
+pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: ::c_int = 1 << 1;
+pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: ::c_int = 1 << 2;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: ::c_int = 1 << 3;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: ::c_int = 1 << 4;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 5;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8;
+
// linux/mempolicy.h
pub const MPOL_DEFAULT: ::c_int = 0;
pub const MPOL_PREFERRED: ::c_int = 1;
diff --git a/src/unix/linux_like/linux/align.rs b/src/unix/linux_like/linux/align.rs
index 60afbb200c..cd4bbc7213 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 40bc30a4f3..cffe748de9 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/gnu/b32/riscv32/mod.rs b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
index 6e3130324a..f3b130cbc6 100644
--- a/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b32/riscv32/mod.rs
@@ -196,6 +196,41 @@ s! {
pub l_len: ::off64_t,
pub l_pid: ::pid_t,
}
+
+ pub struct user_regs_struct {
+ pub pc: ::c_ulong,
+ pub ra: ::c_ulong,
+ pub sp: ::c_ulong,
+ pub gp: ::c_ulong,
+ pub tp: ::c_ulong,
+ pub t0: ::c_ulong,
+ pub t1: ::c_ulong,
+ pub t2: ::c_ulong,
+ pub s0: ::c_ulong,
+ pub s1: ::c_ulong,
+ pub a0: ::c_ulong,
+ pub a1: ::c_ulong,
+ pub a2: ::c_ulong,
+ pub a3: ::c_ulong,
+ pub a4: ::c_ulong,
+ pub a5: ::c_ulong,
+ pub a6: ::c_ulong,
+ pub a7: ::c_ulong,
+ pub s2: ::c_ulong,
+ pub s3: ::c_ulong,
+ pub s4: ::c_ulong,
+ pub s5: ::c_ulong,
+ pub s6: ::c_ulong,
+ pub s7: ::c_ulong,
+ pub s8: ::c_ulong,
+ pub s9: ::c_ulong,
+ pub s10: ::c_ulong,
+ pub s11: ::c_ulong,
+ pub t3: ::c_ulong,
+ pub t4: ::c_ulong,
+ pub t5: ::c_ulong,
+ pub t6: ::c_ulong,
+ }
}
pub const O_LARGEFILE: ::c_int = 0;
diff --git a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
index c84442f1f3..c65a562ac2 100644
--- a/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
+++ b/src/unix/linux_like/linux/gnu/b64/riscv64/mod.rs
@@ -192,6 +192,41 @@ s! {
pub l_len: ::off64_t,
pub l_pid: ::pid_t,
}
+
+ pub struct user_regs_struct {
+ pub pc: ::c_ulong,
+ pub ra: ::c_ulong,
+ pub sp: ::c_ulong,
+ pub gp: ::c_ulong,
+ pub tp: ::c_ulong,
+ pub t0: ::c_ulong,
+ pub t1: ::c_ulong,
+ pub t2: ::c_ulong,
+ pub s0: ::c_ulong,
+ pub s1: ::c_ulong,
+ pub a0: ::c_ulong,
+ pub a1: ::c_ulong,
+ pub a2: ::c_ulong,
+ pub a3: ::c_ulong,
+ pub a4: ::c_ulong,
+ pub a5: ::c_ulong,
+ pub a6: ::c_ulong,
+ pub a7: ::c_ulong,
+ pub s2: ::c_ulong,
+ pub s3: ::c_ulong,
+ pub s4: ::c_ulong,
+ pub s5: ::c_ulong,
+ pub s6: ::c_ulong,
+ pub s7: ::c_ulong,
+ pub s8: ::c_ulong,
+ pub s9: ::c_ulong,
+ pub s10: ::c_ulong,
+ pub s11: ::c_ulong,
+ pub t3: ::c_ulong,
+ pub t4: ::c_ulong,
+ pub t5: ::c_ulong,
+ pub t6: ::c_ulong,
+ }
}
pub const POSIX_FADV_DONTNEED: ::c_int = 4;
diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs
index 2d84ec662d..1aad8361ad 100644
--- a/src/unix/linux_like/linux/gnu/mod.rs
+++ b/src/unix/linux_like/linux/gnu/mod.rs
@@ -730,27 +730,6 @@ pub const PF_NFC: ::c_int = AF_NFC;
pub const PF_VSOCK: ::c_int = AF_VSOCK;
pub const PF_XDP: ::c_int = AF_XDP;
-/* DCCP socket options */
-pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
-pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
-pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
-pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
-pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
-pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
-pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
-pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
-pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
-pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
-pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
-pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
-pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
-pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
-pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
-pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
-
-/// maximum number of services provided on the same listening port
-pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
-
pub const SIGEV_THREAD_ID: ::c_int = 4;
pub const BUFSIZ: ::c_uint = 8192;
@@ -1212,14 +1191,6 @@ extern "C" {
pub fn ntp_gettime(buf: *mut ntptimeval) -> ::c_int;
pub fn clock_adjtime(clk_id: ::clockid_t, buf: *mut ::timex) -> ::c_int;
- pub fn copy_file_range(
- fd_in: ::c_int,
- off_in: *mut ::off64_t,
- fd_out: ::c_int,
- off_out: *mut ::off64_t,
- len: ::size_t,
- flags: ::c_uint,
- ) -> ::ssize_t;
pub fn fanotify_mark(
fd: ::c_int,
flags: ::c_uint,
@@ -1403,6 +1374,16 @@ extern "C" {
) -> ::c_int;
}
+// mntent.h
+extern "C" {
+ pub fn getmntent_r(
+ stream: *mut ::FILE,
+ mntbuf: *mut ::mntent,
+ buf: *mut ::c_char,
+ buflen: ::c_int,
+ ) -> *mut ::mntent;
+}
+
cfg_if! {
if #[cfg(any(target_arch = "x86",
target_arch = "arm",
diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs
index 2422d2063f..a1e1900747 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;
@@ -1849,6 +1849,18 @@ pub const MPOL_F_NUMA_BALANCING: ::c_int = 1 << 13;
pub const MPOL_F_RELATIVE_NODES: ::c_int = 1 << 14;
pub const MPOL_F_STATIC_NODES: ::c_int = 1 << 15;
+// linux/membarrier.h
+pub const MEMBARRIER_CMD_QUERY: ::c_int = 0;
+pub const MEMBARRIER_CMD_GLOBAL: ::c_int = 1 << 0;
+pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: ::c_int = 1 << 1;
+pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: ::c_int = 1 << 2;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: ::c_int = 1 << 3;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: ::c_int = 1 << 4;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 5;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: ::c_int = 1 << 6;
+pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 7;
+pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: ::c_int = 1 << 8;
+
align_const! {
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
size: [0; __SIZEOF_PTHREAD_MUTEX_T],
@@ -3546,6 +3558,14 @@ pub fn FUTEX_OP(op: ::c_int, oparg: ::c_int, cmp: ::c_int, cmparg: ::c_int) -> :
((op & 0xf) << 28) | ((cmp & 0xf) << 24) | ((oparg & 0xfff) << 12) | (cmparg & 0xfff)
}
+// linux/kexec.h
+pub const KEXEC_ON_CRASH: ::c_int = 0x00000001;
+pub const KEXEC_PRESERVE_CONTEXT: ::c_int = 0x00000002;
+pub const KEXEC_ARCH_MASK: ::c_int = 0xffff0000;
+pub const KEXEC_FILE_UNLOAD: ::c_int = 0x00000001;
+pub const KEXEC_FILE_ON_CRASH: ::c_int = 0x00000002;
+pub const KEXEC_FILE_NO_INITRAMFS: ::c_int = 0x00000004;
+
// linux/reboot.h
pub const LINUX_REBOOT_MAGIC1: ::c_int = 0xfee1dead;
pub const LINUX_REBOOT_MAGIC2: ::c_int = 672274793;
@@ -3796,6 +3816,27 @@ pub const SCTP_PR_SCTP_ALL: ::c_int = 1 << 7;
pub const SCTP_NOTIFICATION: ::c_int = MSG_NOTIFICATION;
pub const SCTP_EOF: ::c_int = ::MSG_FIN;
+/* DCCP socket options */
+pub const DCCP_SOCKOPT_PACKET_SIZE: ::c_int = 1;
+pub const DCCP_SOCKOPT_SERVICE: ::c_int = 2;
+pub const DCCP_SOCKOPT_CHANGE_L: ::c_int = 3;
+pub const DCCP_SOCKOPT_CHANGE_R: ::c_int = 4;
+pub const DCCP_SOCKOPT_GET_CUR_MPS: ::c_int = 5;
+pub const DCCP_SOCKOPT_SERVER_TIMEWAIT: ::c_int = 6;
+pub const DCCP_SOCKOPT_SEND_CSCOV: ::c_int = 10;
+pub const DCCP_SOCKOPT_RECV_CSCOV: ::c_int = 11;
+pub const DCCP_SOCKOPT_AVAILABLE_CCIDS: ::c_int = 12;
+pub const DCCP_SOCKOPT_CCID: ::c_int = 13;
+pub const DCCP_SOCKOPT_TX_CCID: ::c_int = 14;
+pub const DCCP_SOCKOPT_RX_CCID: ::c_int = 15;
+pub const DCCP_SOCKOPT_QPOLICY_ID: ::c_int = 16;
+pub const DCCP_SOCKOPT_QPOLICY_TXQLEN: ::c_int = 17;
+pub const DCCP_SOCKOPT_CCID_RX_INFO: ::c_int = 128;
+pub const DCCP_SOCKOPT_CCID_TX_INFO: ::c_int = 192;
+
+/// maximum number of services provided on the same listening port
+pub const DCCP_SERVICE_LIST_MAX_LEN: ::c_int = 32;
+
f! {
pub fn NLA_ALIGN(len: ::c_int) -> ::c_int {
return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1)
@@ -3966,7 +4007,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;
@@ -3985,6 +4026,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,
@@ -4034,8 +4082,79 @@ 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;
@@ -4066,18 +4185,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;
@@ -4183,37 +4290,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,
@@ -4280,8 +4356,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;
@@ -4385,7 +4459,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,
@@ -4483,7 +4557,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;
@@ -4518,14 +4591,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,
@@ -4710,13 +4775,22 @@ extern "C" {
longopts: *const option,
longindex: *mut ::c_int,
) -> ::c_int;
+
+ pub fn copy_file_range(
+ fd_in: ::c_int,
+ off_in: *mut ::off64_t,
+ fd_out: ::c_int,
+ off_out: *mut ::off64_t,
+ len: ::size_t,
+ flags: ::c_uint,
+ ) -> ::ssize_t;
}
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/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs
index 40b507bcd0..d09b8278e5 100644
--- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs
+++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs
@@ -261,6 +261,7 @@ pub const MAP_NORESERVE: ::c_int = 0x0400;
pub const MAP_POPULATE: ::c_int = 0x10000;
pub const MAP_NONBLOCK: ::c_int = 0x20000;
pub const MAP_STACK: ::c_int = 0x40000;
+pub const MAP_HUGETLB: ::c_int = 0x80000;
pub const EDEADLK: ::c_int = 45;
pub const ENAMETOOLONG: ::c_int = 78;
@@ -382,8 +383,6 @@ pub const SIG_UNBLOCK: ::c_int = 2;
pub const EXTPROC: ::tcflag_t = 0o200000;
-pub const MAP_HUGETLB: ::c_int = 0x80000;
-
pub const F_GETLK: ::c_int = 33;
pub const F_GETOWN: ::c_int = 23;
pub const F_SETLK: ::c_int = 34;
diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs
index 5b1bf17ed8..3b998329bb 100644
--- a/src/unix/linux_like/linux/musl/b32/powerpc.rs
+++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs
@@ -254,6 +254,8 @@ pub const MAP_NORESERVE: ::c_int = 0x00040;
pub const MAP_POPULATE: ::c_int = 0x08000;
pub const MAP_NONBLOCK: ::c_int = 0x010000;
pub const MAP_STACK: ::c_int = 0x020000;
+pub const MAP_HUGETLB: ::c_int = 0x040000;
+pub const MAP_SYNC: ::c_int = 0x080000;
pub const SOCK_STREAM: ::c_int = 1;
pub const SOCK_DGRAM: ::c_int = 2;
diff --git a/src/unix/linux_like/linux/musl/b64/s390x.rs b/src/unix/linux_like/linux/musl/b64/s390x.rs
index 60bfc8d3e0..d7dcce615c 100644
--- a/src/unix/linux_like/linux/musl/b64/s390x.rs
+++ b/src/unix/linux_like/linux/musl/b64/s390x.rs
@@ -177,6 +177,7 @@ pub const MAP_POPULATE: ::c_int = 0x08000;
pub const MAP_NONBLOCK: ::c_int = 0x010000;
pub const MAP_STACK: ::c_int = 0x020000;
pub const MAP_HUGETLB: ::c_int = 0x040000;
+pub const MAP_SYNC: ::c_int = 0x080000;
pub const EDEADLOCK: ::c_int = 35;
pub const ENAMETOOLONG: ::c_int = 36;
diff --git a/src/unix/linux_like/linux/musl/mod.rs b/src/unix/linux_like/linux/musl/mod.rs
index 454ab53eb1..37a8ca2aff 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 351340ed24..6f5f2f7c01 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 20d0006bd4..db57745967 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 49c2d5717a..75d511e390 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")))]
@@ -1048,6 +1048,7 @@ extern "C" {
pub fn symlink(path1: *const c_char, path2: *const c_char) -> ::c_int;
+ pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
pub fn ftruncate(fd: ::c_int, length: off_t) -> ::c_int;
pub fn signal(signum: ::c_int, handler: sighandler_t) -> sighandler_t;
@@ -1217,7 +1218,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 +1240,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 +1252,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;
@@ -1444,7 +1448,6 @@ cfg_if! {
if #[cfg(not(target_os = "redox"))] {
extern {
pub fn getsid(pid: pid_t) -> pid_t;
- pub fn truncate(path: *const c_char, length: off_t) -> ::c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "pause$UNIX2003")]
pub fn pause() -> ::c_int;
diff --git a/src/unix/nto/mod.rs b/src/unix/nto/mod.rs
index 45e97ceace..b8fcf9df8e 100644
--- a/src/unix/nto/mod.rs
+++ b/src/unix/nto/mod.rs
@@ -2748,7 +2748,6 @@ extern "C" {
pub fn strerror_r(errnum: ::c_int, buf: *mut c_char, buflen: ::size_t) -> ::c_int;
pub fn abs(i: ::c_int) -> ::c_int;
- pub fn atof(s: *const ::c_char) -> ::c_double;
pub fn labs(i: ::c_long) -> ::c_long;
pub fn rand() -> ::c_int;
pub fn srand(seed: ::c_uint);
diff --git a/src/unix/redox/mod.rs b/src/unix/redox/mod.rs
index afba677277..6661ea7358 100644
--- a/src/unix/redox/mod.rs
+++ b/src/unix/redox/mod.rs
@@ -459,6 +459,15 @@ pub const O_SYMLINK: ::c_int = 0x4000_0000;
// FIXME: Fix negative values missing from includes
pub const O_NOFOLLOW: ::c_int = -0x8000_0000;
+// locale.h
+pub const LC_ALL: ::c_int = 0;
+pub const LC_COLLATE: ::c_int = 1;
+pub const LC_CTYPE: ::c_int = 2;
+pub const LC_MESSAGES: ::c_int = 3;
+pub const LC_MONETARY: ::c_int = 4;
+pub const LC_NUMERIC: ::c_int = 5;
+pub const LC_TIME: ::c_int = 6;
+
// netdb.h
pub const AI_PASSIVE: ::c_int = 0x0001;
pub const AI_CANONNAME: ::c_int = 0x0002;
@@ -502,6 +511,7 @@ pub const IP_MULTICAST_TTL: ::c_int = 33;
pub const IP_MULTICAST_LOOP: ::c_int = 34;
pub const IP_ADD_MEMBERSHIP: ::c_int = 35;
pub const IP_DROP_MEMBERSHIP: ::c_int = 36;
+pub const IPPROTO_RAW: ::c_int = 255;
// }
// netinet/tcp.h
@@ -1033,6 +1043,13 @@ extern "C" {
pub fn pthread_cancel(thread: ::pthread_t) -> ::c_int;
pub fn pthread_kill(thread: ::pthread_t, sig: ::c_int) -> ::c_int;
+ // stdlib.h
+ pub fn reallocarray(ptr: *mut ::c_void, nmemb: ::size_t, size: ::size_t) -> *mut ::c_void;
+
+ // string.h
+ pub fn strlcat(dst: *mut ::c_char, src: *const ::c_char, siz: ::size_t) -> ::size_t;
+ pub fn strlcpy(dst: *mut ::c_char, src: *const ::c_char, siz: ::size_t) -> ::size_t;
+
// sys/epoll.h
pub fn epoll_create(size: ::c_int) -> ::c_int;
pub fn epoll_create1(flags: ::c_int) -> ::c_int;
@@ -1083,6 +1100,9 @@ extern "C" {
// time.h
pub fn gettimeofday(tp: *mut ::timeval, tz: *mut ::timezone) -> ::c_int;
pub fn clock_gettime(clk_id: ::clockid_t, tp: *mut ::timespec) -> ::c_int;
+
+ // strings.h
+ pub fn explicit_bzero(p: *mut ::c_void, len: ::size_t);
}
cfg_if! {
diff --git a/src/wasi.rs b/src/wasi.rs
index abfebd6439..1a855e0e0f 100644
--- a/src/wasi.rs
+++ b/src/wasi.rs
@@ -246,12 +246,15 @@ pub const S_IFREG: mode_t = 32768;
pub const S_IFLNK: mode_t = 40960;
pub const S_IFSOCK: mode_t = 49152;
pub const S_IFMT: mode_t = 57344;
+pub const S_IRWXO: mode_t = 0x7;
pub const S_IXOTH: mode_t = 0x1;
pub const S_IWOTH: mode_t = 0x2;
pub const S_IROTH: mode_t = 0x4;
+pub const S_IRWXG: mode_t = 0x38;
pub const S_IXGRP: mode_t = 0x8;
pub const S_IWGRP: mode_t = 0x10;
pub const S_IRGRP: mode_t = 0x20;
+pub const S_IRWXU: mode_t = 0x1c0;
pub const S_IXUSR: mode_t = 0x40;
pub const S_IWUSR: mode_t = 0x80;
pub const S_IRUSR: mode_t = 0x100;
@@ -822,4 +825,6 @@ extern "C" {
pub fn arc4random() -> u32;
pub fn arc4random_buf(a: *mut c_void, b: size_t);
pub fn arc4random_uniform(a: u32) -> u32;
+
+ pub fn __errno_location() -> *mut ::c_int;
}