Skip to content

Commit 3792048

Browse files
froydnjretep998
authored andcommitted
add support for aarch64-pc-windows-msvc (#677)
* add aarch64 conditionals and types Most of the additions are where `_WIN64` was being checked, in which case we add a case next to the `target_arch = "x86_64"` checks. Other headers, particularly winnt.h, require custom AArch64-specific types. * use target_pointer_width rather than explicit target_arch selections This style is shorter, and corresponds more closer to the headers depending on _WIN64 and the like.
1 parent 0521980 commit 3792048

File tree

16 files changed

+296
-103
lines changed

16 files changed

+296
-103
lines changed

src/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ macro_rules! UNION {
297297
}) => (
298298
#[repr(C)] $(#[$attrs])* #[cfg(target_arch = "x86")]
299299
pub struct $name([$stype32; $ssize32]);
300-
#[repr(C)] $(#[$attrs])* #[cfg(target_arch = "x86_64")]
300+
#[repr(C)] $(#[$attrs])* #[cfg(target_pointer_width = "64")]
301301
pub struct $name([$stype64; $ssize64]);
302302
impl Copy for $name {}
303303
impl Clone for $name {

src/shared/basetsd.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ pub type SHANDLE_PTR = isize;
4141
pub type HANDLE_PTR = usize;
4242
#[cfg(target_arch = "x86")]
4343
pub type UHALF_PTR = c_ushort;
44-
#[cfg(target_arch = "x86_64")]
44+
#[cfg(target_pointer_width = "64")]
4545
pub type UHALF_PTR = c_uint;
4646
#[cfg(target_arch = "x86")]
4747
pub type PUHALF_PTR = *mut c_ushort;
48-
#[cfg(target_arch = "x86_64")]
48+
#[cfg(target_pointer_width = "64")]
4949
pub type PUHALF_PTR = *mut c_uint;
5050
#[cfg(target_arch = "x86")]
5151
pub type HALF_PTR = c_short;
52-
#[cfg(target_arch = "x86_64")]
52+
#[cfg(target_pointer_width = "64")]
5353
pub type HALF_PTR = c_int;
5454
#[cfg(target_arch = "x86")]
5555
pub type PHALF_PTR = *mut c_short;
56-
#[cfg(target_arch = "x86_64")]
56+
#[cfg(target_pointer_width = "64")]
5757
pub type PHALF_PTR = *mut c_int;
5858
pub type SIZE_T = ULONG_PTR;
5959
pub type PSIZE_T = *mut ULONG_PTR;

src/shared/usb.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ STRUCT!{struct URB_CONTROL_TRANSFER {
420420
hca: URB_HCD_AREA,
421421
SetupPacket: [UCHAR; 8],
422422
}}
423-
#[cfg(target_arch = "x86_64")]
423+
#[cfg(target_pointer_width = "64")]
424424
STRUCT!{struct URB_CONTROL_TRANSFER_EX {
425425
Hdr: URB_HEADER,
426426
PipeHandle: USBD_PIPE_HANDLE,

src/um/commctrl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// except according to those terms.
77
use ctypes::{c_char, c_int, c_long, c_short, c_void};
88
use shared::basetsd::{DWORD_PTR, INT_PTR, LONG_PTR, UINT_PTR};
9-
#[cfg(target_arch = "x86_64")] use shared::basetsd::PINT_PTR;
9+
#[cfg(target_pointer_width = "64")] use shared::basetsd::PINT_PTR;
1010
use shared::guiddef::{IID, REFIID};
1111
use shared::minwindef::{
1212
BOOL, BYTE, DWORD, HINSTANCE, HKEY, INT, LPARAM, LPINT, LRESULT, PUINT, UINT, ULONG, WORD,
@@ -781,7 +781,7 @@ STRUCT!{struct TBBUTTON {
781781
dwData: DWORD_PTR,
782782
iString: INT_PTR,
783783
}}
784-
#[cfg(target_arch = "x86_64")]
784+
#[cfg(target_pointer_width = "64")]
785785
STRUCT!{struct TBBUTTON {
786786
iBitmap: c_int,
787787
idCommand: c_int,
@@ -4033,7 +4033,7 @@ extern "system" {
40334033
propIndex: c_int,
40344034
pValue: LPINT,
40354035
) -> BOOL;
4036-
#[cfg(target_arch = "x86_64")]
4036+
#[cfg(target_pointer_width = "64")]
40374037
pub fn FlatSB_GetScrollPropPtr(
40384038
hWnd: HWND,
40394039
propIndex: c_int,

src/um/dbghelp.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ use um::winnt::{
1919
PFPO_DATA, PIMAGE_COFF_SYMBOLS_HEADER, PIMAGE_DEBUG_DIRECTORY, PIMAGE_FUNCTION_ENTRY,
2020
PIMAGE_NT_HEADERS32,
2121
};
22-
#[cfg(target_arch = "x86_64")]
22+
#[cfg(target_pointer_width = "64")]
2323
use um::winnt::PIMAGE_NT_HEADERS64;
2424
use vc::vcruntime::size_t;
25-
#[cfg(target_arch = "x86_64")]
25+
#[cfg(target_pointer_width = "64")]
2626
STRUCT!{struct LOADED_IMAGE {
2727
ModuleName: PSTR,
2828
hFile: HANDLE,
@@ -191,9 +191,9 @@ STRUCT!{struct ADDRESS64 {
191191
Mode: ADDRESS_MODE,
192192
}}
193193
pub type LPADDRESS64 = *mut ADDRESS64;
194-
#[cfg(target_arch = "x86_64")]
194+
#[cfg(target_pointer_width = "64")]
195195
pub type ADDRESS = ADDRESS64;
196-
#[cfg(target_arch = "x86_64")]
196+
#[cfg(target_pointer_width = "64")]
197197
pub type LPADDRESS = LPADDRESS64;
198198
#[cfg(target_arch = "x86")]
199199
STRUCT!{struct ADDRESS {
@@ -220,9 +220,9 @@ STRUCT!{struct KDHELP64 {
220220
Reserved1: [DWORD64; 4],
221221
}}
222222
pub type PKDHELP64 = *mut KDHELP64;
223-
#[cfg(target_arch = "x86_64")]
223+
#[cfg(target_pointer_width = "64")]
224224
pub type KDHELP = KDHELP64;
225-
#[cfg(target_arch = "x86_64")]
225+
#[cfg(target_pointer_width = "64")]
226226
pub type PKDHELP = PKDHELP64;
227227
#[cfg(target_arch = "x86")]
228228
STRUCT!{struct KDHELP {
@@ -273,9 +273,9 @@ STRUCT!{struct STACKFRAME_EX {
273273
InlineFrameContext: DWORD,
274274
}}
275275
pub type LPSTACKFRAME_EX = *mut STACKFRAME_EX;
276-
#[cfg(target_arch = "x86_64")]
276+
#[cfg(target_pointer_width = "64")]
277277
pub type STACKFRAME = STACKFRAME64;
278-
#[cfg(target_arch = "x86_64")]
278+
#[cfg(target_pointer_width = "64")]
279279
pub type LPSTACKFRAME = LPSTACKFRAME64;
280280
#[cfg(target_arch = "x86")]
281281
STRUCT!{struct STACKFRAME {
@@ -315,13 +315,13 @@ FN!{stdcall PTRANSLATE_ADDRESS_ROUTINE64(
315315
) -> DWORD64}
316316
pub const SYM_STKWALK_DEFAULT: DWORD = 0x00000000;
317317
pub const SYM_STKWALK_FORCE_FRAMEPTR: DWORD = 0x00000001;
318-
#[cfg(target_arch = "x86_64")]
318+
#[cfg(target_pointer_width = "64")]
319319
pub type PREAD_PROCESS_MEMORY_ROUTINE = PREAD_PROCESS_MEMORY_ROUTINE64;
320-
#[cfg(target_arch = "x86_64")]
320+
#[cfg(target_pointer_width = "64")]
321321
pub type PFUNCTION_TABLE_ACCESS_ROUTINE = PFUNCTION_TABLE_ACCESS_ROUTINE64;
322-
#[cfg(target_arch = "x86_64")]
322+
#[cfg(target_pointer_width = "64")]
323323
pub type PGET_MODULE_BASE_ROUTINE = PGET_MODULE_BASE_ROUTINE64;
324-
#[cfg(target_arch = "x86_64")]
324+
#[cfg(target_pointer_width = "64")]
325325
pub type PTRANSLATE_ADDRESS_ROUTINE = PTRANSLATE_ADDRESS_ROUTINE64;
326326
#[cfg(target_arch = "x86")]
327327
FN!{stdcall PREAD_PROCESS_MEMORY_ROUTINE(

src/um/lmdfs.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ STRUCT!{struct DFS_INFO_1 {
4545
}}
4646
pub type PDFS_INFO_1 = *mut DFS_INFO_1;
4747
pub type LPDFS_INFO_1 = *mut DFS_INFO_1;
48-
#[cfg(target_arch = "x86_64")]
48+
#[cfg(target_pointer_width = "64")]
4949
IFDEF!{
5050
STRUCT!{struct DFS_INFO_1_32 {
5151
EntryPath: ULONG,
@@ -61,7 +61,7 @@ STRUCT!{struct DFS_INFO_2 {
6161
}}
6262
pub type PDFS_INFO_2 = *mut DFS_INFO_2;
6363
pub type LPDFS_INFO_2 = *mut DFS_INFO_2;
64-
#[cfg(target_arch = "x86_64")]
64+
#[cfg(target_pointer_width = "64")]
6565
IFDEF!{
6666
STRUCT!{struct DFS_INFO_2_32 {
6767
EntryPath: ULONG,
@@ -79,7 +79,7 @@ STRUCT!{struct DFS_STORAGE_INFO {
7979
}}
8080
pub type PDFS_STORAGE_INFO = *mut DFS_STORAGE_INFO;
8181
pub type LPDFS_STORAGE_INFO = *mut DFS_STORAGE_INFO;
82-
#[cfg(target_arch = "x86_64")]
82+
#[cfg(target_pointer_width = "64")]
8383
IFDEF!{
8484
STRUCT!{struct DFS_STORAGE_INFO_0_32 {
8585
State: ULONG,
@@ -106,7 +106,7 @@ STRUCT!{struct DFS_INFO_3 {
106106
}}
107107
pub type PDFS_INFO_3 = *mut DFS_INFO_3;
108108
pub type LPDFS_INFO_3 = *mut DFS_INFO_3;
109-
#[cfg(target_arch = "x86_64")]
109+
#[cfg(target_pointer_width = "64")]
110110
IFDEF!{
111111
STRUCT!{struct DFS_INFO_3_32 {
112112
EntryPath: ULONG,
@@ -129,7 +129,7 @@ STRUCT!{struct DFS_INFO_4 {
129129
}}
130130
pub type PDFS_INFO_4 = *mut DFS_INFO_4;
131131
pub type LPDFS_INFO_4 = *mut DFS_INFO_4;
132-
#[cfg(target_arch = "x86_64")]
132+
#[cfg(target_pointer_width = "64")]
133133
IFDEF!{
134134
STRUCT!{struct DFS_INFO_4_32 {
135135
EntryPath: ULONG,

src/um/nb30.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub const MAX_LANA: usize = 254;
1212
FN!{stdcall PFPOST(
1313
*mut NCB,
1414
) -> ()}
15-
#[cfg(target_arch = "x86_64")]
15+
#[cfg(target_pointer_width = "64")]
1616
STRUCT!{struct NCB {
1717
ncb_command: UCHAR,
1818
ncb_retcode: UCHAR,

src/um/oaidl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ UNION!{union __MIDL_IOleAutomationTypes_0001 {
8080
LongStr LongStr_mut: DWORD_SIZEDARR,
8181
HyperStr HyperStr_mut: HYPER_SIZEDARR,
8282
}}
83-
#[cfg(target_arch = "x86_64")]
83+
#[cfg(target_pointer_width = "64")]
8484
UNION!{union __MIDL_IOleAutomationTypes_0001 {
8585
[u64; 4],
8686
BstrStr BstrStr_mut: SAFEARR_BSTR,

src/um/sporder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ FN!{stdcall LPWSCWRITEPROVIDERORDER(
1818
lpwdCatalogEntryId: LPDWORD,
1919
dwNumberOfEntries: DWORD,
2020
) -> c_int}
21-
#[cfg(target_arch = "x86_64")]
21+
#[cfg(target_pointer_width = "64")]
2222
extern "system" {
2323
pub fn WSCWriteProviderOrder32(
2424
lpwdCatalogEntryId: LPDWORD,
@@ -33,7 +33,7 @@ FN!{stdcall LPWSCWRITENAMESPACEORDER(
3333
lpProviderId: LPGUID,
3434
dwNumberOfEntries: DWORD,
3535
) -> c_int}
36-
#[cfg(target_arch = "x86_64")]
36+
#[cfg(target_pointer_width = "64")]
3737
extern "system" {
3838
pub fn WSCWriteNameSpaceOrder32(
3939
lpProviderId: LPGUID,

src/um/sqltypes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// except according to those terms.
77
//! This module defines the types used in ODBC
88
use ctypes::*;
9-
#[cfg(target_arch = "x86_64")]
9+
#[cfg(target_pointer_width = "64")]
1010
use shared::basetsd::{INT64, UINT64};
1111
use shared::guiddef::GUID;
1212
use shared::windef::HWND;
@@ -18,11 +18,11 @@ pub type SQLDOUBLE = c_double;
1818
pub type SQLFLOAT = c_double;
1919
pub type SQLINTEGER = c_long;
2020
pub type SQLUINTEGER = c_ulong;
21-
#[cfg(target_arch = "x86_64")]
21+
#[cfg(target_pointer_width = "64")]
2222
pub type SQLLEN = INT64;
23-
#[cfg(target_arch = "x86_64")]
23+
#[cfg(target_pointer_width = "64")]
2424
pub type SQLULEN = UINT64;
25-
#[cfg(target_arch = "x86_64")]
25+
#[cfg(target_pointer_width = "64")]
2626
pub type SQLSETPOSIROW = UINT64;
2727
#[cfg(target_arch = "x86")]
2828
pub type SQLLEN = SQLINTEGER;

0 commit comments

Comments
 (0)