diff --git a/docs/design/datacontracts/RuntimeInfo.md b/docs/design/datacontracts/RuntimeInfo.md index c56dbc5a58fcf7..94d4245e8fc208 100644 --- a/docs/design/datacontracts/RuntimeInfo.md +++ b/docs/design/datacontracts/RuntimeInfo.md @@ -21,6 +21,8 @@ public enum RuntimeInfoOperatingSystem : uint Unknown = 0, Win, Unix, + Browser, + Apple, } ``` @@ -50,6 +52,12 @@ Global variables used: The contract implementation returns the architecture and operating system global values parsed as the respective enum case-insensitively. If these globals are not available, the contract returns Unknown. +`Apple` covers all Apple platforms (macOS, iOS, tvOS, MacCatalyst) — i.e. any target where the +runtime is compiled with `TARGET_APPLE` defined. It is distinct from `Unix` so that consumers which +need to apply Apple-specific ABI or platform rules (for example, the Apple ARM64 stack-argument +alignment) can detect the target reliably. Apple platforms are still POSIX and will behave like +`Unix` for the purposes of any `GetTargetOperatingSystem() != Windows` check. + ### Reader versioning scheme When the .NET runtime team wants to signal that an update is recommended we update both the diff --git a/src/coreclr/vm/datadescriptor/datadescriptor.inc b/src/coreclr/vm/datadescriptor/datadescriptor.inc index be78f9c1bf6028..b7e13c1f8574db 100644 --- a/src/coreclr/vm/datadescriptor/datadescriptor.inc +++ b/src/coreclr/vm/datadescriptor/datadescriptor.inc @@ -1311,6 +1311,11 @@ CDAC_GLOBALS_BEGIN() #error Handle 'Browser' define #endif // Browser CDAC_GLOBAL_STRING(OperatingSystem, Browser) +#elif defined(TARGET_APPLE) +#ifdef Apple +#error Handle 'Apple' define +#endif // Apple +CDAC_GLOBAL_STRING(OperatingSystem, Apple) #elif defined(TARGET_UNIX) #ifdef Unix #error Handle 'Unix' define diff --git a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs index 42f567a60e9657..0f2dfe0615bd52 100644 --- a/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs +++ b/src/native/managed/cdac/Microsoft.Diagnostics.DataContractReader.Abstractions/Contracts/IRuntimeInfo.cs @@ -27,6 +27,7 @@ public enum RuntimeInfoOperatingSystem : uint Windows, Unix, Browser, + Apple, } public interface IRuntimeInfo : IContract diff --git a/src/native/managed/cdac/tests/DumpTests/RuntimeInfoDumpTests.cs b/src/native/managed/cdac/tests/DumpTests/RuntimeInfoDumpTests.cs index 7a3517cb285ace..5faac6d4794b64 100644 --- a/src/native/managed/cdac/tests/DumpTests/RuntimeInfoDumpTests.cs +++ b/src/native/managed/cdac/tests/DumpTests/RuntimeInfoDumpTests.cs @@ -52,7 +52,8 @@ public void RuntimeInfo_OperatingSystemMatchesDumpMetadata(TestConfiguration con RuntimeInfoOperatingSystem expected = DumpMetadata.Os switch { "windows" => RuntimeInfoOperatingSystem.Windows, - "linux" or "osx" or "freebsd" => RuntimeInfoOperatingSystem.Unix, + "osx" => RuntimeInfoOperatingSystem.Apple, + "linux" or "freebsd" => RuntimeInfoOperatingSystem.Unix, _ => RuntimeInfoOperatingSystem.Unknown, };