diff --git a/src/fuchsia/aarch64.rs b/src/fuchsia/aarch64.rs index 93090f7238d7a..0994711a03f3d 100644 --- a/src/fuchsia/aarch64.rs +++ b/src/fuchsia/aarch64.rs @@ -1,10 +1,11 @@ use crate::off_t; use crate::prelude::*; +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. The Fuchsia SDK doesn't ship it." +)] pub type __u64 = c_ulonglong; -pub type wchar_t = u32; -pub type nlink_t = c_ulong; -pub type blksize_t = c_long; s! { pub struct stat { @@ -15,20 +16,21 @@ s! { pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, pub st_rdev: crate::dev_t, - __pad0: Padding, + __pad: Padding, pub st_size: off_t, pub st_blksize: crate::blksize_t, - __pad1: Padding, + __pad2: Padding, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, - __unused: Padding<[c_uint; 2]>, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, + __unused1: Padding<[c_uint; 2]>, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK.", + )] pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -51,6 +53,10 @@ s! { __unused: Padding<[c_uint; 2]>, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK.", + )] pub struct ipc_perm { pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, @@ -62,6 +68,25 @@ s! { __unused1: Padding, __unused2: Padding, } + + // FIXME(i128): __reserved is meant to be an array of `long double`s. That + // requires native support for `i128`. This is currently missing. + pub struct mcontext_t { + pub fault_address: c_ulong, + pub regs: [c_ulong; 31], + pub sp: c_ulong, + pub pc: c_ulong, + pub pstate: c_ulong, + __reserved: Padding<[c_longlong; 256]>, + } + + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut crate::ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_sigmask: crate::sigset_t, + pub uc_mcontext: crate::mcontext_t, + } } // From https://cs.opensource.google/fuchsia/fuchsia/+/main:zircon/third_party/ulib/musl/include/bits/signal.h;l=20-21;drc=0827b18ab9540c46f8037f407d17ea15a79e9ba7 diff --git a/src/fuchsia/mod.rs b/src/fuchsia/mod.rs index 20bf7401e570f..7fc6ce1cb93a2 100644 --- a/src/fuchsia/mod.rs +++ b/src/fuchsia/mod.rs @@ -9,6 +9,7 @@ use crate::prelude::*; pub type intmax_t = i64; pub type uintmax_t = u64; +pub type wchar_t = u32; pub type locale_t = *mut c_void; @@ -16,36 +17,64 @@ pub type size_t = usize; pub type ptrdiff_t = isize; pub type intptr_t = isize; pub type uintptr_t = usize; -pub type ssize_t = isize; +pub type ssize_t = crate::intptr_t; -pub type pid_t = i32; -pub type uid_t = u32; -pub type gid_t = u32; +pub type pid_t = c_int; +pub type uid_t = c_uint; +pub type gid_t = c_uint; pub type in_addr_t = u32; pub type in_port_t = u16; -pub type sighandler_t = size_t; pub type cc_t = c_uchar; -pub type sa_family_t = u16; +pub type sa_family_t = c_ushort; pub type pthread_key_t = c_uint; pub type speed_t = c_uint; pub type tcflag_t = c_uint; pub type clockid_t = c_int; pub type key_t = c_int; pub type id_t = c_uint; -pub type useconds_t = u32; -pub type dev_t = u64; -pub type socklen_t = u32; +pub type useconds_t = c_uint; +pub type dev_t = c_ulonglong; +pub type socklen_t = c_uint; pub type pthread_t = c_ulong; -pub type mode_t = u32; -pub type ino64_t = u64; -pub type off64_t = i64; -pub type blkcnt64_t = i64; -pub type rlim64_t = u64; -pub type mqd_t = c_int; +pub type mode_t = c_uint; pub type nfds_t = c_ulong; pub type nl_item = c_int; pub type idtype_t = c_uint; -pub type loff_t = c_longlong; +pub type loff_t = crate::off_t; +pub type nlink_t = c_ulong; +pub type blksize_t = c_long; + +pub type sighandler_t = extern "C" fn(c_int); + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist usptream. It's not part of the Fuchsia SDK." +)] +pub type mqd_t = c_int; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist usptream. It's not part of the Fuchsia SDK." +)] +pub type off64_t = i64; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist usptream. It's not part of the Fuchsia SDK." +)] +pub type ino64_t = u64; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist usptream. It's not part of the Fuchsia SDK." +)] +pub type blkcnt64_t = i64; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist upstream. It's not part of the Fuchsia SDK." +)] +pub type rlim64_t = u64; pub type __u8 = c_uchar; pub type __u16 = c_ushort; @@ -76,11 +105,27 @@ pub type msgqnum_t = c_ulong; pub type msglen_t = c_ulong; pub type fsblkcnt_t = c_ulonglong; pub type fsfilcnt_t = c_ulonglong; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist upstream. It's not part of the Fuchsia SDK." +)] pub type rlim_t = c_ulonglong; +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist upstream. It's not part of the Fuchsia SDK.", +)] +pub type statfs64 = statfs; + extern_ty! { pub enum timezone {} pub enum DIR {} + + #[deprecated( + since = "0.2.187", + note = "Use `fpos_t` instead. This type does not exist upstream." + )] pub enum fpos64_t {} // FIXME(fuchsia): fill this out with a struct } @@ -111,8 +156,7 @@ s! { pub tv_nsec: c_long, } - // FIXME(fuchsia): the rlimit and rusage related functions and types don't exist - // within zircon. Are there reasons for keeping them around? + #[deprecated(since = "0.2.187", note = "This type does not exist upstream.")] pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, @@ -267,15 +311,6 @@ s! { __dummy4: [c_char; 16], } - // FIXME(1.0): This should not implement `PartialEq` - #[allow(unpredictable_function_pointer_comparisons)] - pub struct sigaction { - pub sa_sigaction: crate::sighandler_t, - pub sa_mask: crate::sigset_t, - pub sa_flags: c_int, - pub sa_restorer: Option, - } - pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -354,7 +389,7 @@ s! { } pub struct fd_set { - fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], + pub fds_bits: [c_ulong; FD_SETSIZE as usize / 8 / size_of::()], } pub struct tm { @@ -386,6 +421,11 @@ s! { pub dli_saddr: *mut c_void, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. The Fuchsia SDK doesn't ship it.", + )] + #[allow(deprecated)] pub struct epoll_event { pub events: u32, pub data: epoll_data, @@ -418,22 +458,21 @@ s! { pub int_n_sign_posn: c_char, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist upstream. It is not part of the Fuchsia SDK." + )] pub struct rlimit64 { pub rlim_cur: rlim64_t, pub rlim_max: rlim64_t, } pub struct glob_t { - pub gl_pathc: size_t, + pub gl_pathc: crate::size_t, pub gl_pathv: *mut *mut c_char, - pub gl_offs: size_t, - pub gl_flags: c_int, - - __unused1: Padding<*mut c_void>, - __unused2: Padding<*mut c_void>, - __unused3: Padding<*mut c_void>, - __unused4: Padding<*mut c_void>, - __unused5: Padding<*mut c_void>, + pub gl_offs: crate::size_t, + __dummy1: Padding, + __dummy2: Padding<[*mut c_void; 5]>, } pub struct ifaddrs { @@ -477,15 +516,10 @@ s! { pub f_files: crate::fsfilcnt_t, pub f_ffree: crate::fsfilcnt_t, pub f_favail: crate::fsfilcnt_t, - #[cfg(target_endian = "little")] - pub f_fsid: c_ulong, - #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] - __f_unused: Padding, - #[cfg(target_endian = "big")] pub f_fsid: c_ulong, pub f_flag: c_ulong, pub f_namemax: c_ulong, - __f_spare: [c_int; 6], + __f_spare: Padding<[c_int; 6]>, } pub struct dqblk { @@ -531,14 +565,11 @@ s! { } pub struct fsid_t { - __val: [c_int; 2], + pub __val: [c_int; 2], } pub struct cpu_set_t { - #[cfg(all(target_pointer_width = "32", not(target_arch = "x86_64")))] - bits: [u32; 32], - #[cfg(not(all(target_pointer_width = "32", not(target_arch = "x86_64"))))] - bits: [u64; 16], + pub __bits: [c_ulonglong; 128 / size_of::()], } pub struct if_nameindex { @@ -663,6 +694,10 @@ s! { pub weak_magnitude: crate::__u16, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist usptream. It's not included in the Fuchsia SDK.", + )] pub struct ff_effect { pub type_: crate::__u16, pub id: crate::__s16, @@ -677,26 +712,13 @@ s! { } pub struct dl_phdr_info { - #[cfg(target_pointer_width = "64")] pub dlpi_addr: Elf64_Addr, - #[cfg(target_pointer_width = "32")] - pub dlpi_addr: Elf32_Addr, - pub dlpi_name: *const c_char, - - #[cfg(target_pointer_width = "64")] pub dlpi_phdr: *const Elf64_Phdr, - #[cfg(target_pointer_width = "32")] - pub dlpi_phdr: *const Elf32_Phdr, - - #[cfg(target_pointer_width = "64")] pub dlpi_phnum: Elf64_Half, - #[cfg(target_pointer_width = "32")] - pub dlpi_phnum: Elf32_Half, - pub dlpi_adds: c_ulonglong, pub dlpi_subs: c_ulonglong, - pub dlpi_tls_modid: size_t, + pub dlpi_tls_modid: crate::size_t, pub dlpi_tls_data: *mut c_void, } @@ -722,21 +744,10 @@ s! { pub p_align: Elf64_Xword, } - pub struct statfs64 { - pub f_type: c_ulong, - pub f_bsize: c_ulong, - pub f_blocks: crate::fsblkcnt_t, - pub f_bfree: crate::fsblkcnt_t, - pub f_bavail: crate::fsblkcnt_t, - pub f_files: crate::fsfilcnt_t, - pub f_ffree: crate::fsfilcnt_t, - pub f_fsid: crate::fsid_t, - pub f_namelen: c_ulong, - pub f_frsize: c_ulong, - pub f_flags: c_ulong, - pub f_spare: [c_ulong; 4], - } - + #[deprecated( + since = "0.2.187", + note = "Use `statvfs` instead. This type doesn't exist upstream." + )] pub struct statvfs64 { pub f_bsize: c_ulong, pub f_frsize: c_ulong, @@ -759,11 +770,19 @@ s! { } pub struct pthread_attr_t { - __size: [u64; 7], + pub __name: *const c_char, + pub __c11: c_int, + pub _a_stacksize: crate::size_t, + pub _a_guardsize: crate::size_t, + pub _a_stackaddr: *mut c_void, + pub _a_detach: c_int, + pub _a_sched: c_int, + pub _a_policy: c_int, + pub _a_prio: c_int, } pub struct sigset_t { - __val: [c_ulong; 16], + pub __bits: [c_ulong; 128 / size_of::()], } pub struct shmid_ds { @@ -828,17 +847,22 @@ s! { } pub struct sem_t { - __val: [c_int; 8], + pub _s_value: c_int, + pub _s_waiters: c_int, } + #[repr(align(8))] pub struct siginfo_t { pub si_signo: c_int, pub si_errno: c_int, pub si_code: c_int, - pub _pad: [c_int; 29], - _align: [usize; 0], + pub __si_fields: [c_int; 28], } + #[deprecated( + since = "0.2.187", + note = "Use `termios`. This type doesn't exist. The Fuchsia SDK doesn't include it.", + )] pub struct termios2 { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -855,29 +879,19 @@ s! { pub ipi6_ifindex: c_uint, } - #[cfg_attr( - any(target_pointer_width = "32", target_arch = "x86_64"), - repr(align(4)) - )] - #[cfg_attr( - not(any(target_pointer_width = "32", target_arch = "x86_64")), - repr(align(8)) - )] pub struct pthread_mutexattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_MUTEXATTR_T], + pub __attr: c_uint, } - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] pub struct pthread_rwlockattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_RWLOCKATTR_T], + pub __attr: [c_uint; 2], } - #[repr(align(4))] pub struct pthread_condattr_t { - size: [u8; crate::__SIZEOF_PTHREAD_CONDATTR_T], + pub __attr: c_uint, } + #[deprecated(since = "0.2.187", note = "This type doesn't exist upstream.")] pub struct sysinfo { pub uptime: c_ulong, pub loads: [c_ulong; 3], @@ -902,13 +916,15 @@ s! { pub struct sockaddr_storage { pub ss_family: sa_family_t, - __ss_pad2: Padding<[u8; 128 - 2 - 8]>, - __ss_align: size_t, + __ss_padding: Padding< + [c_char; 128 - size_of::() - size_of::()] + >, + __ss_align: c_ulong, } pub struct utsname { pub sysname: [c_char; 65], - pub nodename: [c_char; 65], + pub nodename: [c_char; crate::HOST_NAME_MAX.cast_unsigned() as usize + 1], pub release: [c_char; 65], pub version: [c_char; 65], pub machine: [c_char; 65], @@ -917,12 +933,17 @@ s! { pub struct dirent { pub d_ino: crate::ino_t, - pub d_off: off_t, + pub d_off: crate::off_t, pub d_reclen: c_ushort, pub d_type: c_uchar, pub d_name: [c_char; 256], } + #[deprecated( + since = "0.2.187", + note = "Use `dirent` instead. This type doesn't exist. It's not part of the Fuchsia SDK." + )] + #[allow(deprecated)] pub struct dirent64 { pub d_ino: crate::ino64_t, pub d_off: off64_t, @@ -931,8 +952,10 @@ s! { pub d_name: [c_char; 256], } - // x32 compatibility - // See https://sourceware.org/bugzilla/show_bug.cgi?id=21279 + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist upstream. It's not part of the Fuchsia SDK.", + )] pub struct mq_attr { #[cfg(all(target_arch = "x86_64", target_pointer_width = "32"))] pub mq_flags: i64, @@ -957,6 +980,10 @@ s! { pad: Padding<[c_long; 4]>, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist upstream. It's not part of the Fuchsia SDK.", + )] pub struct sockaddr_nl { pub nl_family: crate::sa_family_t, nl_pad: Padding, @@ -970,53 +997,28 @@ s! { pub sigev_value: crate::sigval, pub sigev_signo: c_int, pub sigev_notify: c_int, - pub sigev_notify_function: fn(crate::sigval), + pub sigev_notify_function: Option, pub sigev_notify_attributes: *mut pthread_attr_t, - pub __pad: [c_char; 56 - 3 * 8], + __pad: Padding<[c_char; 56 - 3 * size_of::()]>, } - #[cfg_attr( - all( - target_pointer_width = "32", - any(target_arch = "arm", target_arch = "x86_64") - ), - repr(align(4)) - )] - #[cfg_attr( - any( - target_pointer_width = "64", - not(any(target_arch = "arm", target_arch = "x86_64")) - ), - repr(align(8)) - )] pub struct pthread_mutex_t { - size: [u8; crate::__SIZEOF_PTHREAD_MUTEX_T], + pub _m_attr: c_uint, + pub _m_lock: c_int, + pub _m_waiters: c_int, + pub _m_count: c_int, } - #[cfg_attr( - all( - target_pointer_width = "32", - any(target_arch = "arm", target_arch = "x86_64") - ), - repr(align(4)) - )] - #[cfg_attr( - any( - target_pointer_width = "64", - not(any(target_arch = "arm", target_arch = "x86_64")) - ), - repr(align(8)) - )] pub struct pthread_rwlock_t { - size: [u8; crate::__SIZEOF_PTHREAD_RWLOCK_T], + pub _rw_lock: c_int, + pub _rw_waiters: c_int, } - #[cfg_attr(target_pointer_width = "32", repr(align(4)))] - #[cfg_attr(target_pointer_width = "64", repr(align(8)))] - #[cfg_attr(target_arch = "x86", repr(align(4)))] - #[cfg_attr(not(target_arch = "x86"), repr(align(8)))] pub struct pthread_cond_t { - size: [u8; crate::__SIZEOF_PTHREAD_COND_T], + pub _c_head: *mut c_void, + pub _c_clock: c_int, + pub _c_tail: *mut c_void, + pub _c_lock: c_int, } } @@ -1026,6 +1028,15 @@ s_no_extra_traits! { pub sival_ptr: *mut c_void, } + pub union fpos_t { + __opaque: [c_char; 16], + __align: c_double, + } + + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK.", + )] pub union epoll_data { pub ptr: *mut c_void, pub fd: c_int, @@ -1037,40 +1048,61 @@ s_no_extra_traits! { ifu_broadaddr: *mut sockaddr, ifu_dstaddr: *mut sockaddr, } + + pub union __c_anonymous_sigaction___sa_handler { + sa_handler: Option, + sa_sigaction: Option, + } + + pub struct sigaction { + pub __sa_handler: crate::__c_anonymous_sigaction___sa_handler, + pub sa_mask: crate::sigset_t, + pub sa_flags: c_int, + pub sa_restorer: Option, + } } cfg_if! { if #[cfg(feature = "extra_traits")] { + #[allow(deprecated)] impl PartialEq for sigval { fn eq(&self, _other: &sigval) -> bool { unimplemented!("traits") } } + #[allow(deprecated)] impl Eq for sigval {} + #[allow(deprecated)] impl hash::Hash for sigval { fn hash(&self, _state: &mut H) { unimplemented!("traits") } } + #[allow(deprecated)] impl PartialEq for epoll_data { fn eq(&self, _other: &epoll_data) -> bool { unimplemented!("traits") } } + #[allow(deprecated)] impl Eq for epoll_data {} + #[allow(deprecated)] impl hash::Hash for epoll_data { fn hash(&self, _state: &mut H) { unimplemented!("traits") } } + #[allow(deprecated)] impl PartialEq for __c_anonymous_ifaddrs_ifa_ifu { fn eq(&self, _other: &__c_anonymous_ifaddrs_ifa_ifu) -> bool { unimplemented!("traits") } } + #[allow(deprecated)] impl Eq for __c_anonymous_ifaddrs_ifa_ifu {} + #[allow(deprecated)] impl hash::Hash for __c_anonymous_ifaddrs_ifa_ifu { fn hash(&self, _state: &mut H) { unimplemented!("traits") @@ -1081,12 +1113,14 @@ cfg_if! { // PUB_CONST -pub const INT_MIN: c_int = -2147483648; -pub const INT_MAX: c_int = 2147483647; +pub const HOST_NAME_MAX: c_int = 255; + +pub const INT_MIN: c_int = -1 - 0x7fffffff; +pub const INT_MAX: c_int = 0x7fffffff; -pub const SIG_DFL: sighandler_t = 0 as sighandler_t; -pub const SIG_IGN: sighandler_t = 1 as sighandler_t; -pub const SIG_ERR: sighandler_t = !0 as sighandler_t; +pub const SIG_ERR: Option = None; +pub const SIG_DFL: Option = None; +pub const SIG_IGN: Option = None; pub const DT_UNKNOWN: u8 = 0; pub const DT_FIFO: u8 = 1; @@ -1102,14 +1136,14 @@ pub const FD_CLOEXEC: c_int = 0x1; pub const USRQUOTA: c_int = 0; pub const GRPQUOTA: c_int = 1; -pub const SIGIOT: c_int = 6; +pub const SIGIOT: c_int = crate::SIGABRT; pub const S_ISUID: mode_t = 0o4000; pub const S_ISGID: mode_t = 0o2000; pub const S_ISVTX: mode_t = 0o1000; pub const IF_NAMESIZE: size_t = 16; -pub const IFNAMSIZ: size_t = IF_NAMESIZE; +pub const IFNAMSIZ: size_t = crate::IF_NAMESIZE; pub const LOG_EMERG: c_int = 0; pub const LOG_ALERT: c_int = 1; @@ -2030,7 +2064,18 @@ pub const _SC_XOPEN_STREAMS: c_int = 246; pub const _SC_THREAD_ROBUST_PRIO_INHERIT: c_int = 247; pub const _SC_THREAD_ROBUST_PRIO_PROTECT: c_int = 248; +#[deprecated( + since = "0.2.187", + note = "This doesn't exist upstream. It's not part of the Fuchsia SDK." +)] +#[allow(deprecated)] pub const RLIM_SAVED_MAX: crate::rlim_t = RLIM_INFINITY; + +#[deprecated( + since = "0.2.187", + note = "This doesn't exist upstream. It's not part of the Fuchsia SDK." +)] +#[allow(deprecated)] pub const RLIM_SAVED_CUR: crate::rlim_t = RLIM_INFINITY; pub const GLOB_ERR: c_int = 1 << 0; @@ -2083,13 +2128,20 @@ pub const RTLD_NOW: c_int = 0x2; pub const TCP_MD5SIG: c_int = 14; pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t { - size: [0; __SIZEOF_PTHREAD_MUTEX_T], + _m_attr: 0, + _m_lock: 0, + _m_waiters: 0, + _m_count: 0, }; pub const PTHREAD_COND_INITIALIZER: pthread_cond_t = pthread_cond_t { - size: [0; __SIZEOF_PTHREAD_COND_T], + _c_head: ptr::null_mut(), + _c_clock: 0, + _c_tail: ptr::null_mut(), + _c_lock: 0, }; pub const PTHREAD_RWLOCK_INITIALIZER: pthread_rwlock_t = pthread_rwlock_t { - size: [0; __SIZEOF_PTHREAD_RWLOCK_T], + _rw_lock: 0, + _rw_waiters: 0, }; pub const PTHREAD_MUTEX_NORMAL: c_int = 0; pub const PTHREAD_MUTEX_RECURSIVE: c_int = 1; @@ -2097,7 +2149,6 @@ pub const PTHREAD_MUTEX_ERRORCHECK: c_int = 2; pub const PTHREAD_MUTEX_DEFAULT: c_int = PTHREAD_MUTEX_NORMAL; pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; pub const PTHREAD_PROCESS_SHARED: c_int = 1; -pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const RENAME_NOREPLACE: c_int = 1; pub const RENAME_EXCHANGE: c_int = 2; @@ -2574,12 +2625,30 @@ pub const POSIX_FADV_NOREUSE: c_int = 5; pub const POSIX_MADV_DONTNEED: c_int = 4; +#[deprecated( + since = "0.2.187", + note = "This doesn't exist upstream. It's not part of the Fuchsia SDK." +)] +#[allow(deprecated)] pub const RLIM_INFINITY: crate::rlim_t = !0; + +#[deprecated( + since = "0.2.187", + note = "This doesn't exist upstream. It's not part of the Fuchsia SDK." +)] +#[allow(deprecated)] pub const RLIMIT_RTTIME: c_int = 15; -#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] + +#[deprecated( + since = "0.2.64", + note = "This doesn't exist upstream. It's not part of the Fuchsia SDK." +)] pub const RLIMIT_NLIMITS: c_int = 16; +#[deprecated( + since = "0.2.64", + note = "This doesn't exist upstream. It's not part of the Fuchsia SDK." +)] #[allow(deprecated)] -#[deprecated(since = "0.2.64", note = "Not stable across OS versions")] pub const RLIM_NLIMITS: c_int = RLIMIT_NLIMITS; pub const MAP_ANONYMOUS: c_int = MAP_ANON; @@ -3004,17 +3073,6 @@ pub const O_NOFOLLOW: c_int = 0x00000080; pub const HUGETLB_FLAG_ENCODE_SHIFT: u32 = 26; pub const MAP_HUGE_SHIFT: u32 = 26; -// intentionally not public, only used for fd_set -cfg_if! { - if #[cfg(target_pointer_width = "32")] { - const ULONG_SIZE: usize = 32; - } else if #[cfg(target_pointer_width = "64")] { - const ULONG_SIZE: usize = 64; - } else { - // Unknown target_pointer_width - } -} - // END_PUB_CONST f! { @@ -3043,31 +3101,36 @@ f! { } pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () { - cpuset.bits.fill(0); + cpuset.__bits.fill(0); } - pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc - let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - cpuset.bits[idx] |= 1 << offset; - () + pub fn CPU_SET(cpu: usize, cpuset: &mut cpu_set_t) -> c_ulonglong { + (cpu / 8 >= size_of::()).then(|| 0).unwrap_or_else(|| { + let c = &mut cpuset.__bits[cpu / 8 / size_of::()]; + *c |= 1 << (cpu % (8 * size_of::())); + + *c + }) } - pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> () { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); // 32, 64 etc - let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - cpuset.bits[idx] &= !(1 << offset); - () + pub fn CPU_CLR(cpu: usize, cpuset: &mut cpu_set_t) -> c_ulonglong { + (cpu / 8 >= size_of::()).then(|| 0).unwrap_or_else(|| { + let c = &mut cpuset.__bits[cpu / 8 / size_of::()]; + *c &= !(1 << (cpu % (8 * size_of::()))); + + *c + }) } pub fn CPU_ISSET(cpu: usize, cpuset: &cpu_set_t) -> bool { - let size_in_bits = 8 * size_of_val(&cpuset.bits[0]); - let (idx, offset) = (cpu / size_in_bits, cpu % size_in_bits); - 0 != (cpuset.bits[idx] & (1 << offset)) + (cpu / 8 >= size_of::()).then(|| false).unwrap_or_else(|| { + (cpuset.__bits[cpu / 8 / size_of::()] + & (1 << (cpu % (8 * size_of::())))) != 0 + }) } pub fn CPU_EQUAL(set1: &cpu_set_t, set2: &cpu_set_t) -> bool { - set1.bits == set2.bits + set1.__bits == set2.__bits } pub fn CMSG_DATA(cmsg: *const cmsghdr) -> *mut c_uchar { @@ -3189,7 +3252,6 @@ extern "C" {} extern_ty! { pub enum FILE {} - pub enum fpos_t {} // FIXME(fuchsia): fill this out with a struct } extern "C" { @@ -3797,7 +3859,7 @@ extern "C" { pub fn fallocate(fd: c_int, mode: c_int, offset: off_t, len: off_t) -> c_int; pub fn posix_fallocate(fd: c_int, offset: off_t, len: off_t) -> c_int; - pub fn readahead(fd: c_int, offset: off64_t, count: size_t) -> ssize_t; + pub fn readahead(fd: c_int, offset: off_t, count: size_t) -> ssize_t; pub fn signalfd(fd: c_int, mask: *const crate::sigset_t, flags: c_int) -> c_int; pub fn timerfd_create(clockid: c_int, flags: c_int) -> c_int; pub fn timerfd_gettime(fd: c_int, curr_value: *mut itimerspec) -> c_int; @@ -3837,7 +3899,7 @@ extern "C" { pub fn mkfifoat(dirfd: c_int, pathname: *const c_char, mode: mode_t) -> c_int; pub fn if_nameindex() -> *mut if_nameindex; pub fn if_freenameindex(ptr: *mut if_nameindex); - pub fn sync_file_range(fd: c_int, offset: off64_t, nbytes: off64_t, flags: c_uint) -> c_int; + pub fn sync_file_range(fd: c_int, offset: off_t, nbytes: off_t, flags: c_uint) -> c_int; pub fn getifaddrs(ifap: *mut *mut crate::ifaddrs) -> c_int; pub fn freeifaddrs(ifa: *mut crate::ifaddrs); diff --git a/src/fuchsia/riscv64.rs b/src/fuchsia/riscv64.rs index bc93cc3bff0a9..8d3c8528b10d3 100644 --- a/src/fuchsia/riscv64.rs +++ b/src/fuchsia/riscv64.rs @@ -1,14 +1,18 @@ -use crate::off_t; use crate::prelude::*; // From psABI Calling Convention for RV64 +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. The Fuchsia SDK doesn't ship it." +)] pub type __u64 = c_ulonglong; -pub type wchar_t = i32; - -pub type nlink_t = c_ulong; -pub type blksize_t = c_long; +#[deprecated( + since = "0.2.187", + note = "Thist type doesn't exist. It's not part of the Fuchsia SDK." +)] pub type stat64 = stat; + s! { pub struct stat { pub st_dev: crate::dev_t, @@ -17,21 +21,22 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: Padding, + __pad0: Padding, pub st_rdev: crate::dev_t, - pub st_size: off_t, + pub st_size: crate::off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, __unused: Padding<[c_long; 3]>, } // Not actually used, IPC calls just return ENOSYS + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. The Fuchsia SDK does not ship it.", + )] pub struct ipc_perm { pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, @@ -43,4 +48,16 @@ s! { __unused1: Padding, __unused2: Padding, } + + pub struct mcontext_t { + pub regs: [c_ulong; 32] + } + + pub struct ucontext_t { + uc_flags: c_ulong, + uc_link: *mut crate::ucontext_t, + uc_stack: crate::stack_t, + uc_sigmask: crate::sigset_t, + uc_mcontext: crate::mcontext_t, + } } diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index fc42cd9810985..d12d8e41ac83a 100644 --- a/src/fuchsia/x86_64.rs +++ b/src/fuchsia/x86_64.rs @@ -1,12 +1,40 @@ use crate::off_t; use crate::prelude::*; -pub type wchar_t = i32; -pub type nlink_t = u64; -pub type blksize_t = c_long; +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. The Fuchsia SDK doesn't ship it." +)] pub type __u64 = c_ulonglong; +pub type gregset_t = [c_ulonglong; 23]; +pub type fpregset_t = *mut _fpstate; + s! { + pub struct __c_anonymous__fpstate__st { + pub significand: [c_ushort; 4], + pub exponent: c_ushort, + pub padding: [c_ushort; 3], + } + + pub struct __c_anonymous__fpstate__xmm { + element: [c_uint; 4], + } + + pub struct _fpstate { + pub cwd: c_ushort, + pub swd: c_ushort, + pub ftw: c_ushort, + pub fop: c_ushort, + pub rip: c_ulonglong, + pub rdp: c_ulonglong, + pub mxcsr: c_uint, + pub mxcr_mask: c_uint, + pub _st: [__c_anonymous__fpstate__st; 8], + pub _xmm: [__c_anonymous__fpstate__xmm; 16], + padding: [c_uint; 24], + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -14,20 +42,21 @@ s! { pub st_mode: crate::mode_t, pub st_uid: crate::uid_t, pub st_gid: crate::gid_t, - __pad0: Padding, + __pad0: Padding, pub st_rdev: crate::dev_t, pub st_size: off_t, pub st_blksize: crate::blksize_t, pub st_blocks: crate::blkcnt_t, - pub st_atime: crate::time_t, - pub st_atime_nsec: c_long, - pub st_mtime: crate::time_t, - pub st_mtime_nsec: c_long, - pub st_ctime: crate::time_t, - pub st_ctime_nsec: c_long, + pub st_atim: crate::timespec, + pub st_mtim: crate::timespec, + pub st_ctim: crate::timespec, __unused: Padding<[c_long; 3]>, } + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK.", + )] pub struct stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino64_t, @@ -50,9 +79,24 @@ s! { } pub struct mcontext_t { - __private: [u64; 32], + pub gregs: crate::gregset_t, + pub fpregs: crate::fpregset_t, + __reserved1: Padding<[c_ulonglong; 8]>, } + pub struct ucontext_t { + pub uc_flags: c_ulong, + pub uc_link: *mut ucontext_t, + pub uc_stack: crate::stack_t, + pub uc_mcontext: crate::mcontext_t, + pub uc_sigmask: crate::sigset_t, + pub __fpregs_mem: [c_ulong; 64], + } + + #[deprecated( + since = "0.2.187", + note = "This type doesn't exist. The Fuchsia SDK doesn't ship with it.", + )] pub struct ipc_perm { pub __ipc_perm_key: crate::key_t, pub uid: crate::uid_t, @@ -64,15 +108,6 @@ s! { __unused1: Padding, __unused2: Padding, } - - pub struct ucontext_t { - pub uc_flags: c_ulong, - pub uc_link: *mut ucontext_t, - pub uc_stack: crate::stack_t, - pub uc_mcontext: mcontext_t, - pub uc_sigmask: crate::sigset_t, - __private: [u8; 512], - } } // offsets in user_regs_structs, from sys/reg.h