You've already forked linux-packaging-mono
Imported Upstream version 5.10.0.69
Former-commit-id: fc39669a0b707dd3c063977486506b6793da2890
This commit is contained in:
parent
d8f8abd549
commit
e2950ec768
331
external/corert/src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs
vendored
Normal file
331
external/corert/src/System.Private.CoreLib/shared/Internal/Runtime/CompilerServices/Unsafe.cs
vendored
Normal file
@@ -0,0 +1,331 @@
|
||||
// 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;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.Versioning;
|
||||
|
||||
#if BIT64
|
||||
using nuint = System.UInt64;
|
||||
using nint = System.Int64;
|
||||
#else
|
||||
using nuint = System.UInt32;
|
||||
using nint = System.Int32;
|
||||
#endif
|
||||
|
||||
//
|
||||
// The implementations of most the methods in this file are provided as intrinsics.
|
||||
// In CoreCLR, the body of the functions are replaced by the EE with unsafe code. See see getILIntrinsicImplementationForUnsafe for details.
|
||||
// In CoreRT, see Internal.IL.Stubs.UnsafeIntrinsics for details.
|
||||
//
|
||||
|
||||
namespace Internal.Runtime.CompilerServices
|
||||
{
|
||||
//
|
||||
// Subsetted clone of System.Runtime.CompilerServices.Unsafe for internal runtime use.
|
||||
// Keep in sync with https://github.com/dotnet/corefx/tree/master/src/System.Runtime.CompilerServices.Unsafe.
|
||||
//
|
||||
|
||||
/// <summary>
|
||||
/// For internal use only. Contains generic, low-level functionality for manipulating pointers.
|
||||
/// </summary>
|
||||
[CLSCompliant(false)]
|
||||
public static unsafe class Unsafe
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns a pointer to the given by-ref parameter.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void* AsPointer<T>(ref T value)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
// ldarg.0
|
||||
// conv.u
|
||||
// ret
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the size of an object of the given type parameter.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static int SizeOf<T>()
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
#endif
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
// sizeof !!0
|
||||
// ret
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Casts the given object to the specified type, performs no dynamic type checking.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T As<T>(object value) where T : class
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
// ldarg.0
|
||||
// ret
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reinterprets the given reference as a reference to a value of type <typeparamref name="TTo"/>.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref TTo As<TFrom, TTo>(ref TFrom source)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
// ldarg.0
|
||||
// ret
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element offset to the given reference.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T Add<T>(ref T source, int elementOffset)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
return ref AddByteOffset(ref source, (IntPtr)(elementOffset * (nint)SizeOf<T>()));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element offset to the given reference.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T Add<T>(ref T source, IntPtr elementOffset)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
return ref AddByteOffset(ref source, (IntPtr)((nint)elementOffset * (nint)SizeOf<T>()));
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element offset to the given pointer.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void* Add<T>(void* source, int elementOffset)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
return (byte*)source + (elementOffset * (nint)SizeOf<T>());
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element offset to the given reference.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static ref T AddByteOffset<T>(ref T source, nuint byteOffset)
|
||||
{
|
||||
return ref AddByteOffset(ref source, (IntPtr)(void*)byteOffset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether the specified references point to the same location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static bool AreSame<T>(ref T left, ref T right)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
// ldarg.0
|
||||
// ldarg.1
|
||||
// ceq
|
||||
// ret
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a block of memory at the given location with a given initial value
|
||||
/// without assuming architecture dependent alignment of the address.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void InitBlockUnaligned(ref byte startAddress, byte value, uint byteCount)
|
||||
{
|
||||
for (uint i = 0; i < byteCount; i++)
|
||||
AddByteOffset(ref startAddress, i) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value of type <typeparamref name="T"/> from the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ReadUnaligned<T>(void* source)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
return Unsafe.As<byte, T>(ref *(byte*)source);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value of type <typeparamref name="T"/> from the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T ReadUnaligned<T>(ref byte source)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
return Unsafe.As<byte, T>(ref source);
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a value of type <typeparamref name="T"/> to the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteUnaligned<T>(void* destination, T value)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
Unsafe.As<byte, T>(ref *(byte*)destination) = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a value of type <typeparamref name="T"/> to the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void WriteUnaligned<T>(ref byte destination, T value)
|
||||
{
|
||||
#if CORECLR
|
||||
typeof(T).ToString(); // Type token used by the actual method body
|
||||
throw new PlatformNotSupportedException();
|
||||
#else
|
||||
Unsafe.As<byte, T>(ref destination) = value;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an element offset to the given reference.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T AddByteOffset<T>(ref T source, IntPtr byteOffset)
|
||||
{
|
||||
// This method is implemented by the toolchain
|
||||
throw new PlatformNotSupportedException();
|
||||
|
||||
// ldarg.0
|
||||
// ldarg.1
|
||||
// add
|
||||
// ret
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value of type <typeparamref name="T"/> from the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Read<T>(void* source)
|
||||
{
|
||||
return Unsafe.As<byte, T>(ref *(byte*)source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reads a value of type <typeparamref name="T"/> from the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static T Read<T>(ref byte source)
|
||||
{
|
||||
return Unsafe.As<byte, T>(ref source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a value of type <typeparamref name="T"/> to the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Write<T>(void* destination, T value)
|
||||
{
|
||||
Unsafe.As<byte, T>(ref *(byte*)destination) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Writes a value of type <typeparamref name="T"/> to the given location.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void Write<T>(ref byte destination, T value)
|
||||
{
|
||||
Unsafe.As<byte, T>(ref destination) = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reinterprets the given location as a reference to a value of type <typeparamref name="T"/>.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static ref T AsRef<T>(void* source)
|
||||
{
|
||||
return ref Unsafe.As<byte, T>(ref *(byte*)source);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines the byte offset from origin to target from the given references.
|
||||
/// </summary>
|
||||
[Intrinsic]
|
||||
[NonVersionable]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static IntPtr ByteOffset<T>(ref T origin, ref T target)
|
||||
{
|
||||
throw new PlatformNotSupportedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -138,7 +138,9 @@ internal static partial class Interop
|
||||
new UnauthorizedAccessException(SR.UnauthorizedAccess_IODenied_NoPathName, inner);
|
||||
|
||||
case Error.ENAMETOOLONG:
|
||||
return new PathTooLongException(SR.IO_PathTooLong);
|
||||
return !string.IsNullOrEmpty(path) ?
|
||||
new PathTooLongException(SR.Format(SR.IO_PathTooLong_Path, path)) :
|
||||
new PathTooLongException(SR.IO_PathTooLong);
|
||||
|
||||
case Error.EWOULDBLOCK:
|
||||
return !string.IsNullOrEmpty(path) ?
|
||||
|
||||
@@ -44,7 +44,7 @@ internal static partial class Interop
|
||||
internal unsafe static extern int CompareStringOrdinalIgnoreCase(char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len);
|
||||
|
||||
[DllImport(Libraries.GlobalizationInterop, EntryPoint = "GlobalizationNative_GetSortVersion")]
|
||||
internal static extern int GetSortVersion();
|
||||
internal static extern int GetSortVersion(SafeSortHandle sortHandle);
|
||||
|
||||
internal class SafeSortHandle : SafeHandle
|
||||
{
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
// 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;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
internal static partial class Interop
|
||||
{
|
||||
internal static partial class GlobalizationInterop
|
||||
{
|
||||
[DllImport(Libraries.GlobalizationInterop, EntryPoint = "GlobalizationNative_LoadICU")]
|
||||
internal static extern int LoadICU();
|
||||
}
|
||||
}
|
||||
@@ -9,9 +9,6 @@ internal static partial class Interop
|
||||
{
|
||||
internal static partial class GlobalizationInterop
|
||||
{
|
||||
[DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Ansi, EntryPoint = "GlobalizationNative_ReadLink")] // readlink requires char*
|
||||
internal static extern bool ReadLink(string filePath, [Out] StringBuilder result, uint resultCapacity);
|
||||
|
||||
// needs to be kept in sync with TimeZoneDisplayNameType in System.Globalization.Native
|
||||
internal enum TimeZoneDisplayNameType
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using System;
|
||||
using System.Buffers;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal static partial class Interop
|
||||
@@ -10,7 +11,7 @@ internal static partial class Interop
|
||||
internal static partial class Sys
|
||||
{
|
||||
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCwd", SetLastError = true)]
|
||||
private static unsafe extern byte* GetCwd(byte* buffer, int bufferLength);
|
||||
private static extern unsafe byte* GetCwd(byte* buffer, int bufferLength);
|
||||
|
||||
internal static unsafe string GetCwd()
|
||||
{
|
||||
@@ -25,15 +26,13 @@ internal static partial class Interop
|
||||
}
|
||||
|
||||
// If that was too small, try increasing large buffer sizes
|
||||
// until we get one that works or until we hit MaxPath.
|
||||
int maxPath = Interop.Sys.MaxPath;
|
||||
if (StackLimit < maxPath)
|
||||
int bufferSize = StackLimit;
|
||||
do
|
||||
{
|
||||
int bufferSize = StackLimit;
|
||||
do
|
||||
checked { bufferSize *= 2; }
|
||||
byte[] buf = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
try
|
||||
{
|
||||
checked { bufferSize *= 2; }
|
||||
var buf = new byte[Math.Min(bufferSize, maxPath)];
|
||||
fixed (byte* ptr = &buf[0])
|
||||
{
|
||||
result = GetCwdHelper(ptr, buf.Length);
|
||||
@@ -43,11 +42,12 @@ internal static partial class Interop
|
||||
}
|
||||
}
|
||||
}
|
||||
while (bufferSize < maxPath);
|
||||
finally
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(buf);
|
||||
}
|
||||
}
|
||||
|
||||
// If we couldn't get the cwd with a MaxPath-sized buffer, something's wrong.
|
||||
throw Interop.GetExceptionForIoErrno(new ErrorInfo(Interop.Error.ENAMETOOLONG));
|
||||
while (true);
|
||||
}
|
||||
|
||||
private static unsafe string GetCwdHelper(byte* ptr, int bufferSize)
|
||||
|
||||
@@ -24,50 +24,7 @@ internal static partial class Interop
|
||||
PC_VDISABLE = 9,
|
||||
}
|
||||
|
||||
/// <summary>The maximum path length for the system. -1 if it hasn't yet been initialized.</summary>
|
||||
private static int s_maxPath = -1;
|
||||
|
||||
/// <summary>The maximum name length for the system. -1 if it hasn't yet been initialized.</summary>
|
||||
private static int s_maxName = -1;
|
||||
|
||||
internal static int MaxPath
|
||||
{
|
||||
get
|
||||
{
|
||||
// Benign race condition on cached value
|
||||
if (s_maxPath < 0)
|
||||
{
|
||||
// GetMaximumPath returns a long from PathConf
|
||||
// but our callers expect an int so we need to convert.
|
||||
long temp = GetMaximumPath();
|
||||
if (temp > int.MaxValue)
|
||||
s_maxPath = int.MaxValue;
|
||||
else
|
||||
s_maxPath = Convert.ToInt32(temp);
|
||||
}
|
||||
return s_maxPath;
|
||||
}
|
||||
}
|
||||
|
||||
internal static int MaxName
|
||||
{
|
||||
get
|
||||
{
|
||||
// Benign race condition on cached value
|
||||
if (s_maxName < 0)
|
||||
{
|
||||
int result = PathConf("/", PathConfName.PC_NAME_MAX);
|
||||
s_maxName = result >= 0 ? result : DEFAULT_PC_NAME_MAX;
|
||||
}
|
||||
|
||||
return s_maxName;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PathConf", SetLastError = true)]
|
||||
private static extern int PathConf(string path, PathConfName name);
|
||||
|
||||
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetMaximumPath")]
|
||||
private static extern long GetMaximumPath();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ internal static partial class Interop
|
||||
POSIX_FADV_SEQUENTIAL = 2, /* sequential I/O access */
|
||||
POSIX_FADV_WILLNEED = 3, /* will need specified pages */
|
||||
POSIX_FADV_DONTNEED = 4, /* don't need the specified pages */
|
||||
POSIX_FADV_NOREUSE = 5, /* data will only be acessed once */
|
||||
POSIX_FADV_NOREUSE = 5, /* data will only be accessed once */
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
63
external/corert/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadLink.cs
vendored
Normal file
63
external/corert/src/System.Private.CoreLib/shared/Interop/Unix/System.Native/Interop.ReadLink.cs
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
// 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;
|
||||
using System.Buffers;
|
||||
using System.Text;
|
||||
|
||||
internal static partial class Interop
|
||||
{
|
||||
internal static partial class Sys
|
||||
{
|
||||
/// <summary>
|
||||
/// Takes a path to a symbolic link and attempts to place the link target path into the buffer. If the buffer is too
|
||||
/// small, the path will be truncated. No matter what, the buffer will not be null terminated.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the symlink</param>
|
||||
/// <param name="buffer">The buffer to hold the output path</param>
|
||||
/// <param name="bufferSize">The size of the buffer</param>
|
||||
/// <returns>
|
||||
/// Returns the number of bytes placed into the buffer on success; bufferSize if the buffer is too small; and -1 on error.
|
||||
/// </returns>
|
||||
[DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadLink", SetLastError = true)]
|
||||
private static extern unsafe int ReadLink(string path, byte[] buffer, int bufferSize);
|
||||
|
||||
/// <summary>
|
||||
/// Takes a path to a symbolic link and returns the link target path.
|
||||
/// </summary>
|
||||
/// <param name="path">The path to the symlink</param>
|
||||
/// <returns>
|
||||
/// Returns the link to the target path on success; and null otherwise.
|
||||
/// </returns>
|
||||
public static string ReadLink(string path)
|
||||
{
|
||||
int bufferSize = 256;
|
||||
do
|
||||
{
|
||||
byte[] buffer = ArrayPool<byte>.Shared.Rent(bufferSize);
|
||||
try
|
||||
{
|
||||
int resultLength = Interop.Sys.ReadLink(path, buffer, buffer.Length);
|
||||
if (resultLength < 0)
|
||||
{
|
||||
// error
|
||||
return null;
|
||||
}
|
||||
else if (resultLength < buffer.Length)
|
||||
{
|
||||
// success
|
||||
return Encoding.UTF8.GetString(buffer, 0, resultLength);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ArrayPool<byte>.Shared.Return(buffer);
|
||||
}
|
||||
|
||||
// buffer was too small, loop around again and try with a larger buffer.
|
||||
bufferSize *= 2;
|
||||
} while (true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,5 +40,6 @@ internal partial class Interop
|
||||
internal const int ERROR_NOT_FOUND = 0x490;
|
||||
internal const int ERROR_BAD_IMPERSONATION_LEVEL = 0x542;
|
||||
internal const int E_FILENOTFOUND = unchecked((int)0x80070002);
|
||||
internal const int ERROR_TIMEOUT = 0x000005B4;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ internal static partial class Interop
|
||||
internal const string BCrypt = "BCrypt.dll";
|
||||
internal const string Crypt32 = "crypt32.dll";
|
||||
internal const string Kernel32 = "kernel32.dll";
|
||||
internal const string Ole32 = "ole32.dll";
|
||||
internal const string OleAut32 = "oleaut32.dll";
|
||||
internal const string User32 = "user32.dll";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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 Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class Kernel32
|
||||
{
|
||||
internal unsafe struct CREATEFILE2_EXTENDED_PARAMETERS
|
||||
{
|
||||
internal uint dwSize;
|
||||
internal uint dwFileAttributes;
|
||||
internal uint dwFileFlags;
|
||||
internal uint dwSecurityQosFlags;
|
||||
internal SECURITY_ATTRIBUTES* lpSecurityAttributes;
|
||||
internal IntPtr hTemplateFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,29 +3,30 @@
|
||||
// See the LICENSE file in the project root for more information.
|
||||
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class Kernel32
|
||||
{
|
||||
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFile2", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
|
||||
internal static extern unsafe SafeFileHandle CreateFile2(
|
||||
[DllImport(Libraries.Kernel32, EntryPoint = "CreateFile2", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
private static extern SafeFileHandle CreateFile2Private(
|
||||
string lpFileName,
|
||||
int dwDesiredAccess,
|
||||
System.IO.FileShare dwShareMode,
|
||||
System.IO.FileMode dwCreationDisposition,
|
||||
CREATEFILE2_EXTENDED_PARAMETERS* pCreateExParams);
|
||||
FileShare dwShareMode,
|
||||
FileMode dwCreationDisposition,
|
||||
ref Kernel32.CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams);
|
||||
|
||||
internal unsafe struct CREATEFILE2_EXTENDED_PARAMETERS
|
||||
internal static SafeFileHandle CreateFile2(
|
||||
string lpFileName,
|
||||
int dwDesiredAccess,
|
||||
FileShare dwShareMode,
|
||||
FileMode dwCreationDisposition,
|
||||
ref Kernel32.CREATEFILE2_EXTENDED_PARAMETERS pCreateExParams)
|
||||
{
|
||||
internal uint dwSize;
|
||||
internal uint dwFileAttributes;
|
||||
internal uint dwFileFlags;
|
||||
internal uint dwSecurityQosFlags;
|
||||
internal SECURITY_ATTRIBUTES* lpSecurityAttributes;
|
||||
internal IntPtr hTemplateFile;
|
||||
lpFileName = PathInternal.EnsureExtendedPrefixOverMaxPath(lpFileName);
|
||||
return CreateFile2Private(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, ref pCreateExParams);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// 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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class Kernel32
|
||||
{
|
||||
[DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
|
||||
internal static extern bool FreeLibrary(IntPtr hModule);
|
||||
}
|
||||
}
|
||||
@@ -85,8 +85,10 @@ internal static partial class Interop
|
||||
char* lpString,
|
||||
int cchStr);
|
||||
|
||||
#if !PROJECTN
|
||||
[DllImport("Kernel32.dll", CharSet = CharSet.Auto)]
|
||||
internal static extern bool GetUserPreferredUILanguages(uint dwFlags, out uint pulNumLanguages, char [] pwszLanguagesBuffer, ref uint pcchLanguagesBuffer);
|
||||
#endif //!PROJECTN
|
||||
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
|
||||
internal static extern int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// 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 Microsoft.Win32.SafeHandles;
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class Kernel32
|
||||
{
|
||||
internal const int LOAD_LIBRARY_AS_DATAFILE = 0x00000002;
|
||||
|
||||
[DllImport(Libraries.Kernel32, EntryPoint = "LoadLibraryExW", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern SafeLibraryHandle LoadLibraryEx(string libFilename, IntPtr reserved, int flags);
|
||||
}
|
||||
}
|
||||
35
external/corert/src/System.Private.CoreLib/shared/Interop/Windows/Normaliz/Interop.Idna.cs
vendored
Normal file
35
external/corert/src/System.Private.CoreLib/shared/Interop/Windows/Normaliz/Interop.Idna.cs
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
// 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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class Normaliz
|
||||
{
|
||||
//
|
||||
// Idn APIs
|
||||
//
|
||||
|
||||
[DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern unsafe int IdnToAscii(
|
||||
uint dwFlags,
|
||||
char* lpUnicodeCharStr,
|
||||
int cchUnicodeChar,
|
||||
char* lpASCIICharStr,
|
||||
int cchASCIIChar);
|
||||
|
||||
[DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern unsafe int IdnToUnicode(
|
||||
uint dwFlags,
|
||||
char* lpASCIICharStr,
|
||||
int cchASCIIChar,
|
||||
char* lpUnicodeCharStr,
|
||||
int cchUnicodeChar);
|
||||
|
||||
internal const int IDN_ALLOW_UNASSIGNED = 0x1;
|
||||
internal const int IDN_USE_STD3_ASCII_RULES = 0x2;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// 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;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class Normaliz
|
||||
{
|
||||
[DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern bool IsNormalizedString(int normForm, string source, int length);
|
||||
|
||||
[DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||
internal static extern int NormalizeString(
|
||||
int normForm,
|
||||
string source,
|
||||
int sourceLength,
|
||||
[System.Runtime.InteropServices.OutAttribute()]
|
||||
char[] destination,
|
||||
int destinationLength);
|
||||
}
|
||||
}
|
||||
12
external/corert/src/System.Private.CoreLib/shared/Interop/Windows/User32/Interop.Constants.cs
vendored
Normal file
12
external/corert/src/System.Private.CoreLib/shared/Interop/Windows/User32/Interop.Constants.cs
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// 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.
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class User32
|
||||
{
|
||||
internal const int HWND_BROADCAST = 0xffff;
|
||||
internal const int WM_SETTINGCHANGE = 0x001A;
|
||||
}
|
||||
}
|
||||
16
external/corert/src/System.Private.CoreLib/shared/Interop/Windows/User32/Interop.LoadString.cs
vendored
Normal file
16
external/corert/src/System.Private.CoreLib/shared/Interop/Windows/User32/Interop.LoadString.cs
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
// 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;
|
||||
using System.Text;
|
||||
using Microsoft.Win32.SafeHandles;
|
||||
|
||||
internal partial class Interop
|
||||
{
|
||||
internal partial class User32
|
||||
{
|
||||
[DllImport(Libraries.User32, SetLastError = true, EntryPoint = "LoadStringW", CharSet = CharSet.Unicode)]
|
||||
internal static extern int LoadString(SafeLibraryHandle handle, int id, [Out] StringBuilder buffer, int bufferLength);
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user