Replies: 3 comments 32 replies
-
What about ARM64? How does that compare?
The
Anyway I guess my biggest question on this is how common it is to have types changed on methods across architectures.
There is: it's To not coalesce things like |
Beta Was this translation helpful? Give feedback.
-
Rust already maps The |
Beta Was this translation helpful? Give feedback.
-
How does this look? I like the ArchSupported attribute because there are sometimes methods/structs that only appear on certain architectures and then there aren't versions for the other architectures, but the ArchSpecificVersions leads you to the others ones if they exist. I could also combine ArchSupported and ArchSpecific, like: [ArchSupported(Arch.x64 | Arch.arm64)]
[DllImport("USER32", ExactSpelling = true, SetLastError = true)]
public static extern IntPtr GetWindowLongPtrA([In] HWND hWnd, [In] WINDOW_LONG_PTR_INDEX nIndex);
[ArchSupported(Arch.x64 | Arch.arm64)]
[ArchSpecific(x86 = "JSCreateContext__x86__")]
[DllImport("chakra", ExactSpelling = true)]
public unsafe static extern JsErrorCode JsCreateContext([In] void* runtime, [In] IDebugApplication64 debugApplication, [Out] void** newContext);
[ArchSupported(Arch.x86)]
[DllImport("chakra", EntryPoint = "JSCreateContext")]
public unsafe static extern JsErrorCode JSCreateContext__x86__([In] void* runtime, [In] IDebugApplication32 debugApplication, [Out] void** newContext);
[ArchSupported(Arch.x64)]
[ArchSpecific(x86 = "CONTEXT__x86__", arm64 = "CONTEXT__arm64__")]
public partial struct CONTEXT
{
...
}
[ArchSupported(Arch.x86)]
public partial struct CONTEXT__x86__
{
...
} |
Beta Was this translation helpful? Give feedback.
-
Below is how I'm thinking about solving arch-specific differences. Thoughts, comments?
To solve #384, we talked about using attributes to surface arch-specific differences. I built a 32-bit version of the .winmd and compared it with the normal 64-bit version using WinmdUtils:
dotnet D:\repos\win32metadata\sources\WinmdUtils\bin\Release\netcoreapp3.1\WinmdUtils.dll compare --first D:\repos\win32metadata\bin\Windows.Win32.64.winmd --second D:\repos\win32metadata\bin\Windows.Win32.32.winmd
Some common cases and how I plan to solve them:
A method or struct in one but not the other: (This one means it's in x64 but not x86)
Windows.Win32.Debug.Apis.RtlAddFunctionTable(FunctionTable,EntryCount,BaseAddress) not found in 2nd winmd
Add this to the metadata:
[ArchDifferences(Supported = Arch.x64)]
A struct has a different packing on 32-bit: (This one means 64-bit has no packing but 32-bit does)
Windows.Win32.WindowsAndMessaging.OPENFILENAMEA : => [StructLayout(0,Pack=1)]
Add this to the metadata:
[ArchDifferences(32BitPacking = 1)]
A parameter or return type changes on a method: (This one means the parameter debugApplication changes types between 64 and 32-bit)
Windows.Win32.Js.Apis.JsCreateContext(runtime,debugApplication,newContext) : debugApplication...IDebugApplication64 => IDebugApplication32
This one is trickier, but I think the best solution is to emit it twice, once for each signature, and add attributes to indicate which
one is for which:
I'm thinking I would do the same thing for a struct where a field was in one or not the other. I could attribute the field, but I could also attribute the entire struct and emit it twice.
A really annoying one is where lots of methods and structs in Search use a typedef for an int to be either 32 or 64 bits long depending on the arch: (This means it's a 64-bit int vs a 32-bit int)
Windows.Win32.Search.DBVECTOR.size...UInt64 => UInt32
Original definition:
There are a lot of these. The easiest would be to make these UIntPtr or use a NativeTypedef to make a DBLENGTH that wraps a UIntPtr. That would collapse all of these into the same version so I wouldn't need to add any arch-specific attributes. I wish there was a SIZE_T type in ECMA-335.
Beta Was this translation helpful? Give feedback.
All reactions