Skip to content

Commit 478f445

Browse files
am11baronfel
authored andcommitted
P/invoke Kernel32.dll only on Windows (#7858)
1 parent 1622740 commit 478f445

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/fsharp/lib.fs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ module internal FSharp.Compiler.Lib
44

55
open System.IO
66
open System.Collections.Generic
7+
open System.Runtime.InteropServices
78
open Internal.Utilities
89
open FSharp.Compiler.AbstractIL.Internal
910
open FSharp.Compiler.AbstractIL.Internal.Library
@@ -518,7 +519,7 @@ module UnmanagedProcessExecutionOptions =
518519
// Translation of C# from http://swikb/v1/DisplayOnlineDoc.aspx?entryID=826 and copy in bug://5018
519520
[<System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)>]
520521
let EnableHeapTerminationOnCorruption() =
521-
if (System.Environment.OSVersion.Version.Major >= 6 && // If OS is Vista or higher
522+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && System.Environment.OSVersion.Version.Major >= 6 && // If OS is Vista or higher
522523
System.Environment.Version.Major < 3) then // and CLR not 3.0 or higher
523524
// "The flag HeapSetInformation sets is available in Windows XP SP3 and later.
524525
// The data structure used for heap information is available on earlier versions of Windows.
@@ -547,4 +548,4 @@ module StackGuard =
547548

548549
let EnsureSufficientExecutionStack recursionDepth =
549550
if recursionDepth > MaxUncheckedRecursionDepth then
550-
RuntimeHelpers.EnsureSufficientExecutionStack ()
551+
RuntimeHelpers.EnsureSufficientExecutionStack ()

0 commit comments

Comments
 (0)