diff options
author | Sedar Gokbulut <sedarg@microsoft.com> | 2017-01-29 06:05:03 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2017-01-29 06:05:03 +0300 |
commit | d652ab4ef13b64d40582db236d45ee0d47caac26 (patch) | |
tree | 9f1bf8eb0f0d20a7ef2e0e8e8a98bd8f4739c7df /src | |
parent | bf69b3a62f4479e9d499ad121648a8df73ad30c8 (diff) |
Consuming Microsoft.NETCore.Native package, which brings in libSystem… (#2592)
* Consuming Microsoft.NETCore.Native package, which brings in libSystem.Globalization.Native.a
Replacing the dummy globalization implementation for unix with the actual one
Diffstat (limited to 'src')
13 files changed, 102 insertions, 31 deletions
diff --git a/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props b/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props index b82b5f8e9..a8d414e66 100644 --- a/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props +++ b/src/BuildIntegration/Microsoft.NETCore.Native.Unix.props @@ -40,6 +40,7 @@ See the LICENSE file in the project root for more information. <ItemGroup> <AdditionalNativeLibrary Include="$(IlcPath)/sdk/libSystem.Private.CoreLib.Native.a" /> <AdditionalNativeLibrary Include="$(IlcPath)/framework/System.Native.a" /> + <AdditionalNativeLibrary Include="$(IlcPath)/framework/libSystem.Globalization.Native.a" /> </ItemGroup> <ItemGroup> @@ -51,5 +52,6 @@ See the LICENSE file in the project root for more information. <LinkerArg Include="-ldl" /> <LinkerArg Include="-lm" /> <LinkerArg Include="-lrt" Condition="'$(TargetOS)' != 'OSX'" /> + <LinkerArg Include="-licucore" Condition="'$(TargetOS)' == 'OSX'" /> </ItemGroup> </Project> diff --git a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj index b3d3f7cd1..0aa86c2ce 100644 --- a/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj +++ b/src/System.Private.CoreLib/src/System.Private.CoreLib.csproj @@ -498,11 +498,14 @@ <Compile Include="System\Runtime\InteropServices\GCHandle.cs" /> <Compile Include="System\Runtime\InteropServices\GCHandleType.cs" /> <Compile Include="System\Runtime\InteropServices\InteropExtensions.cs" /> + <Compile Include="System\Runtime\InteropServices\MarshalAsAttribute.cs" /> <Compile Include="System\Runtime\InteropServices\NativeCallableAttribute.cs" /> <Compile Include="System\Runtime\InteropServices\PInvokeMarshal.cs" /> <Compile Include="System\Runtime\InteropServices\SafeBuffer.cs" /> <Compile Include="System\Runtime\InteropServices\SafeHandle.cs" /> <Compile Include="System\Runtime\InteropServices\UnmanagedFunctionPointerAttribute.cs" /> + <Compile Include="System\Runtime\InteropServices\UnmanagedType.cs" /> + <Compile Include="System\Runtime\InteropServices\VarEnum.cs" /> <Compile Include="System\Runtime\InteropServices\WindowsRuntime\EventRegistrationToken.cs" /> <Compile Include="System\Runtime\Versioning\NonVersionableAttribute.cs" /> <Compile Include="System\Runtime\Versioning\TargetFrameworkAttribute.cs" /> @@ -932,20 +935,33 @@ <Link>Interop\Windows\mincore\Interop.QueryUnbiasedInterruptTime.cs</Link> </Compile> </ItemGroup> - <ItemGroup Condition="'$(TargetsUnix)'=='true'"> - <Compile Include="Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" /> - <Compile Include="System\TimeZoneInfo.Unix.cs" /> - <!-- + <!-- Dummy globalization implementation --> + <ItemGroup Condition="'$(TargetsUnix)' == 'true' And '$(EnableDummyGlobalizationImplementation)' == 'true'"> + <Compile Include="System\Globalization\HijriCalendar.Dummy.cs" /> + <Compile Include="System\Globalization\JapaneseCalendar.Dummy.cs" /> + <Compile Include="System\Globalization\CultureInfo.Dummy.cs" /> + <Compile Include="System\Globalization\CompareInfo.Dummy.cs" /> + <Compile Include="System\Globalization\CultureData.Dummy.cs" /> + <Compile Include="System\Globalization\TextInfo.Dummy.cs" /> + <Compile Include="System\Globalization\CalendarData.Dummy.cs" /> + <Compile Include="System\Globalization\IdnMapping.Dummy.cs" /> + <Compile Include="System\Text\Normalization.Dummy.cs" /> + </ItemGroup> + <ItemGroup Condition="'$(TargetsUnix)' == 'true' And '$(EnableDummyGlobalizationImplementation)' != 'true'"> <Compile Include="System\Globalization\HijriCalendar.Unix.cs" /> <Compile Include="System\Globalization\JapaneseCalendar.Unix.cs" /> <Compile Include="System\Globalization\CultureInfo.Unix.cs" /> <Compile Include="System\Globalization\CompareInfo.Unix.cs" /> <Compile Include="System\Globalization\CultureData.Unix.cs" /> + <Compile Include="System\Globalization\LocaleData.Unix.cs" /> <Compile Include="System\Globalization\TextInfo.Unix.cs" /> <Compile Include="System\Globalization\CalendarData.Unix.cs" /> <Compile Include="System\Globalization\IdnMapping.Unix.cs" /> <Compile Include="System\Text\Normalization.Unix.cs" /> - --> + </ItemGroup> + <ItemGroup Condition="'$(TargetsUnix)'=='true'"> + <Compile Include="Microsoft\Win32\SafeHandles\SafeFileHandle.Unix.cs" /> + <Compile Include="System\TimeZoneInfo.Unix.cs" /> <Compile Include="System\DateTime.Unix.cs" /> <Compile Include="System\Globalization\FormatProvider.FormatAndParse.Unix.cs" /> <Compile Include="System\Environment.Unix.cs" /> @@ -1048,18 +1064,33 @@ <Compile Include="..\..\Common\src\Interop\Unix\System.Native\Interop.Write.cs"> <Link>Interop\Unix\System.Native\Interop.Write.cs</Link> </Compile> - </ItemGroup> - <!-- Dummy globalization implementation --> - <ItemGroup Condition="'$(TargetsUnix)'=='true'"> - <Compile Include="System\Globalization\HijriCalendar.Dummy.cs" /> - <Compile Include="System\Globalization\JapaneseCalendar.Dummy.cs" /> - <Compile Include="System\Globalization\CultureInfo.Dummy.cs" /> - <Compile Include="System\Globalization\CompareInfo.Dummy.cs" /> - <Compile Include="System\Globalization\CultureData.Dummy.cs" /> - <Compile Include="System\Globalization\TextInfo.Dummy.cs" /> - <Compile Include="System\Globalization\CalendarData.Dummy.cs" /> - <Compile Include="System\Globalization\IdnMapping.Dummy.cs" /> - <Compile Include="System\Text\Normalization.Dummy.cs" /> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Calendar.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Calendar.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Casing.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Casing.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Collation.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Collation.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Idna.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Idna.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Locale.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Locale.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Normalization.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Normalization.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.ResultCode.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.ResultCode.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.TimeZoneInfo.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.TimeZoneInfo.cs</Link> + </Compile> + <Compile Include="..\..\Common\src\Interop\Unix\System.Globalization.Native\Interop.Utils.cs"> + <Link>Interop\Unix\System.Globalization.Native\Interop.Utils.cs</Link> + </Compile> </ItemGroup> <ItemGroup> <Compile Include="..\..\Common\src\System\Collections\Generic\LowLevelList.cs"> diff --git a/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs b/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs index 21c3c9f7e..1500149dc 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.Unix.cs @@ -174,12 +174,12 @@ namespace System.Globalization { return IndexOfOrdinal(source, target, startIndex, count, ignoreCase: false); } - +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) { return IndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options)); } - +#endif fixed (char* pSource = source) { int index = Interop.GlobalizationInterop.IndexOf(_sortHandle, target, target.Length, pSource + startIndex, count, options); @@ -204,10 +204,12 @@ namespace System.Globalization return LastIndexOfOrdinal(source, target, startIndex, count, ignoreCase: false); } +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && target.IsFastSort()) { return LastIndexOf(source, target, startIndex, count, GetOrdinalCompareOptions(options)); } +#endif // startIndex is the index into source where we start search backwards from. leftStartIndex is the index into source // of the start of the string that is count characters away from startIndex. @@ -227,10 +229,12 @@ namespace System.Globalization Debug.Assert(!string.IsNullOrEmpty(prefix)); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && prefix.IsFastSort()) { return IsPrefix(source, prefix, GetOrdinalCompareOptions(options)); } +#endif return Interop.GlobalizationInterop.StartsWith(_sortHandle, prefix, prefix.Length, source, source.Length, options); } @@ -241,10 +245,12 @@ namespace System.Globalization Debug.Assert(!string.IsNullOrEmpty(suffix)); Debug.Assert((options & (CompareOptions.Ordinal | CompareOptions.OrdinalIgnoreCase)) == 0); +#if CORECLR if (_isAsciiEqualityOrdinal && CanUseAsciiOrdinalForOptions(options) && source.IsFastSort() && suffix.IsFastSort()) { return IsSuffix(source, suffix, GetOrdinalCompareOptions(options)); } +#endif return Interop.GlobalizationInterop.EndsWith(_sortHandle, suffix, suffix.Length, source, source.Length, options); } @@ -256,13 +262,13 @@ namespace System.Globalization if ((options & ValidSortkeyCtorMaskOffFlags) != 0) { - throw new ArgumentException(Environment.GetResourceString("Argument_InvalidFlag"), nameof(options)); + throw new ArgumentException(SR.Argument_InvalidFlag, nameof(options)); } byte [] keyData; if (source.Length == 0) { - keyData = EmptyArray<Byte>.Value; + keyData = Array.Empty<Byte>(); } else { @@ -348,9 +354,35 @@ namespace System.Globalization } } - [DllImport(JitHelpers.QCall)] - [SuppressUnmanagedCodeSecurity] - private static unsafe extern int InternalHashSortKey(byte* sortKey, int sortKeyLength, [MarshalAs(UnmanagedType.Bool)] bool forceRandomizedHashing, long additionalEntropy); + private static unsafe int InternalHashSortKey(byte* sortKey, int sortKeyLength, bool forceRandomizedHashing, long additionalEntropy) + { + if (forceRandomizedHashing || additionalEntropy != 0) + { + // TODO: Random hashing is yet to be done + // Active Issue: https://github.com/dotnet/corert/issues/2588 + throw new NotImplementedException(); + } + else + { + int hash1 = 5381; + int hash2 = hash1; + if (sortKeyLength == 0) + { + return 0; + } + if (sortKeyLength == 1) + { + return (((hash1 << 5) + hash1) ^ sortKey[0]) + (hash2 * 1566083941); + } + + for (int i = 0; i < (sortKeyLength & ~1); i += 2) + { + hash1 = ((hash1 << 5) + hash1) ^ sortKey[i]; + hash2 = ((hash2 << 5) + hash2) ^ sortKey[i+1]; + } + return hash1 + (hash2 * 1566083941); + } + } private static CompareOptions GetOrdinalCompareOptions(CompareOptions options) { diff --git a/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs b/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs index 16ebfbbaf..deee59442 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/CompareInfo.cs @@ -60,8 +60,8 @@ namespace System.Globalization // The interesting part is that since haw-US doesn't have its own sort, it has to point at another // locale, which is what SCOMPAREINFO does. - private readonly String _name; // The name used to construct this CompareInfo - private readonly String _sortName; // The name that defines our behavior + private String _name; // The name used to construct this CompareInfo + private String _sortName; // The name that defines our behavior private SortVersion _sortVersion; diff --git a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs index 6911688b0..e9fe86ace 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/CultureInfo.Unix.cs @@ -18,7 +18,7 @@ namespace System.Globalization if (CultureData.GetDefaultLocaleName(out localeName)) { cultureInfo = GetCultureByName(localeName, true); - cultureInfo.m_isReadOnly = true; + cultureInfo._isReadOnly = true; } else { diff --git a/src/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs b/src/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs index 3d9b777f6..a75b2a927 100644 --- a/src/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs +++ b/src/System.Private.CoreLib/src/System/Globalization/TextInfo.Unix.cs @@ -49,6 +49,7 @@ namespace System.Globalization { fixed (char* pResult = result) { +#if CORECLR if (IsAsciiCasingSameAsInvariant && s.IsAscii()) { int length = s.Length; @@ -69,6 +70,7 @@ namespace System.Globalization } } else +#endif { ChangeCase(pSource, s.Length, pResult, result.Length, toUpper); } diff --git a/src/System.Private.Interop/src/System/Runtime/InteropServices/MarshalAsAttribute.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalAsAttribute.cs index abc683771..abc683771 100644 --- a/src/System.Private.Interop/src/System/Runtime/InteropServices/MarshalAsAttribute.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/MarshalAsAttribute.cs diff --git a/src/System.Private.Interop/src/System/Runtime/InteropServices/UnmanagedType.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedType.cs index d8da0730a..d8da0730a 100644 --- a/src/System.Private.Interop/src/System/Runtime/InteropServices/UnmanagedType.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/UnmanagedType.cs diff --git a/src/System.Private.Interop/src/System/Runtime/InteropServices/VarEnum.cs b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/VarEnum.cs index a166d0095..a166d0095 100644 --- a/src/System.Private.Interop/src/System/Runtime/InteropServices/VarEnum.cs +++ b/src/System.Private.CoreLib/src/System/Runtime/InteropServices/VarEnum.cs diff --git a/src/System.Private.Interop/src/System.Private.Interop.csproj b/src/System.Private.Interop/src/System.Private.Interop.csproj index 7293a6c37..69f6179cb 100644 --- a/src/System.Private.Interop/src/System.Private.Interop.csproj +++ b/src/System.Private.Interop/src/System.Private.Interop.csproj @@ -144,7 +144,6 @@ <Compile Include="System\Runtime\InteropServices\Marshal.cs" /> <Compile Include="System\Runtime\InteropServices\MarshalAdapter.cs" /> <Compile Include="System\Runtime\InteropServices\MarshalImpl.cs" /> - <Compile Include="System\Runtime\InteropServices\MarshalAsAttribute.cs" /> <Compile Include="System\Runtime\InteropServices\MarshalDirectiveException.cs" /> <Compile Include="System\Runtime\InteropServices\MissingInteropDataException.cs" /> <Compile Include="System\Runtime\InteropServices\OptionalAttribute.cs" /> @@ -153,9 +152,7 @@ <Compile Include="System\Runtime\InteropServices\SafeArrayTypeMismatchException.cs" /> <Compile Include="System\Runtime\InteropServices\SEHException.cs" /> <Compile Include="System\Runtime\InteropServices\TypeIdentifierAttribute.cs" /> - <Compile Include="System\Runtime\InteropServices\UnmanagedType.cs" /> <Compile Include="System\Runtime\InteropServices\UnknownWrapper.cs" /> - <Compile Include="System\Runtime\InteropServices\VarEnum.cs" /> <Compile Include="System\Runtime\InteropServices\Variant.cs" /> <Compile Include="System\Runtime\InteropServices\VariantWrapper.cs" /> <Compile Include="System\Runtime\InteropServices\ComWeakReferenceHelpers.cs" /> diff --git a/src/System.Private.Interop/src/TypeForwarders.cs b/src/System.Private.Interop/src/TypeForwarders.cs index a62e87b36..0c636f7b4 100644 --- a/src/System.Private.Interop/src/TypeForwarders.cs +++ b/src/System.Private.Interop/src/TypeForwarders.cs @@ -3,3 +3,6 @@ // See the LICENSE file in the project root for more information. [assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.SafeBuffer))] +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.MarshalAsAttribute))] +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.UnmanagedType))] +[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Runtime.InteropServices.VarEnum))] diff --git a/src/packaging/netcoreapp/project.json b/src/packaging/netcoreapp/project.json index 5d366a435..a3e9f826b 100644 --- a/src/packaging/netcoreapp/project.json +++ b/src/packaging/netcoreapp/project.json @@ -8,7 +8,8 @@ "System.Linq": "4.4.0-beta-24913-02", "System.Runtime.CompilerServices.Unsafe": "4.4.0-beta-24913-02", - "runtime.native.System": "4.4.0-beta-24913-02" + "runtime.native.System": "4.4.0-beta-24913-02", + "Microsoft.NETCore.Native": "1.2.0-beta-24911-02" } } }, diff --git a/src/packaging/packages.targets b/src/packaging/packages.targets index 9fa966871..8b3605941 100644 --- a/src/packaging/packages.targets +++ b/src/packaging/packages.targets @@ -27,6 +27,8 @@ <JitPackageVersion>1.2.0-beta-24911-02</JitPackageVersion> + <MicrosoftNetCoreNativePackageVersion>1.2.0-beta-24911-02</MicrosoftNetCoreNativePackageVersion> + <ObjectWriterPackageVersion>1.0.13-prerelease-00001</ObjectWriterPackageVersion> <ObjectWriterNuPkgRid Condition="'$(OSGroup)'=='Linux'">ubuntu.14.04-x64</ObjectWriterNuPkgRid> <ObjectWriterNuPkgRid Condition="'$(ObjectWriterNuPkgRid)'==''">$(NuPkgRid)</ObjectWriterNuPkgRid> @@ -172,6 +174,7 @@ <ILCompilerFrameworkFiles Include="System.Runtime.CompilerServices.Unsafe/$(CoreFxPackageVersion)/lib/netstandard1.0/System.Runtime.CompilerServices.Unsafe.dll" /> <ILCompilerFrameworkFiles Include="runtime.$(NuPkgRid).runtime.native.System/$(CoreFxPackageVersion)/runtimes/$(NuPkgRid)/native/System.Native.a" Condition="'$(OsEnvironment)'!='Windows_NT'" /> + <ILCompilerFrameworkFiles Include="runtime.$(NuPkgRid).Microsoft.NETCore.Native/$(MicrosoftNetCoreNativePackageVersion)/runtimes/$(NuPkgRid)/native/libSystem.Globalization.Native.a" Condition="'$(OsEnvironment)'!='Windows_NT'" /> <ILCompilerSdkBinPlace Include="@(ILCompilerFrameworkFiles)"> <Text><![CDATA[ <file src="packages/%(Identity)" target="runtimes/$(NuPkgRid)/native/framework/%(Filename)%(Extension)" /> ]]></Text> |