Skip to content

Commit

Permalink
Fix remaining std references in windows and windows-core crates…
Browse files Browse the repository at this point in the history
… for `no_std` builds (#3317)
  • Loading branch information
kennykerr authored Oct 9, 2024
1 parent b2ffdc9 commit 4dea5dd
Show file tree
Hide file tree
Showing 220 changed files with 6,144 additions and 5,968 deletions.
2 changes: 1 addition & 1 deletion crates/libs/bindgen/src/rust/implements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ pub fn writer(writer: &Writer, def: metadata::TypeDef) -> TokenStream {
}
#[doc(hidden)]
#features
struct #implvtbl_ident<T: #impl_ident> (std::marker::PhantomData<T>);
struct #implvtbl_ident<T: #impl_ident> (core::marker::PhantomData<T>);
#features
impl<T: #impl_ident> #implvtbl_ident<T> {
const VTABLE: #vtbl_ident = #vtbl_ident::new::<T>();
Expand Down
6 changes: 3 additions & 3 deletions crates/libs/bindgen/src/rust/standalone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ pub fn standalone_imp(writer: &Writer) -> String {
#[repr(C)]
pub struct IInspectable_Vtbl {
pub base: IUnknown_Vtbl,
pub GetIids: unsafe extern "system" fn(this: *mut std::ffi::c_void, count: *mut u32, values: *mut *mut GUID) -> HRESULT,
pub GetRuntimeClassName: unsafe extern "system" fn(this: *mut std::ffi::c_void, value: *mut *mut std::ffi::c_void) -> HRESULT,
pub GetTrustLevel: unsafe extern "system" fn(this: *mut std::ffi::c_void, value: *mut i32) -> HRESULT,
pub GetIids: unsafe extern "system" fn(this: *mut core::ffi::c_void, count: *mut u32, values: *mut *mut GUID) -> HRESULT,
pub GetRuntimeClassName: unsafe extern "system" fn(this: *mut core::ffi::c_void, value: *mut *mut core::ffi::c_void) -> HRESULT,
pub GetTrustLevel: unsafe extern "system" fn(this: *mut core::ffi::c_void, value: *mut i32) -> HRESULT,
}
}
},
Expand Down
4 changes: 2 additions & 2 deletions crates/libs/bindgen/src/rust/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,9 +1043,9 @@ impl Writer {
}
metadata::SignatureParamKind::OptionalPointer => {
if flags.contains(metadata::ParamAttributes::Out) {
quote! { core::mem::transmute(#name.unwrap_or(std::ptr::null_mut())), }
quote! { core::mem::transmute(#name.unwrap_or(core::ptr::null_mut())), }
} else {
quote! { core::mem::transmute(#name.unwrap_or(std::ptr::null())), }
quote! { core::mem::transmute(#name.unwrap_or(core::ptr::null())), }
}
}
metadata::SignatureParamKind::ValueType => {
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/core/src/imp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ macro_rules! define_interface {
($name:ident, $vtbl:ident) => {
#[repr(transparent)]
#[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::clone::Clone)]
pub struct $name(::std::ptr::NonNull<::std::ffi::c_void>);
pub struct $name(::core::ptr::NonNull<::core::ffi::c_void>);
unsafe impl ::windows_core::Interface for $name {
type Vtable = $vtbl;
const IID: ::windows_core::GUID = ::windows_core::GUID::zeroed();
Expand Down
2 changes: 1 addition & 1 deletion crates/libs/windows/src/Windows/Wdk/Foundation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ where
P0: windows_core::Param<super::super::Win32::Foundation::HANDLE>,
{
windows_targets::link!("ntdll.dll" "system" fn NtQueryObject(handle : super::super::Win32::Foundation:: HANDLE, objectinformationclass : OBJECT_INFORMATION_CLASS, objectinformation : *mut core::ffi::c_void, objectinformationlength : u32, returnlength : *mut u32) -> super::super::Win32::Foundation:: NTSTATUS);
NtQueryObject(handle.param().abi(), objectinformationclass, core::mem::transmute(objectinformation.unwrap_or(std::ptr::null_mut())), objectinformationlength, core::mem::transmute(returnlength.unwrap_or(std::ptr::null_mut())))
NtQueryObject(handle.param().abi(), objectinformationclass, core::mem::transmute(objectinformation.unwrap_or(core::ptr::null_mut())), objectinformationlength, core::mem::transmute(returnlength.unwrap_or(core::ptr::null_mut())))
}
pub const DontUseThisType: POOL_TYPE = POOL_TYPE(3i32);
pub const DontUseThisTypeSession: POOL_TYPE = POOL_TYPE(35i32);
Expand Down
28 changes: 14 additions & 14 deletions crates/libs/windows/src/Windows/Wdk/NetworkManagement/Ndis/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub unsafe fn NdisClCloseAddressFamily(ndisafhandle: *const core::ffi::c_void) -
#[inline]
pub unsafe fn NdisClCloseCall(ndisvchandle: *const core::ffi::c_void, ndispartyhandle: Option<*const core::ffi::c_void>, buffer: Option<*const core::ffi::c_void>, size: u32) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisClCloseCall(ndisvchandle : *const core::ffi::c_void, ndispartyhandle : *const core::ffi::c_void, buffer : *const core::ffi::c_void, size : u32) -> i32);
NdisClCloseCall(ndisvchandle, core::mem::transmute(ndispartyhandle.unwrap_or(std::ptr::null())), core::mem::transmute(buffer.unwrap_or(std::ptr::null())), size)
NdisClCloseCall(ndisvchandle, core::mem::transmute(ndispartyhandle.unwrap_or(core::ptr::null())), core::mem::transmute(buffer.unwrap_or(core::ptr::null())), size)
}
#[inline]
pub unsafe fn NdisClDeregisterSap(ndissaphandle: *const core::ffi::c_void) -> i32 {
Expand All @@ -42,7 +42,7 @@ pub unsafe fn NdisClDeregisterSap(ndissaphandle: *const core::ffi::c_void) -> i3
#[inline]
pub unsafe fn NdisClDropParty(ndispartyhandle: *const core::ffi::c_void, buffer: Option<*const core::ffi::c_void>, size: u32) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisClDropParty(ndispartyhandle : *const core::ffi::c_void, buffer : *const core::ffi::c_void, size : u32) -> i32);
NdisClDropParty(ndispartyhandle, core::mem::transmute(buffer.unwrap_or(std::ptr::null())), size)
NdisClDropParty(ndispartyhandle, core::mem::transmute(buffer.unwrap_or(core::ptr::null())), size)
}
#[inline]
pub unsafe fn NdisClGetProtocolVcContextFromTapiCallId(tapicallid: super::super::super::Win32::Foundation::UNICODE_STRING, protocolvccontext: *mut *mut core::ffi::c_void) -> i32 {
Expand All @@ -57,7 +57,7 @@ pub unsafe fn NdisClIncomingCallComplete(status: i32, ndisvchandle: *const core:
#[inline]
pub unsafe fn NdisClMakeCall(ndisvchandle: *const core::ffi::c_void, callparameters: *mut CO_CALL_PARAMETERS, protocolpartycontext: Option<*const core::ffi::c_void>, ndispartyhandle: Option<*mut *mut core::ffi::c_void>) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisClMakeCall(ndisvchandle : *const core::ffi::c_void, callparameters : *mut CO_CALL_PARAMETERS, protocolpartycontext : *const core::ffi::c_void, ndispartyhandle : *mut *mut core::ffi::c_void) -> i32);
NdisClMakeCall(ndisvchandle, callparameters, core::mem::transmute(protocolpartycontext.unwrap_or(std::ptr::null())), core::mem::transmute(ndispartyhandle.unwrap_or(std::ptr::null_mut())))
NdisClMakeCall(ndisvchandle, callparameters, core::mem::transmute(protocolpartycontext.unwrap_or(core::ptr::null())), core::mem::transmute(ndispartyhandle.unwrap_or(core::ptr::null_mut())))
}
#[inline]
pub unsafe fn NdisClModifyCallQoS(ndisvchandle: *const core::ffi::c_void, callparameters: *const CO_CALL_PARAMETERS) -> i32 {
Expand Down Expand Up @@ -87,7 +87,7 @@ pub unsafe fn NdisCmActivateVc(ndisvchandle: *const core::ffi::c_void, callparam
#[inline]
pub unsafe fn NdisCmAddPartyComplete(status: i32, ndispartyhandle: *const core::ffi::c_void, callmgrpartycontext: Option<*const core::ffi::c_void>, callparameters: *const CO_CALL_PARAMETERS) {
windows_targets::link!("ndis.sys" "system" fn NdisCmAddPartyComplete(status : i32, ndispartyhandle : *const core::ffi::c_void, callmgrpartycontext : *const core::ffi::c_void, callparameters : *const CO_CALL_PARAMETERS));
NdisCmAddPartyComplete(status, ndispartyhandle, core::mem::transmute(callmgrpartycontext.unwrap_or(std::ptr::null())), callparameters)
NdisCmAddPartyComplete(status, ndispartyhandle, core::mem::transmute(callmgrpartycontext.unwrap_or(core::ptr::null())), callparameters)
}
#[inline]
pub unsafe fn NdisCmCloseAddressFamilyComplete(status: i32, ndisafhandle: *const core::ffi::c_void) {
Expand All @@ -97,7 +97,7 @@ pub unsafe fn NdisCmCloseAddressFamilyComplete(status: i32, ndisafhandle: *const
#[inline]
pub unsafe fn NdisCmCloseCallComplete(status: i32, ndisvchandle: *const core::ffi::c_void, ndispartyhandle: Option<*const core::ffi::c_void>) {
windows_targets::link!("ndis.sys" "system" fn NdisCmCloseCallComplete(status : i32, ndisvchandle : *const core::ffi::c_void, ndispartyhandle : *const core::ffi::c_void));
NdisCmCloseCallComplete(status, ndisvchandle, core::mem::transmute(ndispartyhandle.unwrap_or(std::ptr::null())))
NdisCmCloseCallComplete(status, ndisvchandle, core::mem::transmute(ndispartyhandle.unwrap_or(core::ptr::null())))
}
#[inline]
pub unsafe fn NdisCmDeactivateVc(ndisvchandle: *const core::ffi::c_void) -> i32 {
Expand Down Expand Up @@ -127,12 +127,12 @@ pub unsafe fn NdisCmDispatchIncomingCallQoSChange(ndisvchandle: *const core::ffi
#[inline]
pub unsafe fn NdisCmDispatchIncomingCloseCall(closestatus: i32, ndisvchandle: *const core::ffi::c_void, buffer: Option<*const core::ffi::c_void>, size: u32) {
windows_targets::link!("ndis.sys" "system" fn NdisCmDispatchIncomingCloseCall(closestatus : i32, ndisvchandle : *const core::ffi::c_void, buffer : *const core::ffi::c_void, size : u32));
NdisCmDispatchIncomingCloseCall(closestatus, ndisvchandle, core::mem::transmute(buffer.unwrap_or(std::ptr::null())), size)
NdisCmDispatchIncomingCloseCall(closestatus, ndisvchandle, core::mem::transmute(buffer.unwrap_or(core::ptr::null())), size)
}
#[inline]
pub unsafe fn NdisCmDispatchIncomingDropParty(dropstatus: i32, ndispartyhandle: *const core::ffi::c_void, buffer: Option<*const core::ffi::c_void>, size: u32) {
windows_targets::link!("ndis.sys" "system" fn NdisCmDispatchIncomingDropParty(dropstatus : i32, ndispartyhandle : *const core::ffi::c_void, buffer : *const core::ffi::c_void, size : u32));
NdisCmDispatchIncomingDropParty(dropstatus, ndispartyhandle, core::mem::transmute(buffer.unwrap_or(std::ptr::null())), size)
NdisCmDispatchIncomingDropParty(dropstatus, ndispartyhandle, core::mem::transmute(buffer.unwrap_or(core::ptr::null())), size)
}
#[inline]
pub unsafe fn NdisCmDropPartyComplete(status: i32, ndispartyhandle: *const core::ffi::c_void) {
Expand All @@ -142,7 +142,7 @@ pub unsafe fn NdisCmDropPartyComplete(status: i32, ndispartyhandle: *const core:
#[inline]
pub unsafe fn NdisCmMakeCallComplete(status: i32, ndisvchandle: *const core::ffi::c_void, ndispartyhandle: Option<*const core::ffi::c_void>, callmgrpartycontext: Option<*const core::ffi::c_void>, callparameters: *const CO_CALL_PARAMETERS) {
windows_targets::link!("ndis.sys" "system" fn NdisCmMakeCallComplete(status : i32, ndisvchandle : *const core::ffi::c_void, ndispartyhandle : *const core::ffi::c_void, callmgrpartycontext : *const core::ffi::c_void, callparameters : *const CO_CALL_PARAMETERS));
NdisCmMakeCallComplete(status, ndisvchandle, core::mem::transmute(ndispartyhandle.unwrap_or(std::ptr::null())), core::mem::transmute(callmgrpartycontext.unwrap_or(std::ptr::null())), callparameters)
NdisCmMakeCallComplete(status, ndisvchandle, core::mem::transmute(ndispartyhandle.unwrap_or(core::ptr::null())), core::mem::transmute(callmgrpartycontext.unwrap_or(core::ptr::null())), callparameters)
}
#[inline]
pub unsafe fn NdisCmModifyCallQoSComplete(status: i32, ndisvchandle: *const core::ffi::c_void, callparameters: *const CO_CALL_PARAMETERS) {
Expand All @@ -162,12 +162,12 @@ pub unsafe fn NdisCmRegisterSapComplete(status: i32, ndissaphandle: *const core:
#[inline]
pub unsafe fn NdisCoAssignInstanceName(ndisvchandle: *const core::ffi::c_void, baseinstancename: *const super::super::super::Win32::Foundation::UNICODE_STRING, vcinstancename: Option<*mut super::super::super::Win32::Foundation::UNICODE_STRING>) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisCoAssignInstanceName(ndisvchandle : *const core::ffi::c_void, baseinstancename : *const super::super::super::Win32::Foundation:: UNICODE_STRING, vcinstancename : *mut super::super::super::Win32::Foundation:: UNICODE_STRING) -> i32);
NdisCoAssignInstanceName(ndisvchandle, baseinstancename, core::mem::transmute(vcinstancename.unwrap_or(std::ptr::null_mut())))
NdisCoAssignInstanceName(ndisvchandle, baseinstancename, core::mem::transmute(vcinstancename.unwrap_or(core::ptr::null_mut())))
}
#[inline]
pub unsafe fn NdisCoCreateVc(ndisbindinghandle: *const core::ffi::c_void, ndisafhandle: Option<*const core::ffi::c_void>, protocolvccontext: *const core::ffi::c_void, ndisvchandle: *mut *mut core::ffi::c_void) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisCoCreateVc(ndisbindinghandle : *const core::ffi::c_void, ndisafhandle : *const core::ffi::c_void, protocolvccontext : *const core::ffi::c_void, ndisvchandle : *mut *mut core::ffi::c_void) -> i32);
NdisCoCreateVc(ndisbindinghandle, core::mem::transmute(ndisafhandle.unwrap_or(std::ptr::null())), protocolvccontext, ndisvchandle)
NdisCoCreateVc(ndisbindinghandle, core::mem::transmute(ndisafhandle.unwrap_or(core::ptr::null())), protocolvccontext, ndisvchandle)
}
#[inline]
pub unsafe fn NdisCoDeleteVc(ndisvchandle: *const core::ffi::c_void) -> i32 {
Expand Down Expand Up @@ -259,7 +259,7 @@ pub unsafe fn NdisIMGetBindingContext(ndisbindinghandle: *const core::ffi::c_voi
#[inline]
pub unsafe fn NdisIMInitializeDeviceInstanceEx(driverhandle: *const core::ffi::c_void, driverinstance: *const super::super::super::Win32::Foundation::UNICODE_STRING, devicecontext: Option<*const core::ffi::c_void>) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisIMInitializeDeviceInstanceEx(driverhandle : *const core::ffi::c_void, driverinstance : *const super::super::super::Win32::Foundation:: UNICODE_STRING, devicecontext : *const core::ffi::c_void) -> i32);
NdisIMInitializeDeviceInstanceEx(driverhandle, driverinstance, core::mem::transmute(devicecontext.unwrap_or(std::ptr::null())))
NdisIMInitializeDeviceInstanceEx(driverhandle, driverinstance, core::mem::transmute(devicecontext.unwrap_or(core::ptr::null())))
}
#[cfg(all(feature = "Wdk_Foundation", feature = "Win32_System_Kernel"))]
#[inline]
Expand All @@ -283,7 +283,7 @@ pub unsafe fn NdisInitializeString(destination: *mut super::super::super::Win32:
#[inline]
pub unsafe fn NdisInitializeTimer(timer: *mut NDIS_TIMER, timerfunction: PNDIS_TIMER_FUNCTION, functioncontext: Option<*const core::ffi::c_void>) {
windows_targets::link!("ndis.sys" "system" fn NdisInitializeTimer(timer : *mut NDIS_TIMER, timerfunction : PNDIS_TIMER_FUNCTION, functioncontext : *const core::ffi::c_void));
NdisInitializeTimer(timer, timerfunction, core::mem::transmute(functioncontext.unwrap_or(std::ptr::null())))
NdisInitializeTimer(timer, timerfunction, core::mem::transmute(functioncontext.unwrap_or(core::ptr::null())))
}
#[inline]
pub unsafe fn NdisMAllocateSharedMemory<P0>(miniportadapterhandle: *const core::ffi::c_void, length: u32, cached: P0, virtualaddress: *mut *mut core::ffi::c_void, physicaladdress: *mut i64)
Expand Down Expand Up @@ -381,7 +381,7 @@ where
#[inline]
pub unsafe fn NdisMGetDeviceProperty(miniportadapterhandle: *const core::ffi::c_void, physicaldeviceobject: Option<*mut *mut super::super::Foundation::DEVICE_OBJECT>, functionaldeviceobject: Option<*mut *mut super::super::Foundation::DEVICE_OBJECT>, nextdeviceobject: Option<*mut *mut super::super::Foundation::DEVICE_OBJECT>, allocatedresources: Option<*mut *mut super::super::System::SystemServices::CM_RESOURCE_LIST>, allocatedresourcestranslated: Option<*mut *mut super::super::System::SystemServices::CM_RESOURCE_LIST>) {
windows_targets::link!("ndis.sys" "system" fn NdisMGetDeviceProperty(miniportadapterhandle : *const core::ffi::c_void, physicaldeviceobject : *mut *mut super::super::Foundation:: DEVICE_OBJECT, functionaldeviceobject : *mut *mut super::super::Foundation:: DEVICE_OBJECT, nextdeviceobject : *mut *mut super::super::Foundation:: DEVICE_OBJECT, allocatedresources : *mut *mut super::super::System::SystemServices:: CM_RESOURCE_LIST, allocatedresourcestranslated : *mut *mut super::super::System::SystemServices:: CM_RESOURCE_LIST));
NdisMGetDeviceProperty(miniportadapterhandle, core::mem::transmute(physicaldeviceobject.unwrap_or(std::ptr::null_mut())), core::mem::transmute(functionaldeviceobject.unwrap_or(std::ptr::null_mut())), core::mem::transmute(nextdeviceobject.unwrap_or(std::ptr::null_mut())), core::mem::transmute(allocatedresources.unwrap_or(std::ptr::null_mut())), core::mem::transmute(allocatedresourcestranslated.unwrap_or(std::ptr::null_mut())))
NdisMGetDeviceProperty(miniportadapterhandle, core::mem::transmute(physicaldeviceobject.unwrap_or(core::ptr::null_mut())), core::mem::transmute(functionaldeviceobject.unwrap_or(core::ptr::null_mut())), core::mem::transmute(nextdeviceobject.unwrap_or(core::ptr::null_mut())), core::mem::transmute(allocatedresources.unwrap_or(core::ptr::null_mut())), core::mem::transmute(allocatedresourcestranslated.unwrap_or(core::ptr::null_mut())))
}
#[inline]
pub unsafe fn NdisMGetDmaAlignment(miniportadapterhandle: *const core::ffi::c_void) -> u32 {
Expand Down Expand Up @@ -577,7 +577,7 @@ pub unsafe fn NdisWriteErrorLogEntry(ndisadapterhandle: *const core::ffi::c_void
#[inline]
pub unsafe fn NdisWriteEventLogEntry(loghandle: *const core::ffi::c_void, eventcode: i32, uniqueeventvalue: u32, numstrings: u16, stringslist: Option<*const core::ffi::c_void>, datasize: u32, data: Option<*const core::ffi::c_void>) -> i32 {
windows_targets::link!("ndis.sys" "system" fn NdisWriteEventLogEntry(loghandle : *const core::ffi::c_void, eventcode : i32, uniqueeventvalue : u32, numstrings : u16, stringslist : *const core::ffi::c_void, datasize : u32, data : *const core::ffi::c_void) -> i32);
NdisWriteEventLogEntry(loghandle, eventcode, uniqueeventvalue, numstrings, core::mem::transmute(stringslist.unwrap_or(std::ptr::null())), datasize, core::mem::transmute(data.unwrap_or(std::ptr::null())))
NdisWriteEventLogEntry(loghandle, eventcode, uniqueeventvalue, numstrings, core::mem::transmute(stringslist.unwrap_or(core::ptr::null())), datasize, core::mem::transmute(data.unwrap_or(core::ptr::null())))
}
pub const AUTHENTICATE: OFFLOAD_OPERATION_E = OFFLOAD_OPERATION_E(1i32);
pub const BINARY_COMPATIBLE: u32 = 0u32;
Expand Down
Loading

0 comments on commit 4dea5dd

Please sign in to comment.