Skip to content

Commit

Permalink
Remove windows-targets dependency
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Jake-Shadle committed Dec 12, 2023
1 parent 60fd14e commit 5cc2bb7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
59 changes: 31 additions & 28 deletions src/utils/flock/win_bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5cc2bb7

Please sign in to comment.