Skip to content

Commit 3291102

Browse files
committed
Merge pull request #457 from nosami/conditional-memory-mapped-files
Change throw/catch to conditional. fixes #456
2 parents c1ca061 + ffe2b44 commit 3291102

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/absil/il.fs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,17 @@ open Microsoft.FSharp.Compiler.AbstractIL
1313
open Microsoft.FSharp.Compiler.AbstractIL.Internal
1414
open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library
1515
open Microsoft.FSharp.Compiler.AbstractIL.Diagnostics
16+
open System
1617
open System.Collections.Generic
1718
open System.Collections
1819

1920
let logging = false
2021

22+
let runningOnWindows =
23+
match System.Environment.OSVersion.Platform with
24+
| PlatformID.Win32NT | PlatformID.Win32S | PlatformID.Win32Windows | PlatformID.WinCE -> true
25+
| _ -> false
26+
2127
// Officially supported way to detect if we are running on Mono.
2228
// See http://www.mono-project.com/FAQ:_Technical
2329
// "How can I detect if am running in Mono?" section

src/absil/il.fsi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,6 +2275,7 @@ type ILPropertyRef =
22752275
member Name: string
22762276
interface System.IComparable
22772277

2278+
val runningOnWindows: bool
22782279
val runningOnMono: bool
22792280

22802281
type ILReferences =

src/absil/ilread.fs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3971,19 +3971,15 @@ let ClosePdbReader pdb =
39713971
#endif
39723972

39733973
let OpenILModuleReader infile opts =
3974-
3975-
#if FX_NO_NATIVE_MEMORY_MAPPED_FILES
3976-
#else
3977-
try
3974+
if IL.runningOnWindows then
39783975
let mmap = MemoryMappedFile.Create infile
39793976
let modul,ilAssemblyRefs,pdb = genOpenBinaryReader infile mmap opts
39803977
{ modul = modul;
39813978
ilAssemblyRefs=ilAssemblyRefs;
39823979
dispose = (fun () ->
39833980
mmap.Close();
39843981
ClosePdbReader pdb) }
3985-
with _ ->
3986-
#endif
3982+
else
39873983
let mc = ByteFile.OpenIn infile
39883984
let modul,ilAssemblyRefs,pdb = genOpenBinaryReader infile mc opts
39893985
{ modul = modul;

0 commit comments

Comments
 (0)