summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Safar <marek.safar@gmail.com>2019-02-08 04:45:44 +0100
committerJan Kotas <jkotas@microsoft.com>2019-02-07 19:45:44 -0800
commit4c480a5f8e1e12d83f089891231c8eadbb5762e1 (patch)
tree342952afc39d55afb9eb3aa37e756558c5d6fb17
parent253c86a9ae4a90f88b24b0bfbba418fb835021a0 (diff)
downloadcoreclr-4c480a5f8e1e12d83f089891231c8eadbb5762e1.tar.gz
coreclr-4c480a5f8e1e12d83f089891231c8eadbb5762e1.tar.bz2
coreclr-4c480a5f8e1e12d83f089891231c8eadbb5762e1.zip
Move DateTime for Unix to shared partition (#22383)
* Move DateTime for Unix to shared partition * Keep CoreCLR specific implementation
-rw-r--r--src/System.Private.CoreLib/System.Private.CoreLib.csproj2
-rw-r--r--src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs2
-rw-r--r--src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems1
-rw-r--r--src/System.Private.CoreLib/shared/System/DateTime.Unix.cs (renamed from src/System.Private.CoreLib/src/System/DateTime.Unix.cs)13
-rw-r--r--src/System.Private.CoreLib/src/System/DateTime.Unix.CoreCLR.cs22
5 files changed, 29 insertions, 11 deletions
diff --git a/src/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
index feabb1d9a3..2feaaa25f8 100644
--- a/src/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -355,8 +355,8 @@
<Compile Include="$(BclSourcesRoot)\System\Variant.cs" />
</ItemGroup>
<ItemGroup Condition="'$(TargetsUnix)' == 'true'">
- <Compile Include="$(BclSourcesRoot)\System\DateTime.Unix.cs" />
<Compile Include="$(BclSourcesRoot)\Interop\Unix\Interop.Libraries.cs" />
+ <Compile Include="$(BclSourcesRoot)\System\DateTime.Unix.CoreCLR.cs" />
<Compile Include="$(BclSourcesRoot)\System\Globalization\GlobalizationMode.Unix.cs" />
<Compile Include="$(BclSourcesRoot)\System\Threading\ClrThreadPoolBoundHandle.Unix.cs" />
</ItemGroup>
diff --git a/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs b/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs
index d33b3f3685..f02ecac13b 100644
--- a/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs
+++ b/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs
@@ -2,8 +2,6 @@
// 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;
-using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
internal static partial class Interop
diff --git a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
index b44cc1e31f..8063228b62 100644
--- a/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
+++ b/src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems
@@ -1138,6 +1138,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Interop\Unix\System.Native\Interop.Write.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Internal\IO\File.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)System\DateTime.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Diagnostics\DebugProvider.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Environment.Unix.cs" />
<Compile Include="$(MSBuildThisFileDirectory)System\Globalization\CalendarData.Unix.cs" />
diff --git a/src/System.Private.CoreLib/src/System/DateTime.Unix.cs b/src/System.Private.CoreLib/shared/System/DateTime.Unix.cs
index f5982fab69..6cf018115b 100644
--- a/src/System.Private.CoreLib/src/System/DateTime.Unix.cs
+++ b/src/System.Private.CoreLib/shared/System/DateTime.Unix.cs
@@ -2,29 +2,26 @@
// 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.CompilerServices;
-
namespace System
{
public readonly partial struct DateTime
{
internal const bool s_systemSupportsLeapSeconds = false;
+#if !CORECLR
public static DateTime UtcNow
{
get
{
- return new DateTime(((ulong)(GetSystemTimeAsFileTime() + FileTimeOffset)) | KindUtc);
+ return new DateTime(((ulong)(Interop.Sys.GetSystemTimeAsTicks() + UnixEpochTicks)) | KindUtc);
}
}
+#endif
- internal static DateTime FromFileTimeLeapSecondsAware(long fileTime) => default(DateTime);
- internal static long ToFileTimeLeapSecondsAware(long ticks) => default(long);
+ internal static DateTime FromFileTimeLeapSecondsAware(long fileTime) => default;
+ internal static long ToFileTimeLeapSecondsAware(long ticks) => default;
// IsValidTimeWithLeapSeconds is not expected to be called at all for now on non-Windows platforms
internal static bool IsValidTimeWithLeapSeconds(int year, int month, int day, int hour, int minute, int second, DateTimeKind kind) => false;
-
- [MethodImplAttribute(MethodImplOptions.InternalCall)]
- internal static extern long GetSystemTimeAsFileTime();
}
}
diff --git a/src/System.Private.CoreLib/src/System/DateTime.Unix.CoreCLR.cs b/src/System.Private.CoreLib/src/System/DateTime.Unix.CoreCLR.cs
new file mode 100644
index 0000000000..1fd1e9ca40
--- /dev/null
+++ b/src/System.Private.CoreLib/src/System/DateTime.Unix.CoreCLR.cs
@@ -0,0 +1,22 @@
+// 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.CompilerServices;
+
+namespace System
+{
+ public readonly partial struct DateTime
+ {
+ public static DateTime UtcNow
+ {
+ get
+ {
+ return new DateTime(((ulong)(GetSystemTimeAsFileTime() + FileTimeOffset)) | KindUtc);
+ }
+ }
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ private static extern long GetSystemTimeAsFileTime();
+ }
+} \ No newline at end of file