diff --git a/src/unix/bsd/apple/b32/mod.rs b/src/unix/bsd/apple/b32/mod.rs index 37ef55c0f8e0b..40305772f202e 100644 --- a/src/unix/bsd/apple/b32/mod.rs +++ b/src/unix/bsd/apple/b32/mod.rs @@ -4,7 +4,7 @@ use crate::prelude::*; pub type boolean_t = c_int; -s! { +s2! { pub struct if_data { pub ifi_type: c_uchar, pub ifi_typelen: c_uchar, @@ -37,6 +37,7 @@ s! { ifi_reserved2: Padding, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct bpf_hdr { pub bh_tstamp: crate::timeval, @@ -50,7 +51,7 @@ s! { } } -s_no_extra_traits! { +s_no_extra_traits2! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], diff --git a/src/unix/bsd/apple/b64/aarch64/mod.rs b/src/unix/bsd/apple/b64/aarch64/mod.rs index b5cbe8ff5175f..5aefa0abfd648 100644 --- a/src/unix/bsd/apple/b64/aarch64/mod.rs +++ b/src/unix/bsd/apple/b64/aarch64/mod.rs @@ -2,13 +2,13 @@ use crate::prelude::*; pub type boolean_t = c_int; -s! { +s2! { pub struct malloc_zone_t { __private: [crate::uintptr_t; 18], // FIXME(macos): needs arm64 auth pointers support } } -s_no_extra_traits! { +s_no_extra_traits2! { pub struct max_align_t { priv_: f64, } diff --git a/src/unix/bsd/apple/b64/mod.rs b/src/unix/bsd/apple/b64/mod.rs index a938cf1a2b3e4..b098e1dc01d96 100644 --- a/src/unix/bsd/apple/b64/mod.rs +++ b/src/unix/bsd/apple/b64/mod.rs @@ -2,8 +2,7 @@ use crate::prelude::*; -s! { - #[derive(Default)] +s2! { pub struct timeval32 { pub tv_sec: i32, pub tv_usec: i32, @@ -41,6 +40,7 @@ s! { ifi_reserved2: Padding, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct bpf_hdr { pub bh_tstamp: crate::timeval32, diff --git a/src/unix/bsd/apple/b64/x86_64/mod.rs b/src/unix/bsd/apple/b64/x86_64/mod.rs index dac8c9e3d336d..641e89432e172 100644 --- a/src/unix/bsd/apple/b64/x86_64/mod.rs +++ b/src/unix/bsd/apple/b64/x86_64/mod.rs @@ -2,7 +2,7 @@ use crate::prelude::*; pub type boolean_t = c_uint; -s! { +s2! { pub struct malloc_introspection_t { _private: [crate::uintptr_t; 16], // FIXME(macos): keeping private for now } @@ -34,6 +34,7 @@ s! { ) -> *mut c_void, >, pub destroy: Option, + #[custom_default(ptr::null_mut())] pub zone_name: *const c_char, pub batch_malloc: Option< unsafe extern "C" fn( @@ -50,6 +51,7 @@ s! { num_to_be_freed: c_uint, ), >, + #[custom_default(ptr::null_mut())] pub introspect: *mut malloc_introspection_t, pub version: c_uint, pub memalign: Option< @@ -69,7 +71,7 @@ s! { } } -s_no_extra_traits! { +s_no_extra_traits2! { #[repr(align(16))] pub struct max_align_t { priv_: [f64; 2], diff --git a/src/unix/bsd/apple/mod.rs b/src/unix/bsd/apple/mod.rs index 8a0cd98f6253a..4a780e4d92b05 100644 --- a/src/unix/bsd/apple/mod.rs +++ b/src/unix/bsd/apple/mod.rs @@ -219,27 +219,32 @@ c_enum! { } } -s! { +s2! { + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ip_mreq { pub imr_multiaddr: in_addr, pub imr_interface: in_addr, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ip_mreqn { pub imr_multiaddr: in_addr, pub imr_address: in_addr, pub imr_ifindex: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ip_mreq_source { pub imr_multiaddr: in_addr, pub imr_sourceaddr: in_addr, pub imr_interface: in_addr, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct aiocb { pub aio_fildes: c_int, pub aio_offset: off_t, + #[custom_default(ptr::null_mut())] pub aio_buf: *mut c_void, pub aio_nbytes: size_t, pub aio_reqprio: c_int, @@ -252,6 +257,7 @@ s! { __unused1: Padding, pub gl_offs: size_t, __unused2: Padding, + #[custom_default(ptr::null_mut())] pub gl_pathv: *mut *mut c_char, __unused3: Padding<*mut c_void>, @@ -263,6 +269,7 @@ s! { __unused8: Padding<*mut c_void>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct tm { pub tm_sec: c_int, pub tm_min: c_int, @@ -274,17 +281,22 @@ s! { pub tm_yday: c_int, pub tm_isdst: c_int, pub tm_gmtoff: c_long, + #[custom_default(ptr::null_mut())] pub tm_zone: *mut c_char, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct addrinfo { pub ai_flags: c_int, pub ai_family: c_int, pub ai_socktype: c_int, pub ai_protocol: c_int, pub ai_addrlen: crate::socklen_t, + #[custom_default(ptr::null_mut())] pub ai_canonname: *mut c_char, + #[custom_default(ptr::null_mut())] pub ai_addr: *mut crate::sockaddr, + #[custom_default(ptr::null_mut())] pub ai_next: *mut addrinfo, } @@ -320,12 +332,14 @@ s! { pub si_pid: crate::pid_t, pub si_uid: crate::uid_t, pub si_status: c_int, + #[custom_default(ptr::null_mut())] pub si_addr: *mut c_void, //Requires it to be union for tests //pub si_value: crate::sigval, _pad: Padding<[usize; 9]>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 // FIXME(1.0): This should not implement `PartialEq` #[allow(unpredictable_function_pointer_comparisons)] pub struct sigaction { @@ -335,12 +349,15 @@ s! { pub sa_flags: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct stack_t { + #[custom_default(ptr::null_mut())] pub ss_sp: *mut c_void, pub ss_size: size_t, pub ss_flags: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct fstore_t { pub fst_flags: c_uint, pub fst_posmode: c_int, @@ -356,6 +373,7 @@ s! { pub fp_length: off_t, /* IN: size of the region */ } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ftrimactivefile_t { pub fta_offset: off_t, pub fta_length: off_t, @@ -368,11 +386,13 @@ s! { pub fsr_length: off_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct radvisory { pub ra_offset: off_t, pub ra_count: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct statvfs { pub f_bsize: c_ulong, pub f_frsize: c_ulong, @@ -387,13 +407,19 @@ s! { pub f_namemax: c_ulong, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct Dl_info { + #[custom_default(ptr::null_mut())] pub dli_fname: *const c_char, + #[custom_default(ptr::null_mut())] pub dli_fbase: *mut c_void, + #[custom_default(ptr::null_mut())] pub dli_sname: *const c_char, + #[custom_default(ptr::null_mut())] pub dli_saddr: *mut c_void, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sockaddr_in { pub sin_len: u8, pub sin_family: crate::sa_family_t, @@ -402,6 +428,7 @@ s! { pub sin_zero: [c_char; 8], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct kevent64_s { pub ident: u64, pub filter: i16, @@ -425,6 +452,7 @@ s! { dqb_spare: Padding<[u32; 4]>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct if_msghdr { pub ifm_msglen: c_ushort, pub ifm_version: c_uchar, @@ -435,6 +463,7 @@ s! { pub ifm_data: if_data, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ifa_msghdr { pub ifam_msglen: c_ushort, pub ifam_version: c_uchar, @@ -445,6 +474,7 @@ s! { pub ifam_metric: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ifma_msghdr { pub ifmam_msglen: c_ushort, pub ifmam_version: c_uchar, @@ -454,6 +484,7 @@ s! { pub ifmam_index: c_ushort, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ifma_msghdr2 { pub ifmam_msglen: c_ushort, pub ifmam_version: c_uchar, @@ -479,6 +510,7 @@ s! { rmx_filler: Padding<[u32; 4]>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct rt_msghdr { pub rtm_msglen: c_ushort, @@ -511,6 +543,7 @@ s! { pub rtm_rmx: rt_metrics, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct termios { pub c_iflag: crate::tcflag_t, pub c_oflag: crate::tcflag_t, @@ -521,6 +554,7 @@ s! { pub c_ospeed: crate::speed_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct flock { pub l_start: off_t, pub l_len: off_t, @@ -529,23 +563,37 @@ s! { pub l_whence: c_short, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sf_hdtr { + #[custom_default(ptr::null_mut())] pub headers: *mut crate::iovec, pub hdr_cnt: c_int, + #[custom_default(ptr::null_mut())] pub trailers: *mut crate::iovec, pub trl_cnt: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct lconv { + #[custom_default(ptr::null_mut())] pub decimal_point: *mut c_char, + #[custom_default(ptr::null_mut())] pub thousands_sep: *mut c_char, + #[custom_default(ptr::null_mut())] pub grouping: *mut c_char, + #[custom_default(ptr::null_mut())] pub int_curr_symbol: *mut c_char, + #[custom_default(ptr::null_mut())] pub currency_symbol: *mut c_char, + #[custom_default(ptr::null_mut())] pub mon_decimal_point: *mut c_char, + #[custom_default(ptr::null_mut())] pub mon_thousands_sep: *mut c_char, + #[custom_default(ptr::null_mut())] pub mon_grouping: *mut c_char, + #[custom_default(ptr::null_mut())] pub positive_sign: *mut c_char, + #[custom_default(ptr::null_mut())] pub negative_sign: *mut c_char, pub int_frac_digits: c_char, pub frac_digits: c_char, @@ -563,6 +611,7 @@ s! { pub int_n_sign_posn: c_char, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct proc_taskinfo { pub pti_virtual_size: u64, @@ -585,6 +634,7 @@ s! { pub pti_priority: i32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct proc_bsdinfo { pub pbi_flags: u32, @@ -641,12 +691,14 @@ s! { pbsi_rfu: Padding, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct proc_taskallinfo { pub pbsd: proc_bsdinfo, pub ptinfo: proc_taskinfo, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct xsw_usage { pub xsu_total: u64, pub xsu_avail: u64, @@ -655,6 +707,7 @@ s! { pub xsu_encrypted: crate::boolean_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct xucred { pub cr_version: c_uint, pub cr_uid: crate::uid_t, @@ -662,6 +715,7 @@ s! { pub cr_groups: [crate::gid_t; 16], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct segment_command { pub cmd: u32, pub cmdsize: u32, @@ -676,6 +730,7 @@ s! { pub flags: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct segment_command_64 { pub cmd: u32, pub cmdsize: u32, @@ -690,11 +745,13 @@ s! { pub flags: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct load_command { pub cmd: u32, pub cmdsize: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sockaddr_dl { pub sdl_len: c_uchar, pub sdl_family: c_uchar, @@ -706,6 +763,7 @@ s! { pub sdl_data: [c_char; 12], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct sockaddr_inarp { pub sin_len: c_uchar, @@ -727,12 +785,14 @@ s! { sc_reserved: Padding<[u32; 5]>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct in_pktinfo { pub ipi_ifindex: c_uint, pub ipi_spec_dst: crate::in_addr, pub ipi_addr: crate::in_addr, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct in6_pktinfo { pub ipi6_addr: crate::in6_addr, pub ipi6_ifindex: c_uint, @@ -740,6 +800,7 @@ s! { // sys/ipc.h: + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ipc_perm { pub uid: crate::uid_t, pub gid: crate::gid_t, @@ -751,6 +812,7 @@ s! { } // sys/sem.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sembuf { pub sem_num: c_ushort, pub sem_op: c_short, @@ -758,6 +820,7 @@ s! { } // sys/if_arp.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct arphdr { pub ar_hrd: u16, @@ -767,11 +830,13 @@ s! { pub ar_op: u16, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct in_addr { pub s_addr: crate::in_addr_t, } // net/ndrv.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct sockaddr_ndrv { pub snd_len: c_uchar, @@ -781,14 +846,18 @@ s! { // sys/socket.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sa_endpoints_t { - pub sae_srcif: c_uint, // optional source interface + pub sae_srcif: c_uint, // optional source interface + #[custom_default(ptr::null_mut())] pub sae_srcaddr: *const crate::sockaddr, // optional source address - pub sae_srcaddrlen: crate::socklen_t, // size of source address + pub sae_srcaddrlen: crate::socklen_t, // size of source address + #[custom_default(ptr::null_mut())] pub sae_dstaddr: *const crate::sockaddr, // destination address - pub sae_dstaddrlen: crate::socklen_t, // size of destination address + pub sae_dstaddrlen: crate::socklen_t, // size of destination address } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct timex { pub modes: c_uint, pub offset: c_long, @@ -809,6 +878,7 @@ s! { pub stbcnt: c_long, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ntptimeval { pub time: crate::timespec, pub maxerror: c_long, @@ -817,14 +887,17 @@ s! { pub time_state: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_standard_policy { pub no_data: natural_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_extended_policy { pub timeshare: boolean_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_time_constraint_policy { pub period: u32, pub computation: u32, @@ -832,27 +905,33 @@ s! { pub preemptible: boolean_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_precedence_policy { pub importance: integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_affinity_policy { pub affinity_tag: integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_background_policy { pub priority: integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_latency_qos_policy { pub thread_latency_qos_tier: thread_latency_qos_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_throughput_qos_policy { pub thread_throughput_qos_tier: thread_throughput_qos_t, } // malloc/malloc.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct malloc_statistics_t { pub blocks_in_use: c_uint, pub size_in_use: size_t, @@ -860,6 +939,7 @@ s! { pub size_allocated: size_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct mstats { pub bytes_total: size_t, pub chunks_used: size_t, @@ -868,6 +948,7 @@ s! { pub bytes_free: size_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct vm_range_t { pub address: crate::vm_address_t, pub size: crate::vm_size_t, @@ -906,18 +987,22 @@ s! { pub vi_fsid: crate::fsid_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct vnode_info_path { pub vip_vi: vnode_info, + #[custom_default([0; crate::MAXPATHLEN as usize])] pub vip_path: [c_char; crate::MAXPATHLEN as usize], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct proc_vnodepathinfo { pub pvi_cdir: vnode_info_path, pub pvi_rdir: vnode_info_path, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct vm_statistics { pub free_count: natural_t, pub active_count: natural_t, @@ -936,11 +1021,13 @@ s! { pub speculative_count: natural_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct task_thread_times_info { pub user_time: time_value_t, pub system_time: time_value_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rusage_info_v0 { pub ri_uuid: [u8; 16], pub ri_user_time: u64, @@ -955,6 +1042,7 @@ s! { pub ri_proc_exit_abstime: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rusage_info_v1 { pub ri_uuid: [u8; 16], pub ri_user_time: u64, @@ -975,6 +1063,7 @@ s! { pub ri_child_elapsed_abstime: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rusage_info_v2 { pub ri_uuid: [u8; 16], pub ri_user_time: u64, @@ -997,6 +1086,7 @@ s! { pub ri_diskio_byteswritten: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rusage_info_v3 { pub ri_uuid: [u8; 16], pub ri_user_time: u64, @@ -1028,6 +1118,7 @@ s! { pub ri_serviced_system_time: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rusage_info_v4 { pub ri_uuid: [u8; 16], pub ri_user_time: u64, @@ -1067,6 +1158,7 @@ s! { pub ri_runnable_time: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct image_offset { pub uuid: crate::uuid_t, pub offset: u32, @@ -1082,16 +1174,19 @@ s! { pub forkattr: attrgroup_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct attrreference_t { pub attr_dataoffset: i32, pub attr_length: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct vol_capabilities_attr_t { pub capabilities: vol_capabilities_set_t, pub valid: vol_capabilities_set_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct attribute_set_t { pub commonattr: attrgroup_t, pub volattr: attrgroup_t, @@ -1100,6 +1195,7 @@ s! { pub forkattr: attrgroup_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct vol_attributes_attr_t { pub validattr: attribute_set_t, pub nativeattr: attribute_set_t, @@ -1148,6 +1244,7 @@ s! { pub tcpi_rxretransmitpackets: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct in6_addrlifetime { pub ia6t_expire: time_t, @@ -1156,6 +1253,7 @@ s! { pub ia6t_pltime: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct in6_ifstat { pub ifs6_in_receive: crate::u_quad_t, @@ -1185,6 +1283,7 @@ s! { pub ifs6_defrtr_expiry_cnt: crate::u_quad_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct icmp6_ifstat { pub ifs6_in_msg: crate::u_quad_t, @@ -1224,6 +1323,7 @@ s! { } // mach/host_info.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct host_cpu_load_info { pub cpu_ticks: [crate::natural_t; CPU_STATE_MAX as usize], } @@ -1249,6 +1349,7 @@ s! { pub ifmd_data: if_data64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct ifs_iso_8802_3 { pub dot3StatsAlignmentErrors: u32, @@ -1270,19 +1371,23 @@ s! { } // kern_control.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct ctl_info { pub ctl_id: u32, + #[custom_default([0; MAX_KCTL_NAME])] pub ctl_name: [c_char; MAX_KCTL_NAME], } // sys/proc_info.h + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct proc_fdinfo { pub proc_fd: i32, pub proc_fdtype: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct kevent { pub ident: crate::uintptr_t, @@ -1290,6 +1395,7 @@ s! { pub flags: u16, pub fflags: u32, pub data: intptr_t, + #[custom_default(ptr::null_mut())] pub udata: *mut c_void, } @@ -1320,6 +1426,7 @@ s! { shm_internal: Padding<*mut c_void>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct proc_threadinfo { pub pth_user_time: u64, @@ -1332,6 +1439,7 @@ s! { pub pth_curpri: i32, pub pth_priority: i32, pub pth_maxpriority: i32, + #[custom_default([0; MAXTHREADNAMESIZE])] pub pth_name: [c_char; MAXTHREADNAMESIZE], } @@ -1348,19 +1456,24 @@ s! { pub f_type: u32, pub f_flags: u32, pub f_fssubtype: u32, + #[custom_default([0; 16])] pub f_fstypename: [c_char; 16], + #[custom_default([0; 1024])] pub f_mntonname: [c_char; 1024], + #[custom_default([0; 1024])] pub f_mntfromname: [c_char; 1024], pub f_flags_ext: u32, f_reserved: Padding<[u32; 7]>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct dirent { pub d_ino: u64, pub d_seekoff: u64, pub d_reclen: u16, pub d_namlen: u16, pub d_type: u8, + #[custom_default([0; 1024])] pub d_name: [c_char; 1024], } @@ -1369,16 +1482,19 @@ s! { pub ss_family: crate::sa_family_t, __ss_pad1: Padding<[u8; 6]>, __ss_align: i64, + #[custom_default(Padding::new([0; 112]))] __ss_pad2: Padding<[u8; 112]>, } // netinet/in.h: RFC 3678 multicast group membership requests. + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct group_req { pub gr_interface: u32, pub gr_group: crate::sockaddr_storage, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct group_source_req { pub gsr_interface: u32, @@ -1387,12 +1503,14 @@ s! { } pub struct utmpx { + #[custom_default([0; _UTX_USERSIZE])] pub ut_user: [c_char; _UTX_USERSIZE], pub ut_id: [c_char; _UTX_IDSIZE], pub ut_line: [c_char; _UTX_LINESIZE], pub ut_pid: crate::pid_t, pub ut_type: c_short, pub ut_tv: crate::timeval, + #[custom_default([0; _UTX_HOSTSIZE])] pub ut_host: [c_char; _UTX_HOSTSIZE], ut_pad: Padding<[u32; 16]>, } @@ -1402,12 +1520,16 @@ s! { pub sigev_signo: c_int, pub sigev_value: crate::sigval, __unused1: Padding<*mut c_void>, //actually a function pointer + #[custom_default(ptr::null_mut())] pub sigev_notify_attributes: *mut crate::pthread_attr_t, } + + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct processor_cpu_load_info { pub cpu_ticks: [c_uint; CPU_STATE_MAX as usize], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct processor_basic_info { pub cpu_type: cpu_type_t, pub cpu_subtype: cpu_subtype_t, @@ -1416,11 +1538,13 @@ s! { pub is_master: crate::boolean_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct processor_set_basic_info { pub processor_count: c_int, pub default_policy: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct processor_set_load_info { pub task_count: c_int, pub thread_count: c_int, @@ -1428,11 +1552,13 @@ s! { pub mach_factor: integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct time_value_t { pub seconds: integer_t, pub microseconds: integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_basic_info { pub user_time: time_value_t, pub system_time: time_value_t, @@ -1444,12 +1570,14 @@ s! { pub sleep_time: crate::integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_identifier_info { pub thread_id: u64, pub thread_handle: u64, pub dispatch_qaddr: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct thread_extended_info { pub pth_user_time: u64, pub pth_system_time: u64, @@ -1461,9 +1589,11 @@ s! { pub pth_curpri: i32, pub pth_priority: i32, pub pth_maxpriority: i32, + #[custom_default([0; MAXTHREADNAMESIZE])] pub pth_name: [c_char; MAXTHREADNAMESIZE], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct if_data64 { pub ifi_type: c_uchar, @@ -1496,6 +1626,7 @@ s! { pub ifi_lastchange: timeval32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct if_msghdr2 { pub ifm_msglen: c_ushort, @@ -1511,6 +1642,7 @@ s! { pub ifm_data: if_data64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(8))] pub struct vm_statistics64 { pub free_count: natural_t, @@ -1572,6 +1704,7 @@ s! { pub phantom_ghosts_added: u64, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct mach_task_basic_info { pub virtual_size: mach_vm_size_t, @@ -1583,6 +1716,7 @@ s! { pub suspend_count: integer_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct log2phys { pub l2p_flags: c_uint, @@ -1603,12 +1737,14 @@ s! { pub svm_cid: c_uint, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ifdevmtu { pub ifdm_current: c_int, pub ifdm_min: c_int, pub ifdm_max: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct ifkpi { pub ifk_module_id: c_uint, @@ -1616,11 +1752,13 @@ s! { pub ifk_data: __c_anonymous_ifk_data, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ifreq { pub ifr_name: [c_char; crate::IFNAMSIZ], pub ifr_ifru: __c_anonymous_ifr_ifru, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(target_os = "macos")] pub struct in6_ifreq { pub ifr_name: [c_char; crate::IFNAMSIZ], @@ -1628,12 +1766,14 @@ s! { } } -s_no_extra_traits! { +s_no_extra_traits2! { + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(packed(4))] pub struct ifconf { pub ifc_len: c_int, pub ifc_ifcu: __c_anonymous_ifc_ifcu, } + pub union __c_anonymous_ifk_data { pub ifk_ptr: *mut c_void, pub ifk_value: c_int, @@ -1664,9 +1804,27 @@ s_no_extra_traits! { } } +impl Default for __c_anonymous_ifk_data { + fn default() -> Self { + unsafe { mem::zeroed() } + } +} + +impl Default for __c_anonymous_ifr_ifru { + fn default() -> Self { + unsafe { mem::zeroed() } + } +} + +impl Default for __c_anonymous_ifc_ifcu { + fn default() -> Self { + unsafe { mem::zeroed() } + } +} + cfg_if! { if #[cfg(target_os = "macos")] { - s_no_extra_traits! { + s_no_extra_traits2! { pub union __c_anonymous_ifr_ifru6 { pub ifru_addr: crate::sockaddr_in6, pub ifru_dstaddr: crate::sockaddr_in6, @@ -1684,6 +1842,13 @@ cfg_if! { } } +#[cfg(target_os = "macos")] +impl Default for __c_anonymous_ifr_ifru6 { + fn default() -> Self { + unsafe { mem::zeroed() } + } +} + impl siginfo_t { pub unsafe fn si_addr(&self) -> *mut c_void { self.si_addr @@ -1718,7 +1883,7 @@ impl siginfo_t { } } -s_no_extra_traits! { +s_no_extra_traits2! { pub union semun { pub val: c_int, pub buf: *mut semid_ds, @@ -3049,6 +3214,7 @@ pub const _CS_DARWIN_USER_CACHE_DIR: c_int = 65538; pub const OS_UNFAIR_LOCK_INIT: os_unfair_lock = os_unfair_lock { _os_unfair_lock_opaque: 0, + __non_exhaustive: (), }; pub const OS_LOG_TYPE_DEFAULT: crate::os_log_type_t = 0x00; diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs index 8dc6a3c066e5e..ff707097ddedb 100644 --- a/src/unix/bsd/mod.rs +++ b/src/unix/bsd/mod.rs @@ -31,13 +31,15 @@ pub type regoff_t = c_int; pub type regoff_t = off_t; pub type sig_t = Option; -s! { +s2! { + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sockaddr { pub sa_len: u8, pub sa_family: sa_family_t, pub sa_data: [c_char; 14], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sockaddr_in6 { pub sin6_len: u8, pub sin6_family: sa_family_t, @@ -47,15 +49,22 @@ s! { pub sin6_scope_id: u32, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct passwd { + #[custom_default(ptr::null_mut())] pub pw_name: *mut c_char, + #[custom_default(ptr::null_mut())] pub pw_passwd: *mut c_char, pub pw_uid: crate::uid_t, pub pw_gid: crate::gid_t, pub pw_change: crate::time_t, + #[custom_default(ptr::null_mut())] pub pw_class: *mut c_char, + #[custom_default(ptr::null_mut())] pub pw_gecos: *mut c_char, + #[custom_default(ptr::null_mut())] pub pw_dir: *mut c_char, + #[custom_default(ptr::null_mut())] pub pw_shell: *mut c_char, pub pw_expire: crate::time_t, @@ -63,13 +72,20 @@ s! { pub pw_fields: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct ifaddrs { + #[custom_default(ptr::null_mut())] pub ifa_next: *mut ifaddrs, + #[custom_default(ptr::null_mut())] pub ifa_name: *mut c_char, pub ifa_flags: c_uint, + #[custom_default(ptr::null_mut())] pub ifa_addr: *mut crate::sockaddr, + #[custom_default(ptr::null_mut())] pub ifa_netmask: *mut crate::sockaddr, + #[custom_default(ptr::null_mut())] pub ifa_dstaddr: *mut crate::sockaddr, + #[custom_default(ptr::null_mut())] pub ifa_data: *mut c_void, #[cfg(any(target_os = "dragonfly", target_os = "netbsd"))] pub ifa_addrflags: c_uint, @@ -88,16 +104,21 @@ s! { fds_bits: [i32; FD_SETSIZE as usize / 32], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct msghdr { + #[custom_default(ptr::null_mut())] pub msg_name: *mut c_void, pub msg_namelen: crate::socklen_t, + #[custom_default(ptr::null_mut())] pub msg_iov: *mut crate::iovec, pub msg_iovlen: c_int, + #[custom_default(ptr::null_mut())] pub msg_control: *mut c_void, pub msg_controllen: crate::socklen_t, pub msg_flags: c_int, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct cmsghdr { pub cmsg_len: crate::socklen_t, pub cmsg_level: c_int, @@ -108,52 +129,69 @@ s! { __fsid_val: [i32; 2], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct if_nameindex { pub if_index: c_uint, + #[custom_default(ptr::null_mut())] pub if_name: *mut c_char, } pub struct regex_t { __re_magic: c_int, __re_nsub: size_t, + #[custom_default(ptr::null_mut())] __re_endp: *const c_char, + #[custom_default(ptr::null_mut())] __re_g: *mut c_void, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct regmatch_t { pub rm_so: regoff_t, pub rm_eo: regoff_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct option { + #[custom_default(ptr::null_mut())] pub name: *const c_char, pub has_arg: c_int, + #[custom_default(ptr::null_mut())] pub flag: *mut c_int, pub val: c_int, } + + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct sockaddr_un { pub sun_len: u8, pub sun_family: sa_family_t, + #[custom_default([0; 104])] pub sun_path: [c_char; 104], } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct utsname { + #[custom_default([0; 256])] #[cfg(not(target_os = "dragonfly"))] pub sysname: [c_char; 256], #[cfg(target_os = "dragonfly")] pub sysname: [c_char; 32], + #[custom_default([0; 256])] #[cfg(not(target_os = "dragonfly"))] pub nodename: [c_char; 256], #[cfg(target_os = "dragonfly")] pub nodename: [c_char; 32], + #[custom_default([0; 256])] #[cfg(not(target_os = "dragonfly"))] pub release: [c_char; 256], #[cfg(target_os = "dragonfly")] pub release: [c_char; 32], + #[custom_default([0; 256])] #[cfg(not(target_os = "dragonfly"))] pub version: [c_char; 256], #[cfg(target_os = "dragonfly")] pub version: [c_char; 32], + #[custom_default([0; 256])] #[cfg(not(target_os = "dragonfly"))] pub machine: [c_char; 256], #[cfg(target_os = "dragonfly")] diff --git a/src/unix/mod.rs b/src/unix/mod.rs index b317f2ea72d29..8d06955bfc004 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -45,20 +45,25 @@ extern_ty! { #[cfg(not(target_os = "nuttx"))] pub type locale_t = *mut c_void; -s! { +s2! { + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct group { + #[custom_default(ptr::null_mut())] pub gr_name: *mut c_char, + #[custom_default(ptr::null_mut())] pub gr_passwd: *mut c_char, pub gr_gid: crate::gid_t, + #[custom_default(ptr::null_mut())] pub gr_mem: *mut *mut c_char, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct utimbuf { pub actime: time_t, pub modtime: time_t, } - #[derive(Default)] + #[exhaustive] // This one is not likely to ever change pub struct timeval { pub tv_sec: time_t, #[cfg(not(gnu_time_bits64))] @@ -71,7 +76,7 @@ s! { // linux x32 compatibility // See https://sourceware.org/bugzilla/show_bug.cgi?id=16437 - #[derive(Default)] + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(not(target_env = "gnu"))] pub struct timespec { pub tv_sec: time_t, @@ -85,11 +90,13 @@ s! { __pad0: Padding, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rlimit { pub rlim_cur: rlim_t, pub rlim_max: rlim_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct rusage { pub ru_utime: timeval, pub ru_stime: timeval, @@ -140,6 +147,7 @@ s! { __reserved: Padding<[c_long; 16]>, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(not(target_os = "nuttx"))] pub struct ipv6_mreq { pub ipv6mr_multiaddr: in6_addr, @@ -149,20 +157,27 @@ s! { pub ipv6mr_interface: c_uint, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(all(not(target_os = "cygwin"), not(target_os = "horizon")))] pub struct hostent { + #[custom_default(ptr::null_mut())] pub h_name: *mut c_char, + #[custom_default(ptr::null_mut())] pub h_aliases: *mut *mut c_char, pub h_addrtype: c_int, pub h_length: c_int, + #[custom_default(ptr::null_mut())] pub h_addr_list: *mut *mut c_char, } + #[exhaustive] // Shouldn't ever change pub struct iovec { + #[custom_default(ptr::null_mut())] pub iov_base: *mut c_void, pub iov_len: size_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(not(target_os = "horizon"))] pub struct pollfd { pub fd: c_int, @@ -170,6 +185,7 @@ s! { pub revents: c_short, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct winsize { pub ws_row: c_ushort, pub ws_col: c_ushort, @@ -177,6 +193,7 @@ s! { pub ws_ypixel: c_ushort, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[cfg(not(target_os = "cygwin"))] pub struct linger { pub l_onoff: c_int, @@ -184,12 +201,14 @@ s! { } // + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct itimerval { pub it_interval: crate::timeval, pub it_value: crate::timeval, } // + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct tms { pub tms_utime: crate::clock_t, pub tms_stime: crate::clock_t, @@ -197,18 +216,25 @@ s! { pub tms_cstime: crate::clock_t, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct servent { + #[custom_default(ptr::null_mut())] pub s_name: *mut c_char, + #[custom_default(ptr::null_mut())] pub s_aliases: *mut *mut c_char, #[cfg(target_os = "cygwin")] pub s_port: c_short, #[cfg(not(target_os = "cygwin"))] pub s_port: c_int, + #[custom_default(ptr::null_mut())] pub s_proto: *mut c_char, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 pub struct protoent { + #[custom_default(ptr::null_mut())] pub p_name: *mut c_char, + #[custom_default(ptr::null_mut())] pub p_aliases: *mut *mut c_char, #[cfg(not(target_os = "cygwin"))] pub p_proto: c_int, @@ -216,19 +242,26 @@ s! { pub p_proto: c_short, } + #[exhaustive] // FIXME(exhaustive): review for 1.0 #[repr(align(4))] pub struct in6_addr { pub s6_addr: [u8; 16], } } -s_no_extra_traits! { +s_no_extra_traits2! { pub union sigval { pub sival_int: c_int, pub sival_ptr: *mut c_void, } } +impl Default for sigval { + fn default() -> Self { + unsafe { mem::zeroed() } + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for sigval {