Skip to content
This repository has been archived by the owner on Nov 1, 2020. It is now read-only.

Commit

Permalink
Add F# support (#2165)
Browse files Browse the repository at this point in the history
* add a dummy throwing stub for EventWriteTransfer (#2057)

This enables F# apps to be built against CoreRT
until System.Diagnostics.Tracing is ported to Unix

* add implementation for Environment.ProcessorCount (#2057)

- This fixes "unimplemented runtime method" runtime error
for GetNativeSystemInfo method.
- Achieves successful run of a simple "Hello Wolrd!"
F# console app

* Remove GetNativeSystemInfo unix stub (#2057)

The GetNativeSystemInfo method is no longer called
on unix so can be removed
  • Loading branch information
tonerdo authored and jkotas committed Nov 8, 2016
1 parent 1c12d82 commit 75f57dd
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ internal static partial class Interop
internal static partial class Libraries
{
internal const string CoreLibNative = "System.Private.CoreLib.Native";
internal const string SystemNative = "System.Native";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System.Runtime.InteropServices;

internal static partial class Interop
{
internal unsafe static partial class Sys
{
internal enum SysConfName
{
_SC_CLK_TCK = 1,
_SC_PAGESIZE = 2,
_SC_NPROCESSORS_ONLN = 3,
}

[DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_SysConf", SetLastError = true)]
internal static extern long SysConf(SysConfName name);
}
}
10 changes: 5 additions & 5 deletions src/Native/Bootstrap/platform.unix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ extern "C"
throw "CreateEventExW";
}

void GetNativeSystemInfo()
{
throw "GetNativeSystemInfo";
}

void OutputDebugStringW()
{
}
Expand Down Expand Up @@ -104,4 +99,9 @@ extern "C"
{
throw "GetCPInfo";
}

void EventWriteTransfer()
{
throw "EventWriteTransfer";
}
}
3 changes: 3 additions & 0 deletions src/System.Private.CoreLib/src/System.Private.CoreLib.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,9 @@
<Compile Include="..\..\Common\src\Interop\Unix\System.Private.CoreLib.Native\Interop.DynamicLoad.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.DynamicLoad.cs</Link>
</Compile>
<Compile Include="..\..\Common\src\Interop\Unix\System.Private.CoreLib.Native\Interop.SysConf.cs">
<Link>Interop\Unix\System.Private.CoreLib.Native\Interop.SysConf.cs</Link>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\Common\src\System\Collections\Generic\LowLevelList.cs">
Expand Down
2 changes: 2 additions & 0 deletions src/System.Private.CoreLib/src/System/Environment.Unix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public unsafe static String ExpandEnvironmentVariables(String name)
return blob.ToString();
}

public static int ProcessorCount => (int)Interop.Sys.SysConf(Interop.Sys.SysConfName._SC_NPROCESSORS_ONLN);

public unsafe static String GetEnvironmentVariable(String variable)
{
if (variable == null)
Expand Down
11 changes: 11 additions & 0 deletions src/System.Private.CoreLib/src/System/Environment.Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,16 @@ internal static long TickCount64
return (long)Interop.mincore.GetTickCount64();
}
}

public static int ProcessorCount
{
get
{
// @TODO: can we finally fix this to return the actual number of processors when there are >64?
Interop.mincore.SYSTEM_INFO info;
Interop.mincore.GetNativeSystemInfo(out info);
return (int)info.dwNumberOfProcessors;
}
}
}
}
11 changes: 0 additions & 11 deletions src/System.Private.CoreLib/src/System/Environment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,6 @@ public static void FailFast(String message, Exception exception)
RuntimeExceptionHelpers.FailFast(message, exception);
}

public static int ProcessorCount
{
get
{
// @TODO: can we finally fix this to return the actual number of processors when there are >64?
Interop.mincore.SYSTEM_INFO info;
Interop.mincore.GetNativeSystemInfo(out info);
return (int)info.dwNumberOfProcessors;
}
}

public static int CurrentManagedThreadId
{
get
Expand Down

0 comments on commit 75f57dd

Please sign in to comment.