4 fn $n
:ident ($
( $p
:tt $
(: $t
:ty
)?
),* $
(,)?
) $
(-> $r
:ty
)?
;
6 #[cfg_attr(all(target_env = "msvc", feature = "user"), link(name = "ntdll"))]
7 #[cfg_attr(all(target_env = "msvc", feature = "kernel"), link(name = "ntoskrnl"))]
14 #[cfg(feature = "func-types")]
15 pub type $n
= unsafe extern $c
fn($
($p $
(: $t
)?
),*) $
(-> $r
)?
;
19 static mut $n
:ident
: $t
:ty
;
21 #[cfg_attr(all(target_env = "msvc", feature = "user"), link(name = "ntdll"))]
23 pub static mut $n
: $t
;
28 macro_rules
! FIELD_OFFSET
{
29 ($_type
:ty
, $field
:ident$
(.$cfields
:ident
)*) => {
31 union Transmuter
<T
: '
static> {
38 p
: $
crate::_core
::ptr
::null
::<$_type
>()
39 }.r
).$field$
(.$cfields
)*
44 macro_rules
! BITFIELD
{
45 ($base
:ident $field
:ident
: $fieldtype
:ty
[
46 $
($thing
:ident $set_thing
:ident
[$r
:expr
],)+
50 pub const fn $
thing(&self) -> $fieldtype
{
51 const SIZE
: usize = $
crate::_core
::mem
::size_of
::<$fieldtype
>() * 8;
52 self.$field
<< (SIZE
- $r
.end
) >> (SIZE
- $r
.end
+ $r
.start
)
55 pub fn $
set_thing(&mut self, val
: $fieldtype
) {
56 const MASK
: $fieldtype
= ((1 << ($r
.end
- $r
.start
)) - 1) << $r
.start
;
58 self.$field
|= (val
<< $r
.start
) & MASK
;
62 (unsafe $base
:ident $field
:ident
: $fieldtype
:ty
[
63 $
($thing
:ident $set_thing
:ident
[$r
:expr
],)+
67 pub unsafe fn $
thing(&self) -> $fieldtype
{
68 const SIZE
: usize = $
crate::_core
::mem
::size_of
::<$fieldtype
>() * 8;
69 self.$field
<< (SIZE
- $r
.end
) >> (SIZE
- $r
.end
+ $r
.start
)
72 pub unsafe fn $
set_thing(&mut self, val
: $fieldtype
) {
73 const MASK
: $fieldtype
= ((1 << ($r
.end
- $r
.start
)) - 1) << $r
.start
;
75 self.$field
|= (val
<< $r
.start
) & MASK
;
81 ($
(#[$attrs:meta])* union $name:ident {
82 $
($variant
:ident
: $ftype
:ty
,)+
84 #[repr(C)] $(#[$attrs])*
86 $
(pub $variant
: $ftype
,)+
88 impl Copy
for $name {}
89 impl Clone
for $name
{
91 fn clone(&self) -> $name { *self }
93 #[cfg(feature = "impl-default")]
94 impl Default
for $name
{
96 fn default() -> $name { unsafe { $crate::_core::mem::zeroed() }
}
101 (stdcall $func
:ident($
($p
:ident
: $t
:ty
,)*) -> $ret
:ty
) => (
102 pub type $func
= Option
<unsafe extern "system" fn($
($p
: $t
,)*) -> $ret
>;
104 (cdecl $func
:ident($
($p
:ident
: $t
:ty
,)*) -> $ret
:ty
) => (
105 pub type $func
= Option
<unsafe extern "C" fn($
($p
: $t
,)*) -> $ret
>;
109 ($
($thing
:item
)*) => ($
($thing
)*)