]> git.proxmox.com Git - rustc.git/blob - vendor/windows-sys/src/core/mod.rs
New upstream version 1.70.0+dfsg1
[rustc.git] / vendor / windows-sys / src / core / mod.rs
1 mod literals;
2
3 #[doc(hidden)]
4 pub use literals::*;
5
6 pub type HRESULT = i32;
7 pub type HSTRING = *mut ::core::ffi::c_void;
8 pub type IUnknown = *mut ::core::ffi::c_void;
9 pub type IInspectable = *mut ::core::ffi::c_void;
10 pub type PSTR = *mut u8;
11 pub type PWSTR = *mut u16;
12 pub type PCSTR = *const u8;
13 pub type PCWSTR = *const u16;
14 pub type BSTR = *const u16;
15
16 #[repr(C)]
17 pub struct GUID {
18 pub data1: u32,
19 pub data2: u16,
20 pub data3: u16,
21 pub data4: [u8; 8],
22 }
23
24 impl ::core::marker::Copy for GUID {}
25
26 impl ::core::clone::Clone for GUID {
27 fn clone(&self) -> Self {
28 *self
29 }
30 }
31
32 impl GUID {
33 pub const fn from_u128(uuid: u128) -> Self {
34 Self { data1: (uuid >> 96) as u32, data2: (uuid >> 80 & 0xffff) as u16, data3: (uuid >> 64 & 0xffff) as u16, data4: (uuid as u64).to_be_bytes() }
35 }
36 }
37
38 #[cfg(all(windows_raw_dylib, target_arch = "x86"))]
39 #[macro_export]
40 #[doc(hidden)]
41 macro_rules! link {
42 ($library:literal $abi:literal $(#[$($doc:tt)*])* fn $name:ident($($arg:ident: $argty:ty),*)->$ret:ty) => (
43 #[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim", import_name_type = "undecorated")]
44 extern $abi {
45 pub fn $name($($arg: $argty),*) -> $ret;
46 }
47 )
48 }
49
50 #[cfg(all(windows_raw_dylib, not(target_arch = "x86")))]
51 #[macro_export]
52 #[doc(hidden)]
53 macro_rules! link {
54 ($library:literal $abi:literal $(#[$($doc:tt)*])* fn $name:ident($($arg:ident: $argty:ty),*)->$ret:ty) => (
55 #[link(name = $library, kind = "raw-dylib", modifiers = "+verbatim")]
56 extern "system" {
57 pub fn $name($($arg: $argty),*) -> $ret;
58 }
59 )
60 }
61
62 #[cfg(not(windows_raw_dylib))]
63 #[macro_export]
64 #[doc(hidden)]
65 macro_rules! link {
66 ($library:literal $abi:literal $(#[$($doc:tt)*])* fn $name:ident($($arg:ident: $argty:ty),*)->$ret:ty) => (
67 #[link(name = "windows")]
68 extern $abi {
69 $(#[$($doc)*])*
70 pub fn $name($($arg: $argty),*) -> $ret;
71 }
72 )
73 }
74
75 #[doc(hidden)]
76 pub use crate::link;