From 9541e29a88d4f3d748714b8383b953684fc212c4 Mon Sep 17 00:00:00 2001 From: Zeyi Fan Date: Wed, 23 Dec 2020 10:55:02 -0800 Subject: [PATCH] add definitions for afunix.h --- Cargo.toml | 1 + build.rs | 1 + src/shared/afunix.rs | 10 ++++++++++ src/shared/mod.rs | 1 + tests/structs_x86.rs | 6 ++++++ tests/structs_x86_64.rs | 6 ++++++ 6 files changed, 25 insertions(+) create mode 100644 src/shared/afunix.rs diff --git a/Cargo.toml b/Cargo.toml index 524487083..d614a790d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ std = [] d3dkmthk = [] #mmos #shared +afunix = [] basetsd = [] bcrypt = [] bthdef = [] diff --git a/build.rs b/build.rs index 622050495..d00e0e94e 100644 --- a/build.rs +++ b/build.rs @@ -12,6 +12,7 @@ const DATA: &'static [(&'static str, &'static [&'static str], &'static [&'static ("d3dkmthk", &["basetsd", "d3dukmdt", "minwindef", "ntdef", "windef"], &[]), // mmos // shared + ("afunix", &["minwindef", "winnt", "ws2def"], &[]), ("basetsd", &[], &[]), ("bcrypt", &["minwindef", "winnt"], &["bcrypt"]), ("bthdef", &["bthsdpdef", "guiddef", "minwindef", "ntdef"], &[]), diff --git a/src/shared/afunix.rs b/src/shared/afunix.rs new file mode 100644 index 000000000..43afe38ac --- /dev/null +++ b/src/shared/afunix.rs @@ -0,0 +1,10 @@ +use shared::minwindef::DWORD; +use shared::ws2def::{ADDRESS_FAMILY, IOC_VENDOR}; +use um::winnt::CHAR; +pub const UNIX_PATH_MAX: usize = 108; +STRUCT!{struct SOCKADDR_UN { + sun_family: ADDRESS_FAMILY, + sun_path: [CHAR; UNIX_PATH_MAX], +}} +pub type PSOCKETADDR_UN = *mut SOCKADDR_UN; +pub const SIO_AF_UNIX_GETPEERPID: DWORD = _WSAIOR!(IOC_VENDOR, 256); diff --git a/src/shared/mod.rs b/src/shared/mod.rs index 8924f7b1e..1b586b76a 100644 --- a/src/shared/mod.rs +++ b/src/shared/mod.rs @@ -4,6 +4,7 @@ // All files in the project carrying such notice may not be copied, modified, or distributed // except according to those terms. //! Headers shared between user mode and kernel mode +#[cfg(feature = "afunix")] pub mod afunix; #[cfg(feature = "basetsd")] pub mod basetsd; #[cfg(feature = "bcrypt")] pub mod bcrypt; #[cfg(feature = "bthdef")] pub mod bthdef; diff --git a/tests/structs_x86.rs b/tests/structs_x86.rs index dd211bca0..cba3ce51c 100644 --- a/tests/structs_x86.rs +++ b/tests/structs_x86.rs @@ -1,6 +1,12 @@ #![cfg(all(windows, target_arch = "x86"))] extern crate winapi; use std::mem::{size_of, align_of}; +#[cfg(feature = "afunix")] #[test] +fn shared_afunix() { + use winapi::shared::afunix::*; + assert_eq!(size_of::(), 110); + assert_eq!(align_of::(), 2); +} #[cfg(feature = "bcrypt")] #[test] fn shared_bcrypt() { use winapi::shared::bcrypt::*; diff --git a/tests/structs_x86_64.rs b/tests/structs_x86_64.rs index f267b2855..2545dae54 100644 --- a/tests/structs_x86_64.rs +++ b/tests/structs_x86_64.rs @@ -1,6 +1,12 @@ #![cfg(all(windows, target_arch = "x86_64"))] extern crate winapi; use std::mem::{size_of, align_of}; +#[cfg(feature = "afunix")] #[test] +fn shared_afunix() { + use winapi::shared::afunix::*; + assert_eq!(size_of::(), 110); + assert_eq!(align_of::(), 2); +} #[cfg(feature = "bcrypt")] #[test] fn shared_bcrypt() { use winapi::shared::bcrypt::*;