diff --git a/src/fuchsia/aarch64.rs b/src/fuchsia/aarch64.rs index 93090f7238d7a..69746ff5803e5 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,10 +16,10 @@ 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, @@ -29,6 +30,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 stat64 { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -51,6 +56,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 +71,25 @@ s! { __unused1: Padding, __unused2: Padding, } + + // FIXME(f128): __reserved is meant to be an array of `long double`s. That + // requires native support for `f128`. 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<[i128; 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 834d4e9fac2b7..e1f9ae30b625e 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,63 @@ 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; + +#[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,12 +104,28 @@ 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 type timezone; pub type DIR; - pub type fpos64_t; // FIXME(fuchsia): fill this out with a struct + + #[deprecated( + since = "0.2.187", + note = "Use `fpos_t` instead. This type does not exist upstream." + )] + pub type fpos64_t; } // PUB_STRUCT @@ -111,8 +155,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, @@ -354,7 +397,7 @@ s! { } pub struct fd_set { - fds_bits: [c_ulong; FD_SETSIZE as usize / ULONG_SIZE], + fds_bits: [c_ulong; FD_SETSIZE as usize / 8 / size_of::()], } pub struct tm { @@ -386,6 +429,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 +466,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 +524,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 +573,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 +702,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 +720,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 +752,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 +778,19 @@ s! { } pub struct pthread_attr_t { - __size: [u64; 7], + __name: *const c_char, + __c11: c_int, + _a_stacksize: crate::size_t, + _a_guardsize: crate::size_t, + _a_stackaddr: *mut c_void, + _a_detach: c_int, + _a_sched: c_int, + _a_policy: c_int, + _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 +855,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 +887,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 +924,14 @@ 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 +940,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 +959,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 +987,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 +1004,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 +1035,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, @@ -1041,36 +1059,45 @@ s_no_extra_traits! { 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,8 +1108,10 @@ 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; @@ -1102,14 +1131,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 +2059,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 +2123,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,6 +2144,11 @@ 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; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK." +)] pub const __SIZEOF_PTHREAD_COND_T: usize = 48; pub const RENAME_NOREPLACE: c_int = 1; @@ -2574,12 +2626,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; @@ -2600,8 +2670,22 @@ pub const TCP_TIMESTAMP: c_int = 24; pub const SIGUNUSED: c_int = crate::SIGSYS; +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK." +)] pub const __SIZEOF_PTHREAD_CONDATTR_T: usize = 4; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK." +)] pub const __SIZEOF_PTHREAD_MUTEXATTR_T: usize = 4; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK." +)] pub const __SIZEOF_PTHREAD_RWLOCKATTR_T: usize = 8; pub const CPU_SETSIZE: c_int = 128; @@ -2740,7 +2824,16 @@ pub const B3000000: crate::speed_t = 0o010015; pub const B3500000: crate::speed_t = 0o010016; pub const B4000000: crate::speed_t = 0o010017; +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK." +)] pub const __SIZEOF_PTHREAD_RWLOCK_T: usize = 56; + +#[deprecated( + since = "0.2.187", + note = "This type doesn't exist. It's not part of the Fuchsia SDK." +)] pub const __SIZEOF_PTHREAD_MUTEX_T: usize = 40; pub const O_ASYNC: c_int = 0x00000400; @@ -3004,17 +3097,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 +3125,43 @@ 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_some(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_some(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_some(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 +3283,6 @@ extern "C" {} extern_ty! { pub type FILE; - pub type fpos_t; // FIXME(fuchsia): fill this out with a struct } extern "C" { @@ -3797,7 +3890,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 +3930,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..e95f98d1bc15b 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,9 +21,9 @@ 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, @@ -32,6 +36,10 @@ s! { } // 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 +51,16 @@ s! { __unused1: Padding, __unused2: Padding, } + + pub struct mcontext_t { + pub regs: [c_ulong; 32], + } + + 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, + } } diff --git a/src/fuchsia/x86_64.rs b/src/fuchsia/x86_64.rs index fc42cd9810985..77079249ae88f 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 _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: Padding<[c_uint; 24]>, + } + + pub struct __c_anonymous__fpstate__st { + pub significand: [c_ushort; 4], + pub exponent: c_ushort, + padding: Padding<[c_ushort; 3]>, + } + + pub struct __c_anonymous__fpstate__xmm { + pub element: [c_uint; 4], + } + pub struct stat { pub st_dev: crate::dev_t, pub st_ino: crate::ino_t, @@ -14,7 +42,7 @@ 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, @@ -28,6 +56,10 @@ s! { __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 +82,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, + __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 +111,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