From 5cc2bb79b83d6cb15b8265fe97619a6b1b9cee86 Mon Sep 17 00:00:00 2001 From: Jake Shadle Date: Tue, 12 Dec 2023 16:07:59 +0100 Subject: [PATCH] Remove windows-targets dependency It's been updated again which will just cause needless version duplication, all the functions used by this crate are present in kernel32 which is required to link std anyways --- Cargo.toml | 3 -- src/utils/flock/win_bindings.rs | 59 +++++++++++++++++---------------- 2 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9217085..7aeeabe 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -72,9 +72,6 @@ features = ["blocking", "gzip"] [target.'cfg(unix)'.dependencies] libc = "0.2" -[target.'cfg(windows)'.dependencies] -windows-targets = "0.48.5" - [dev-dependencies] cargo_metadata = "0.18" rayon = "1.7" diff --git a/src/utils/flock/win_bindings.rs b/src/utils/flock/win_bindings.rs index da24ba3..0584cbc 100644 --- a/src/utils/flock/win_bindings.rs +++ b/src/utils/flock/win_bindings.rs @@ -5,28 +5,37 @@ non_camel_case_types, clippy::upper_case_acronyms )] -::windows_targets::link!( - "kernel32.dll" "system" "CloseHandle" fn close_handle(object : Handle) -> Bool -); -::windows_targets::link!( - "kernel32.dll" "system" "CreateEventA" fn create_event_a(event_attributes : * const - SecurityAttributes, manual_reset : Bool, initial_state : Bool, name : Pcstr) -> - Handle -); -::windows_targets::link!( - "kernel32.dll" "system" "LockFileEx" fn lock_file_ex(file : Handle, flags : - LockFileFlags::Enum, reserved : u32, number_of_bytes_to_lock_low : u32, - number_of_bytes_to_lock_high : u32, overlapped : * mut Overlapped) -> Bool -); -::windows_targets::link!( - "kernel32.dll" "system" "UnlockFile" fn unlock_file(file : Handle, file_offset_low : - u32, file_offset_high : u32, number_of_bytes_to_unlock_low : u32, - number_of_bytes_to_unlock_high : u32) -> Bool -); -::windows_targets::link!( - "kernel32.dll" "system" "WaitForSingleObject" fn wait_for_single_object(handle : - Handle, milliseconds : u32) -> Win32Error::Enum -); +#[link(name = "kernel32")] +extern "system" { + #[link_name = "CloseHandle"] + pub fn close_handle(object: Handle) -> Bool; + #[link_name = "CreateEventA"] + pub fn create_event_a( + event_attributes: *const ::core::ffi::c_void, + manual_reset: Bool, + initial_state: Bool, + name: Pcstr, + ) -> Handle; + #[link_name = "LockFileEx"] + pub fn lock_file_ex( + file: Handle, + flags: LockFileFlags::Enum, + reserved: u32, + number_of_bytes_to_lock_low: u32, + number_of_bytes_to_lock_high: u32, + overlapped: *mut Overlapped, + ) -> Bool; + #[link_name = "UnlockFile"] + pub fn unlock_file( + file: Handle, + file_offset_low: u32, + file_offset_high: u32, + number_of_bytes_to_unlock_low: u32, + number_of_bytes_to_unlock_high: u32, + ) -> Bool; + #[link_name = "WaitForSingleObject"] + pub fn wait_for_single_object(handle: Handle, milliseconds: u32) -> Win32Error::Enum; +} pub const Infinite: u32 = 4294967295; pub type Bool = i32; pub mod FileFlagsAndAttributes { @@ -57,12 +66,6 @@ pub struct Overlapped_0_0 { pub offset_high: u32, } pub type Pcstr = *const u8; -#[repr(C)] -pub struct SecurityAttributes { - pub length: u32, - pub security_descriptor: *mut ::core::ffi::c_void, - pub inherit_handle: Bool, -} pub mod Win32Error { pub type Enum = u32; pub const WaitObject0: Enum = 0;