<Project>
<PropertyGroup>
+ <FeatureCoreCLR>true</FeatureCoreCLR>
<FeatureCollectibleALC>true</FeatureCollectibleALC>
<FeatureEventTrace>true</FeatureEventTrace>
<FeatureHardwareIntrinsics>true</FeatureHardwareIntrinsics>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsUnix)' == 'true'">
- <FeaturePal>true</FeaturePal>
<FeatureXplatEventSource>true</FeatureXplatEventSource>
<FeatureArrayStubAsIL>true</FeatureArrayStubAsIL>
<DefineConstants Condition="'$(FeatureCominteropWinRTManagedActivation)' == 'true'">$(DefineConstants);FEATURE_COMINTEROP_WINRT_MANAGED_ACTIVATION</DefineConstants>
<DefineConstants Condition="'$(FeatureManagedEtw)' == 'true'">$(DefineConstants);FEATURE_MANAGED_ETW</DefineConstants>
<DefineConstants Condition="'$(FeatureManagedEtwChannels)' == 'true'">$(DefineConstants);FEATURE_MANAGED_ETW_CHANNELS</DefineConstants>
- <DefineConstants Condition="'$(FeaturePal)' == 'true'">$(DefineConstants);FEATURE_PAL</DefineConstants>
<DefineConstants Condition="'$(FeaturePerfTracing)' == 'true'">$(DefineConstants);FEATURE_PERFTRACING</DefineConstants>
<DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
<DefineConstants Condition="'$(FeatureWin32Registry)' == 'true'">$(DefineConstants);FEATURE_WIN32_REGISTRY</DefineConstants>
<DefineConstants Condition="'$(ProfilingSupportedBuild)' == 'true'">$(DefineConstants);PROFILING_SUPPORTED</DefineConstants>
<DefineConstants Condition="'$(FeatureProfAttach)' == 'true'">$(DefineConstants);FEATURE_PROFAPI_ATTACH_DETACH</DefineConstants>
- <DefineConstants Condition="'$(TargetsUnix)' == 'true'">$(DefineConstants);PLATFORM_UNIX</DefineConstants>
- <DefineConstants Condition="'$(TargetsWindows)' == 'true'">$(DefineConstants);PLATFORM_WINDOWS</DefineConstants>
- <DefineConstants Condition="'$(TargetsOSX)' == 'true'">$(DefineConstants);PLATFORM_OSX</DefineConstants>
+ <DefineConstants Condition="'$(TargetsUnix)' == 'true'">$(DefineConstants);TARGET_UNIX</DefineConstants>
+ <DefineConstants Condition="'$(TargetsWindows)' == 'true'">$(DefineConstants);TARGET_WINDOWS</DefineConstants>
+ <DefineConstants Condition="'$(TargetsOSX)' == 'true'">$(DefineConstants);TARGET_OSX</DefineConstants>
</PropertyGroup>
</Project>
<PropertyGroup Condition="'$(Platform)' == 'x64'">
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
- <DefineConstants>BIT64;AMD64;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_64BIT;TARGET_AMD64;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<PlatformTarget>x86</PlatformTarget>
- <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm'">
<PlatformTarget>arm</PlatformTarget>
- <DefineConstants>BIT32;ARM;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;TARGET_ARM;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm64'">
<PlatformTarget>AnyCPU</PlatformTarget>
- <DefineConstants>BIT64;ARM64;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_64BIT;TARGET_ARM64;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<!-- Configuration specific properties -->
throw new ArgumentNullException(argName);
}
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
string? result = Marshal.PtrToStringUni(arg);
#else
string? result = Marshal.PtrToStringUTF8(arg);
private IntPtr ArgPtr; // Pointer to remaining args.
private int RemainingArgs; // # of remaining args.
-#if PLATFORM_WINDOWS // Native Varargs are not supported on Unix
+#if TARGET_WINDOWS // Native Varargs are not supported on Unix
[MethodImpl(MethodImplOptions.InternalCall)]
private extern ArgIterator(IntPtr arglist);
{
throw new PlatformNotSupportedException(SR.PlatformNotSupported_ArgIterator); // https://github.com/dotnet/coreclr/issues/9204
}
-#endif // PLATFORM_WINDOWS
+#endif // TARGET_WINDOWS
}
}
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
using nint = System.UInt64;
#else
using System.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
{
string s = GetFullyQualifiedName();
-#if !FEATURE_PAL
- int i = s.LastIndexOf('\\');
-#else
int i = s.LastIndexOf(System.IO.Path.DirectorySeparatorChar);
-#endif
+
if (i == -1)
return s;
using System.Runtime.Intrinsics.X86;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
// then we use fibonacci hashing to reduce the value to desired size.
int hashShift = HashShift(table);
-#if BIT64
+#if TARGET_64BIT
ulong hash = (((ulong)source << 32) | ((ulong)source >> 32)) ^ (ulong)target;
return (int)((hash * 11400714819323198485ul) >> hashShift);
#else
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
// after the sync block, so don't count that.
// This property allows C#'s fixed statement to work on Strings.
// On 64 bit platforms, this should be 12 (8+4) and on 32 bit 8 (4+4).
-#if BIT64
+#if TARGET_64BIT
12;
#else // 32
8;
-#endif // BIT64
+#endif // TARGET_64BIT
}
internal class RawArrayData
{
public uint Length; // Array._numComponents padded to IntPtr
-#if BIT64
+#if TARGET_64BIT
public uint Padding;
#endif
public byte Data;
#endif
;
-#if BIT64
+#if TARGET_64BIT
private const int InterfaceMapOffset = 0x38
#else
private const int InterfaceMapOffset = 0x24
// though I couldn't reproduce that. In either case, that means we should continue
// throwing an OOM instead of an ArgumentOutOfRangeException for "negative" amounts of memory.
UIntPtr numBytes;
-#if BIT64
+#if TARGET_64BIT
numBytes = new UIntPtr(unchecked((ulong)cb.ToInt64()));
#else // 32
numBytes = new UIntPtr(unchecked((uint)cb.ToInt32()));
namespace System.Runtime.InteropServices.WindowsRuntime
{
-#if BIT64
+#if TARGET_64BIT
[StructLayout(LayoutKind.Explicit, Size = 24)]
#else
[StructLayout(LayoutKind.Explicit, Size = 20)]
}
}
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
private const CharSet HostpolicyCharSet = CharSet.Unicode;
#else
private const CharSet HostpolicyCharSet = CharSet.Ansi;
return loadedAssembly!;
}
-#if !FEATURE_PAL
+#if TARGET_WINDOWS
[DllImport(RuntimeHelpers.QCall, CharSet = CharSet.Unicode)]
private static extern IntPtr LoadFromInMemoryModuleInternal(IntPtr ptrNativeAssemblyLoadContext, IntPtr hModule, ObjectHandleOnStack retAssembly);
fixed (char* pwzChar = strManaged)
{
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
cbWritten = Interop.Kernel32.WideCharToMultiByte(
Interop.Kernel32.CP_ACP,
bestFit ? 0 : Interop.Kernel32.WC_NO_BEST_FIT_CHARS,
// but on ARM it will allow us to correctly determine the layout of native argument lists containing
// VARIANTs). Note that the field names here don't matter: none of the code refers to these fields,
// the structure just exists to provide size information to the IL marshaler.
-#if BIT64
+#if TARGET_64BIT
private IntPtr data1;
private IntPtr data2;
#else
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IntPtr GetStubContext();
-#if BIT64
+#if TARGET_64BIT
[MethodImpl(MethodImplOptions.InternalCall)]
internal static extern IntPtr GetStubContextAddr();
-#endif // BIT64
+#endif // TARGET_64BIT
#if FEATURE_ARRAYSTUB_AS_IL
[MethodImpl(MethodImplOptions.InternalCall)]
// Both MultiByteToWideChar and the UTF8Encoding instance used on Unix-like
// platforms default to replacing invalid characters with the Unicode replacement
// character U+FFFD.
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
convertedChars = Interop.Kernel32.MultiByteToWideChar(
Interop.Kernel32.CP_ACP,
Interop.Kernel32.MB_PRECOMPOSED,
#pragma warning disable 0809 //warning CS0809: Obsolete member 'Utf8Span.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
#else
return default;
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)text.Length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
return default;
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)text.Length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
return default;
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)text.Length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
return default;
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)text.Length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
using System.Text;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
#else
[StackTraceHidden]
private void ValidateStartIndexAndLength(int startIndex, int length)
{
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)startIndex + (ulong)(uint)length > (ulong)(uint)this.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
#else
using System.Collections;
using System.Collections.Generic;
-#if !FEATURE_PAL
+#if !TARGET_UNIX
using Dia;
using Dia.Util;
-#endif // !FEATURE_PAL
+#endif // !TARGET_UNIX
using System.Globalization;
/******************************************************************************
String keyBaseName);
}
-#if !FEATURE_PAL
+#if !TARGET_UNIX
public class PdbSymbolProvider : SymbolProvider
{
public PdbSymbolProvider(String symbolFilename, String dllFilename)
FileInfo fPDB = null;
DiaFile df = null;
}
-#endif // !FEATURE_PAL
+#endif // !TARGET_UNIX
public class Shell
{
if (pdbFile != null)
{
-#if FEATURE_PAL
+#if TARGET_UNIX
throw new InvalidOperationException("PDBs are only supported on Windows.");
#else
PdbSymbolProvider pdbSymProvider = new PdbSymbolProvider(pdbFile, dllFile);
CORJIT_FLAG_RELATIVE_CODE_RELOCS = 41, // JIT should generate PC-relative address computations instead of EE relocation records
CORJIT_FLAG_NO_INLINING = 42, // JIT should not inline any called method into this method
-#region ARM64
+#region TARGET_ARM64
CORJIT_FLAG_HAS_ARM64_AES = 43, // ID_AA64ISAR0_EL1.AES is 1 or better
CORJIT_FLAG_HAS_ARM64_ATOMICS = 44, // ID_AA64ISAR0_EL1.Atomic is 2 or better
CORJIT_FLAG_HAS_ARM64_CRC32 = 45, // ID_AA64ISAR0_EL1.CRC32 is 1 or better
private const string PathEnvSubdirectoryName = "Subdirectory";
private const string PathEnvFileName = "MovedNativeLib";
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
private const string RelativePath1 = @".\RelativeNative\..\DllImportPath_Relative";
private const string RelativePath3 = @"..\DllImportPathTest\DllImportPath_Relative";
#else
Console.WriteLine("Method Auto.Marshal_Int_InOut: ExactSpelling = false. Verify CharSet.Auto behavior per-platform.");
int int9 = intManaged;
int intRet9 = Auto.Marshal_Int_InOut2(int9);
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
failures += Verify(intReturnUnicode, intManaged, intRet9, int9);
#else
failures += Verify(intReturnAnsi, intManaged, intRet9, int9);
// It required GCStress=0xc and GcStressOnDirectCalls=1 to hit issues. The issues were with saving GC pointers in the return registers.
// The GC infra has to correctly mark registers with pointers as alive and must not report registers without pointers.
-#if BIT32
+#if TARGET_32BIT
using nint = System.Int32;
#else
using nint = System.Int64;
<CLRTestPriority>1</CLRTestPriority>
</PropertyGroup>
<PropertyGroup Condition=" '$(PointerSize)' == '32' ">
- <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
if (!jitLog.Check("System.Numerics.Vector:ConvertToInt32(struct):struct")) returnVal = Fail;
if (!jitLog.Check("System.Numerics.Vector:ConvertToSingle(struct):struct")) returnVal = Fail;
// SIMD Conversion to Int64 is not supported on x86
-#if !BIT32
+#if !TARGET_32BIT
if (!jitLog.Check("System.Numerics.Vector:ConvertToInt64(struct):struct")) returnVal = Fail;
-#endif // !BIT32
+#endif // !TARGET_32BIT
if (!jitLog.Check("System.Numerics.Vector:ConvertToDouble(struct):struct")) returnVal = Fail;
if (!jitLog.Check("System.Numerics.Vector:Narrow(struct,struct):struct")) returnVal = Fail;
if (!jitLog.Check("System.Numerics.Vector:Widen(struct,byref,byref)")) returnVal = Fail;
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildArch)' == 'x86'">
- <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup Condition="'$(BuildArch)' == 'x86'">
- <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<PropertyGroup>
<AssemblyName>Microsoft.Diagnostics.Tracing.EventSource</AssemblyName>
<NoWarn>$(NoWarn);CS1573</NoWarn>
- <DefineConstants>$(DefineConstants);NO_EVENTCOMMANDEXECUTED_SUPPORT;ES_BUILD_STANDALONE;FEATURE_MANAGED_ETW;PLATFORM_WINDOWS</DefineConstants>
+ <DefineConstants>$(DefineConstants);NO_EVENTCOMMANDEXECUTED_SUPPORT;ES_BUILD_STANDALONE;FEATURE_MANAGED_ETW;TARGET_WINDOWS</DefineConstants>
<Configurations>net461-Windows_NT-Debug;net461-Windows_NT-Release;$(NetFrameworkCurrent)-Windows_NT-Debug;$(NetFrameworkCurrent)-Windows_NT-Release</Configurations>
<Nullable>enable</Nullable>
</PropertyGroup>
<OptionCompare>Binary</OptionCompare>
<WarningsNotAsErrors>42025</WarningsNotAsErrors>
<DefineConstants>$(DefineConstants),LATEBINDING=True</DefineConstants>
- <DefineConstants Condition="'$(TargetsWindows)' == 'true'">$(DefineConstants),PLATFORM_WINDOWS=True</DefineConstants>
+ <DefineConstants Condition="'$(TargetsWindows)' == 'true'">$(DefineConstants),TARGET_WINDOWS=True</DefineConstants>
<NoWarn Condition="'$(TargetsWindows)' != 'true'">$(NoWarn);CA1823</NoWarn> <!-- Avoid unused fields warnings in Unix build -->
<AssemblyName>Microsoft.VisualBasic.Core</AssemblyName>
<NoStdLib>true</NoStdLib>
<Diagnostics.DebuggerHiddenAttribute()>
Friend Shared Sub SetTime(ByVal dtTime As DateTime)
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Dim systime As New NativeTypes.SystemTime
SafeNativeMethods.GetLocalTime(systime)
<Diagnostics.DebuggerHiddenAttribute()>
Friend Shared Sub SetDate(ByVal vDate As DateTime)
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Dim systime As New NativeTypes.SystemTime
SafeNativeMethods.GetLocalTime(systime)
<ResourceExposure(ResourceScope.None)>
<ResourceConsumption(ResourceScope.Machine, ResourceScope.Machine)>
Friend Function ParseInputField(ByVal Value As Object, ByVal vtInput As VariantType) As Object
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Dim numprsPtr() As Byte
Dim vtSuffix As Integer
Dim cDecMax As Integer
End Property
Private Function IsDBCSCulture() As Boolean
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
'This function is apparently trying to determine a different default for East Asian systems.
If System.Runtime.InteropServices.Marshal.SystemMaxDBCSCharSize = 1 Then
Return False
Imports System.Text
Imports Microsoft.VisualBasic.CompilerServices
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Imports Microsoft.VisualBasic.CompilerServices.NativeMethods
Imports Microsoft.VisualBasic.CompilerServices.NativeTypes
#End If
' but have write permission / ACL thus cannot see but can delete / overwrite destination.
If Environment.OSVersion.Platform = PlatformID.Win32NT Then ' Platforms supporting MoveFileEx.
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Try
Dim succeed As Boolean = NativeMethods.MoveFileEx(
sourceFileFullPath, destinationFileFullPath, m_MOVEFILEEX_FLAGS)
Debug.Assert(FullTargetPath <> "" And IO.Path.IsPathRooted(FullTargetPath), "Invalid FullTargetPath")
Debug.Assert(ShowUI <> UIOptionInternal.NoUI, "Why call ShellDelete if ShowUI is NoUI???")
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
' Set operation type.
Dim OperationType As SHFileOperationType
If Operation = CopyOrMove.Copy Then
Debug.Assert(FullPath <> "" And IO.Path.IsPathRooted(FullPath), "FullPath must be a full path")
Debug.Assert(ShowUI <> UIOptionInternal.NoUI, "Why call ShellDelete if ShowUI is NoUI???")
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
' Set fFlags to control the operation details.
Dim OperationFlags As ShFileOperationFlags = GetOperationFlags(ShowUI)
If (recycle = RecycleOption.SendToRecycleBin) Then
#End If
End Sub
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
''' <summary>
''' Calls NativeMethods.SHFileOperation with the given SHFILEOPSTRUCT, notifies the shell of change,
''' and throw exceptions if needed.
End If
End Sub
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
''' <summary>
''' Given an error code from winerror.h, throw the appropriate exception.
''' </summary>
Throw New InvalidEnumArgumentException(argName, argValue, GetType(UICancelOption))
End Sub
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
' Base operation flags used in shell IO operation.
' - DON'T move connected files as a group.
' - DON'T confirm directory creation - our silent copy / move do not.
"Methods in Microsoft.VisualBasic should not call FileSystem public method.")
If Attributes = FileAttribute.Volume Then
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Dim Result As Integer
Dim VolumeName As StringBuilder = New StringBuilder(256)
Dim RootName As String = Nothing
'IMPORTANT: This call provides sensitive information whether a device exists and should be used with extreme care
Private Function UnsafeValidDrive(ByVal cDrive As Char) As Boolean 'Return of True means not a valid drive
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Dim iDrive As Integer = AscW(cDrive) - AscW(chLetterA)
Return (CLng(UnsafeNativeMethods.GetLogicalDrives()) And CLng(&H2 ^ iDrive)) <> 0
#Else
OldPath = VB6CheckPathname(oAssemblyData, OldPath, CType(OpenModeTypes.Any, OpenMode))
NewPath = VB6CheckPathname(oAssemblyData, NewPath, CType(OpenModeTypes.Any, OpenMode))
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Dim Result As Integer
Dim ErrCode As Integer
'============================================================================
Public Sub Beep()
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
UnsafeNativeMethods.MessageBeep(0)
#Else
Throw New PlatformNotSupportedException()
End Function
Public Function StrConv(ByVal [str] As String, ByVal Conversion As VbStrConv, Optional ByVal LocaleID As Integer = 0) As String
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Try
Const LANG_CHINESE As Integer = &H4I
Const LANG_JAPANESE As Integer = &H11I
#End If
End Function
-#If PLATFORM_WINDOWS Then
+#If TARGET_WINDOWS Then
Friend Function ValidLCID(ByVal LocaleID As Integer) As Boolean
Try
Dim loc As CultureInfo = New CultureInfo(LocaleID)
{
internal static class ExternDll
{
-#if FEATURE_PAL && !SILVERLIGHT
-
-#if !PLATFORM_UNIX
- internal const String DLLPREFIX = "";
- internal const String DLLSUFFIX = ".dll";
-#else // !PLATFORM_UNIX
-#if __APPLE__
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".dylib";
-#elif _AIX
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".a";
-#elif __hppa__ || IA64
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".sl";
-#else
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".so";
-#endif
-#endif // !PLATFORM_UNIX
-
- public const string Kernel32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- public const string User32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- public const string Mscoree = DLLPREFIX + "sscoree" + DLLSUFFIX;
-
-#elif FEATURE_PAL && SILVERLIGHT
-
- public const string Kernel32 = "coreclr";
- public const string User32 = "coreclr";
-
-#else
public const string Activeds = "activeds.dll";
public const string Advapi32 = "advapi32.dll";
public const string Comctl32 = "comctl32.dll";
// system.data.oracleclient specific
internal const string OciDll = "oci.dll";
internal const string OraMtsDll = "oramts.dll";
-#endif //!FEATURE_PAL
}
}
{
internal static class ExternDll
{
-#if FEATURE_PAL && !SILVERLIGHT
-
-#if !PLATFORM_UNIX
- internal const String DLLPREFIX = "";
- internal const String DLLSUFFIX = ".dll";
-#else // !PLATFORM_UNIX
-#if __APPLE__
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".dylib";
-#elif _AIX
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".a";
-#elif __hppa__ || IA64
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".sl";
-#else
- internal const String DLLPREFIX = "lib";
- internal const String DLLSUFFIX = ".so";
-#endif
-#endif // !PLATFORM_UNIX
-
- public const string Kernel32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- public const string User32 = DLLPREFIX + "rotor_pal" + DLLSUFFIX;
- public const string Mscoree = DLLPREFIX + "sscoree" + DLLSUFFIX;
-
-#elif FEATURE_PAL && SILVERLIGHT
-
- public const string Kernel32 = "coreclr";
- public const string User32 = "coreclr";
-
-#else
public const string Activeds = "activeds.dll";
public const string Advapi32 = "advapi32.dll";
public const string Comctl32 = "comctl32.dll";
// system.data.oracleclient specific
internal const string OciDll = "oci.dll";
internal const string OraMtsDll = "oramts.dll";
-#endif //!FEATURE_PAL
}
}
return _guid.GetHashCode();
}
-#if !FEATURE_PAL
// Find any random encoder which supports this format
internal ImageCodecInfo FindEncoder()
{
}
return null;
}
-#endif
/// <summary>
/// Converts this <see cref='System.Drawing.Imaging.ImageFormat'/> to a human-readable string.
internal static class PaddingHelpers
{
/// <summary>A size greater than or equal to the size of the most common CPU cache lines.</summary>
-#if ARM64
+#if TARGET_ARM64
internal const int CACHE_LINE_SIZE = 128;
#else
internal const int CACHE_LINE_SIZE = 64;
using System.Runtime.Versioning;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
using nint = System.Int64;
#else
#endif
}
-#if BIT64
+#if TARGET_64BIT
/// <summary>
/// Adds an element offset to the given reference.
/// </summary>
<ItemGroup Condition="'$(FeatureCominterop)' == 'true'">
<Compile Include="$(MSBuildThisFileDirectory)System\Runtime\InteropServices\WindowsRuntime\EventRegistrationToken.cs" />
</ItemGroup>
- <ItemGroup Condition="'$(TargetsWindows)' == 'true' or '$(FeaturePal)'=='true'">
+ <!-- CoreCLR uses PAL layer that emulates Windows API on Unix. This is bridge for that PAL layer. See issue dotnet/runtime/#31721. -->
+ <ItemGroup Condition="'$(TargetsWindows)' == 'true' or '$(FeatureCoreCLR)'=='true'">
<Compile Include="$(MSBuildThisFileDirectory)Microsoft\Win32\SafeHandles\SafeWaitHandle.Windows.cs" />
<Compile Include="$(CommonPath)Interop\Windows\Interop.Errors.cs" />
<Compile Include="$(CommonPath)Interop\Windows\OleAut32\Interop.SysAllocStringLen.cs">
break;
case CorElementType.ELEMENT_TYPE_I4:
case CorElementType.ELEMENT_TYPE_U4:
-#if !BIT64
+#if TARGET_32BIT
case CorElementType.ELEMENT_TYPE_I:
case CorElementType.ELEMENT_TYPE_U:
#endif
break;
case CorElementType.ELEMENT_TYPE_I8:
case CorElementType.ELEMENT_TYPE_U8:
-#if BIT64
+#if TARGET_64BIT
case CorElementType.ELEMENT_TYPE_I:
case CorElementType.ELEMENT_TYPE_U:
#endif
break;
case CorElementType.ELEMENT_TYPE_I4:
case CorElementType.ELEMENT_TYPE_U4:
-#if !BIT64
+#if TARGET_32BIT
case CorElementType.ELEMENT_TYPE_I:
case CorElementType.ELEMENT_TYPE_U:
#endif
break;
case CorElementType.ELEMENT_TYPE_I8:
case CorElementType.ELEMENT_TYPE_U8:
-#if BIT64
+#if TARGET_64BIT
case CorElementType.ELEMENT_TYPE_I:
case CorElementType.ELEMENT_TYPE_U:
#endif
return;
case CorElementType.ELEMENT_TYPE_I4:
case CorElementType.ELEMENT_TYPE_U4:
-#if !BIT64
+#if TARGET_32BIT
case CorElementType.ELEMENT_TYPE_I:
case CorElementType.ELEMENT_TYPE_U:
#endif
return;
case CorElementType.ELEMENT_TYPE_I8:
case CorElementType.ELEMENT_TYPE_U8:
-#if BIT64
+#if TARGET_64BIT
case CorElementType.ELEMENT_TYPE_I:
case CorElementType.ELEMENT_TYPE_U:
#endif
// See the LICENSE file in the project root for more information.
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
{
public static partial class Buffer
{
-#if ARM64
+#if TARGET_ARM64
// Managed code is currently faster than glibc unoptimized memmove
// TODO-ARM64-UNIX-OPT revisit when glibc optimized memmove is in Linux distros
// https://github.com/dotnet/coreclr/issues/13844
private const nuint MemmoveNativeThreshold = ulong.MaxValue;
-#elif ARM
+#elif TARGET_ARM
private const nuint MemmoveNativeThreshold = 512;
#else
private const nuint MemmoveNativeThreshold = 2048;
// See the LICENSE file in the project root for more information.
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
{
public static partial class Buffer
{
-#if ARM64
+#if TARGET_ARM64
// Determine optimal value for Windows.
// https://github.com/dotnet/coreclr/issues/13843
private const nuint MemmoveNativeThreshold = ulong.MaxValue;
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
-#if AMD64 || ARM64 || (BIT32 && !ARM)
+#if TARGET_AMD64 || TARGET_ARM64 || (TARGET_32BIT && !TARGET_ARM)
#define HAS_CUSTOM_BLOCKS
#endif
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
#else
Debug.Assert(len > 16 && len <= 64);
#if HAS_CUSTOM_BLOCKS
*(Block16*)dest = *(Block16*)src; // [0,16]
-#elif BIT64
+#elif TARGET_64BIT
*(long*)dest = *(long*)src;
*(long*)(dest + 8) = *(long*)(src + 8); // [0,16]
#else
if (len <= 32) goto MCPY01;
#if HAS_CUSTOM_BLOCKS
*(Block16*)(dest + 16) = *(Block16*)(src + 16); // [0,32]
-#elif BIT64
+#elif TARGET_64BIT
*(long*)(dest + 16) = *(long*)(src + 16);
*(long*)(dest + 24) = *(long*)(src + 24); // [0,32]
#else
if (len <= 48) goto MCPY01;
#if HAS_CUSTOM_BLOCKS
*(Block16*)(dest + 32) = *(Block16*)(src + 32); // [0,48]
-#elif BIT64
+#elif TARGET_64BIT
*(long*)(dest + 32) = *(long*)(src + 32);
*(long*)(dest + 40) = *(long*)(src + 40); // [0,48]
#else
Debug.Assert(len > 16 && len <= 64);
#if HAS_CUSTOM_BLOCKS
*(Block16*)(destEnd - 16) = *(Block16*)(srcEnd - 16);
-#elif BIT64
+#elif TARGET_64BIT
*(long*)(destEnd - 16) = *(long*)(srcEnd - 16);
*(long*)(destEnd - 8) = *(long*)(srcEnd - 8);
#else
// Copy the first 8 bytes and then unconditionally copy the last 8 bytes and return.
if ((len & 24) == 0) goto MCPY03;
Debug.Assert(len >= 8 && len <= 16);
-#if BIT64
+#if TARGET_64BIT
*(long*)dest = *(long*)src;
*(long*)(destEnd - 8) = *(long*)(srcEnd - 8);
#else
MCPY06:
#if HAS_CUSTOM_BLOCKS
*(Block64*)dest = *(Block64*)src;
-#elif BIT64
+#elif TARGET_64BIT
*(long*)dest = *(long*)src;
*(long*)(dest + 8) = *(long*)(src + 8);
*(long*)(dest + 16) = *(long*)(src + 16);
if (len > 16) goto MCPY00;
#if HAS_CUSTOM_BLOCKS
*(Block16*)(destEnd - 16) = *(Block16*)(srcEnd - 16);
-#elif BIT64
+#elif TARGET_64BIT
*(long*)(destEnd - 16) = *(long*)(srcEnd - 16);
*(long*)(destEnd - 8) = *(long*)(srcEnd - 8);
#else
Debug.Assert(len > 16 && len <= 64);
#if HAS_CUSTOM_BLOCKS
Unsafe.As<byte, Block16>(ref dest) = Unsafe.As<byte, Block16>(ref src); // [0,16]
-#elif BIT64
+#elif TARGET_64BIT
Unsafe.As<byte, long>(ref dest) = Unsafe.As<byte, long>(ref src);
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 8)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 8)); // [0,16]
#else
goto MCPY01;
#if HAS_CUSTOM_BLOCKS
Unsafe.As<byte, Block16>(ref Unsafe.Add(ref dest, 16)) = Unsafe.As<byte, Block16>(ref Unsafe.Add(ref src, 16)); // [0,32]
-#elif BIT64
+#elif TARGET_64BIT
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 16)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 16));
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 24)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 24)); // [0,32]
#else
goto MCPY01;
#if HAS_CUSTOM_BLOCKS
Unsafe.As<byte, Block16>(ref Unsafe.Add(ref dest, 32)) = Unsafe.As<byte, Block16>(ref Unsafe.Add(ref src, 32)); // [0,48]
-#elif BIT64
+#elif TARGET_64BIT
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 32)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 32));
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 40)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 40)); // [0,48]
#else
Debug.Assert(len > 16 && len <= 64);
#if HAS_CUSTOM_BLOCKS
Unsafe.As<byte, Block16>(ref Unsafe.Add(ref destEnd, -16)) = Unsafe.As<byte, Block16>(ref Unsafe.Add(ref srcEnd, -16));
-#elif BIT64
+#elif TARGET_64BIT
Unsafe.As<byte, long>(ref Unsafe.Add(ref destEnd, -16)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref srcEnd, -16));
Unsafe.As<byte, long>(ref Unsafe.Add(ref destEnd, -8)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref srcEnd, -8));
#else
if ((len & 24) == 0)
goto MCPY03;
Debug.Assert(len >= 8 && len <= 16);
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref dest) = Unsafe.As<byte, long>(ref src);
Unsafe.As<byte, long>(ref Unsafe.Add(ref destEnd, -8)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref srcEnd, -8));
#else
MCPY06:
#if HAS_CUSTOM_BLOCKS
Unsafe.As<byte, Block64>(ref dest) = Unsafe.As<byte, Block64>(ref src);
-#elif BIT64
+#elif TARGET_64BIT
Unsafe.As<byte, long>(ref dest) = Unsafe.As<byte, long>(ref src);
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 8)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 8));
Unsafe.As<byte, long>(ref Unsafe.Add(ref dest, 16)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref src, 16));
goto MCPY00;
#if HAS_CUSTOM_BLOCKS
Unsafe.As<byte, Block16>(ref Unsafe.Add(ref destEnd, -16)) = Unsafe.As<byte, Block16>(ref Unsafe.Add(ref srcEnd, -16));
-#elif BIT64
+#elif TARGET_64BIT
Unsafe.As<byte, long>(ref Unsafe.Add(ref destEnd, -16)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref srcEnd, -16));
Unsafe.As<byte, long>(ref Unsafe.Add(ref destEnd, -8)) = Unsafe.As<byte, long>(ref Unsafe.Add(ref srcEnd, -8));
#else
private int[]? _buckets;
private Entry[]? _entries;
-#if BIT64
+#if TARGET_64BIT
private ulong _fastModMultiplier;
#endif
private int _count;
// Assign member variables after both arrays allocated to guard against corruption from OOM if second fails
_freeList = -1;
-#if BIT64
+#if TARGET_64BIT
_fastModMultiplier = HashHelpers.GetFastModMultiplier((uint)size);
#endif
_buckets = buckets;
// Assign member variables after both arrays allocated to guard against corruption from OOM if second fails
_buckets = new int[newSize];
-#if BIT64
+#if TARGET_64BIT
_fastModMultiplier = HashHelpers.GetFastModMultiplier((uint)newSize);
#endif
for (int i = 0; i < count; i++)
private ref int GetBucket(uint hashCode)
{
int[] buckets = _buckets!;
-#if BIT64
+#if TARGET_64BIT
return ref buckets[HashHelpers.FastMod(hashCode, (uint)buckets.Length, _fastModMultiplier)];
#else
return ref buckets[hashCode % (uint)buckets.Length];
return GetPrime(newSize);
}
-#if BIT64
+#if TARGET_64BIT
// Returns approximate reciprocal of the divisor: ceil(2**64 / divisor)
public static ulong GetFastModMultiplier(uint divisor)
=> ulong.MaxValue / divisor + 1;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static bool Div96ByConst(ref ulong high64, ref uint low, uint pow)
{
-#if BIT64
+#if TARGET_64BIT
ulong div64 = high64 / pow;
uint div = (uint)((((high64 - div64 * pow) << 32) + low) / pow);
if (low == div * pow)
// Since 10 = 2 * 5, there must be a factor of 2 for every power of 10 we can extract.
// We use this as a quick test on whether to try a given power.
-#if BIT64
+#if TARGET_64BIT
while ((byte)low == 0 && scale >= 8 && Div96ByConst(ref high64, ref low, 100000000))
scale -= 8;
case 4:
power = DivByConst(result, hiRes, out quotient, out remainder, 10000);
break;
-#if BIT64
+#if TARGET_64BIT
case 5:
power = DivByConst(result, hiRes, out quotient, out remainder, 100000);
break;
if (quotient == 0 && hiRes != 0)
hiRes--;
-#if BIT64
+#if TARGET_64BIT
newScale -= MaxInt32Scale;
#else
newScale -= 4;
remainder = high - (quotient = high / power) * power;
for (uint i = hiRes - 1; (int)i >= 0; i--)
{
-#if BIT64
+#if TARGET_64BIT
ulong num = result[i] + ((ulong)remainder << 32);
remainder = (uint)num - (result[i] = (uint)(num / power)) * power;
#else
using System.Globalization;
using System.Numerics;
using System.Runtime.InteropServices;
-#if CORECLR && PLATFORM_WINDOWS
+#if CORECLR && TARGET_WINDOWS
using Internal.Win32;
#endif
#if ES_BUILD_AGAINST_DOTNET_V35
{
m_eventProvider = providerType switch
{
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
EventProviderType.ETW => new EtwEventProvider(),
#endif
#if FEATURE_PERFTRACING
status = EventRegister(eventSource, m_etwCallback);
if (status != 0)
{
-#if PLATFORM_WINDOWS && !ES_BUILD_STANDALONE
+#if TARGET_WINDOWS && !ES_BUILD_STANDALONE
throw new ArgumentException(Interop.Kernel32.GetMessage(unchecked((int)status)));
#else
throw new ArgumentException(Convert.ToString(unchecked((int)status)));
// However the framework version of EventSource DOES have ES_SESSION_INFO defined and thus
// does not have this issue.
-#if (PLATFORM_WINDOWS && (ES_SESSION_INFO || !ES_BUILD_STANDALONE))
+#if (TARGET_WINDOWS && (ES_SESSION_INFO || !ES_BUILD_STANDALONE))
int buffSize = 256; // An initial guess that probably works most of the time.
byte* buffer;
while (true)
providerInstance = (Interop.Advapi32.TRACE_PROVIDER_INSTANCE_INFO*)&structBase[providerInstance->NextOffset];
}
#else
-#if !ES_BUILD_PCL && PLATFORM_WINDOWS // TODO command arguments don't work on PCL builds...
+#if !ES_BUILD_PCL && TARGET_WINDOWS // TODO command arguments don't work on PCL builds...
// This code is only used in the Nuget Package Version of EventSource. because
// the code above is using APIs baned from UWP apps.
//
dataStart = 0;
if (filterData == null)
{
-#if (!ES_BUILD_PCL && !ES_BUILD_PN && PLATFORM_WINDOWS)
+#if (!ES_BUILD_PCL && !ES_BUILD_PN && TARGET_WINDOWS)
string regKey = @"\Microsoft\Windows\CurrentVersion\Winevt\Publishers\{" + m_providerId + "}";
if (IntPtr.Size == 8)
regKey = @"Software\Wow6432Node" + regKey;
private void EventUnregister(long registrationHandle) =>
m_eventProvider.EventUnregister(registrationHandle);
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
private static bool m_setInformationMissing;
internal unsafe int SetInformation(
#endif
}
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
// A wrapper around the ETW-specific API calls.
internal sealed class EtwEventProvider : IEventProvider
(uint)Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_SET_ID,
ref activityId);
#endif // FEATURE_PERFTRACING
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
// Set the activity id via ETW.
Interop.Advapi32.EventActivityIdControl(
Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_SET_ID,
ref activityId);
-#endif // PLATFORM_WINDOWS
+#endif // TARGET_WINDOWS
#endif // FEATURE_MANAGED_ETW
}
// errors. Note we can't access m_throwOnWrites because this is a static method.
Guid retVal = default;
#if FEATURE_MANAGED_ETW
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
Interop.Advapi32.EventActivityIdControl(
Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_GET_ID,
ref retVal);
EventPipeInternal.EventActivityIdControl(
(uint)Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_GET_ID,
ref retVal);
-#endif // PLATFORM_WINDOWS
+#endif // TARGET_WINDOWS
#endif // FEATURE_MANAGED_ETW
return retVal;
}
// We ignore errors to keep with the convention that EventSources do not throw errors.
// Note we can't access m_throwOnWrites because this is a static method.
-#if FEATURE_PERFTRACING && PLATFORM_WINDOWS
+#if FEATURE_PERFTRACING && TARGET_WINDOWS
EventPipeInternal.EventActivityIdControl(
(uint)Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_SET_ID,
ref oldActivityThatWillContinue);
EventPipeInternal.EventActivityIdControl(
(uint)Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_GET_SET_ID,
ref oldActivityThatWillContinue);
-#endif // FEATURE_PERFTRACING && PLATFORM_WINDOWS
+#endif // FEATURE_PERFTRACING && TARGET_WINDOWS
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
Interop.Advapi32.EventActivityIdControl(
Interop.Advapi32.ActivityControl.EVENT_ACTIVITY_CTRL_GET_SET_ID,
ref oldActivityThatWillContinue);
-#endif // PLATFORM_WINDOWS
+#endif // TARGET_WINDOWS
#endif // FEATURE_MANAGED_ETW
// We don't call the activityDying callback here because the caller has declared that
// Set m_provider, which allows this.
m_etwProvider = etwProvider;
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
#if (!ES_BUILD_STANDALONE && !ES_BUILD_PN)
// API available on OS >= Win 8 and patched Win 7.
// Disable only for FrameworkEventSource to avoid recursion inside exception handling.
metadataHandle.Free();
}
-#endif // PLATFORM_WINDOWS
+#endif // TARGET_WINDOWS
#endif // FEATURE_MANAGED_ETW
#if FEATURE_PERFTRACING
// This program uses code hyperlinks available as part of the HyperAddin Visual Studio plug-in.
// It is available from http://www.codeplex.com/hyperAddin
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
#define FEATURE_MANAGED_ETW
-#endif // PLATFORM_WINDOWS
+#endif // TARGET_WINDOWS
#if ES_BUILD_STANDALONE
#define FEATURE_MANAGED_ETW_CHANNELS
case CorElementType.ELEMENT_TYPE_CHAR:
return Unsafe.As<byte, ushort>(ref pThisValue).CompareTo(Unsafe.As<byte, ushort>(ref pTargetValue));
case CorElementType.ELEMENT_TYPE_I4:
-#if !BIT64
+#if TARGET_32BIT
case CorElementType.ELEMENT_TYPE_I:
#endif
return Unsafe.As<byte, int>(ref pThisValue).CompareTo(Unsafe.As<byte, int>(ref pTargetValue));
case CorElementType.ELEMENT_TYPE_U4:
-#if !BIT64
+#if TARGET_32BIT
case CorElementType.ELEMENT_TYPE_U:
#endif
return Unsafe.As<byte, uint>(ref pThisValue).CompareTo(Unsafe.As<byte, uint>(ref pTargetValue));
case CorElementType.ELEMENT_TYPE_I8:
-#if BIT64
+#if TARGET_64BIT
case CorElementType.ELEMENT_TYPE_I:
#endif
return Unsafe.As<byte, long>(ref pThisValue).CompareTo(Unsafe.As<byte, long>(ref pTargetValue));
case CorElementType.ELEMENT_TYPE_U8:
-#if BIT64
+#if TARGET_64BIT
case CorElementType.ELEMENT_TYPE_U:
#endif
return Unsafe.As<byte, ulong>(ref pThisValue).CompareTo(Unsafe.As<byte, ulong>(ref pTargetValue));
{
case SpecialFolder.CommonApplicationData: return "/usr/share";
case SpecialFolder.CommonTemplates: return "/usr/share/templates";
-#if PLATFORM_OSX
+#if TARGET_OSX
case SpecialFolder.ProgramFiles: return "/Applications";
case SpecialFolder.System: return "/System";
#endif
case SpecialFolder.MyVideos:
return ReadXdgDirectory(home, "XDG_VIDEOS_DIR", "Videos");
-#if PLATFORM_OSX
+#if TARGET_OSX
case SpecialFolder.MyMusic:
return Path.Combine(home, "Music");
case SpecialFolder.MyPictures:
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
{
IntPtr byteOffset = IntPtr.Zero;
-#if BIT64
+#if TARGET_64BIT
// Read 4 chars (64 bits) at a time from each string
while ((uint)length >= 4)
{
#endif
// Read 2 chars (32 bits) at a time from each string
-#if BIT64
+#if TARGET_64BIT
if ((uint)length >= 2)
#else
while ((uint)length >= 2)
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System.Globalization
{
{
get
{
- #if PLATFORM_OSX
+ #if TARGET_OSX
return false;
#else
return true;
using System.Threading.Tasks;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
using System.Runtime.Versioning;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
#else
using nint = System.Int32;
[NonVersionable]
public unsafe IntPtr(long value)
{
-#if BIT64
+#if TARGET_64BIT
_value = (void*)value;
#else
_value = (void*)checked((int)value);
public override unsafe int GetHashCode()
{
-#if BIT64
+#if TARGET_64BIT
long l = (long)_value;
return unchecked((int)l) ^ (int)(l >> 32);
#else
[NonVersionable]
public unsafe int ToInt32()
{
-#if BIT64
+#if TARGET_64BIT
long l = (long)_value;
return checked((int)l);
#else
[NonVersionable]
public static unsafe explicit operator int(IntPtr value)
{
-#if BIT64
+#if TARGET_64BIT
long l = (long)value._value;
return checked((int)l);
#else
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System
{
}
if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Memory<T> Slice(int start, int length)
{
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)_length)
ThrowHelper.ThrowArgumentOutOfRangeException();
nuint desiredStartIndex = (uint)_index & (uint)ReadOnlyMemory<T>.RemoveFlagsBitMask;
int desiredLength = _length;
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)desiredStartIndex + (ulong)(uint)desiredLength > (ulong)(uint)lengthOfUnderlyingSpan)
{
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System
{
return default;
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)text.Length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
return default;
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)text.Length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
return (int)Popcnt.X64.PopCount(value);
}
-#if BIT32
+#if TARGET_32BIT
return PopCount((uint)value) // lo
+ PopCount((uint)(value >> 32)); // hi
#else
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
#else
using nint = System.Int32;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
#else
using nint = System.Int32;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System
{
this = default;
return; // returns default
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlyMemory<T> Slice(int start, int length)
{
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)_length)
ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument.start);
nuint desiredStartIndex = (uint)_index & (uint)RemoveFlagsBitMask;
int desiredLength = _length;
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)desiredStartIndex + (ulong)(uint)desiredLength > (ulong)(uint)lengthOfUnderlyingSpan)
{
#pragma warning disable 0809 //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
this = default;
return; // returns default
}
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ReadOnlySpan<T> Slice(int start, int length)
{
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)_length)
ThrowHelper.ThrowArgumentOutOfRangeException();
using System.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
#else
using nint = System.Int32;
using System.Diagnostics.CodeAnalysis;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
public static IntPtr ReadIntPtr(object ptr, int ofs)
{
-#if BIT64
+#if TARGET_64BIT
return (IntPtr)ReadInt64(ptr, ofs);
#else // 32
return (IntPtr)ReadInt32(ptr, ofs);
public static IntPtr ReadIntPtr(IntPtr ptr, int ofs)
{
-#if BIT64
+#if TARGET_64BIT
return (IntPtr)ReadInt64(ptr, ofs);
#else // 32
return (IntPtr)ReadInt32(ptr, ofs);
public static void WriteIntPtr(IntPtr ptr, int ofs, IntPtr val)
{
-#if BIT64
+#if TARGET_64BIT
WriteInt64(ptr, ofs, (long)val);
#else // 32
WriteInt32(ptr, ofs, (int)val);
public static void WriteIntPtr(object ptr, int ofs, IntPtr val)
{
-#if BIT64
+#if TARGET_64BIT
WriteInt64(ptr, ofs, (long)val);
#else // 32
WriteInt32(ptr, ofs, (int)val);
internal partial struct LibraryNameVariation
{
private const string LibraryNamePrefix = "lib";
-#if PLATFORM_OSX
+#if TARGET_OSX
private const string LibraryNameSuffix = ".dylib";
#else
private const string LibraryNameSuffix = ".so";
#pragma warning disable 0809 //warning CS0809: Obsolete member 'Span<T>.Equals(object)' overrides non-obsolete member 'object.Equals(object)'
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
}
if (default(T) == null && array.GetType() != typeof(T[]))
ThrowHelper.ThrowArrayTypeMismatchException();
-#if BIT64
+#if TARGET_64BIT
// See comment in Span<T>.Slice for how this works.
if ((ulong)(uint)start + (ulong)(uint)length > (ulong)(uint)array.Length)
ThrowHelper.ThrowArgumentOutOfRangeException();
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<T> Slice(int start, int length)
{
-#if BIT64
+#if TARGET_64BIT
// Since start and length are both 32-bit, their sum can be computed across a 64-bit domain
// without loss of fidelity. The cast to uint before the cast to ulong ensures that the
// extension from 32- to 64-bit is zero-extending rather than sign-extending. The end result
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System
{
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
using nint = System.Int64;
#else
}
}
-#if BIT64
+#if TARGET_64BIT
if ((byte*)minLength >= (byte*)(i + sizeof(int) / sizeof(char)))
{
if (Unsafe.ReadUnaligned<int>(ref Unsafe.As<char, byte>(ref Unsafe.Add(ref first, i))) ==
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
if (byteLength == 0)
return;
-#if AMD64 || ARM64
+#if TARGET_AMD64 || TARGET_ARM64
// The exact matrix on when ZeroMemory is faster than InitBlockUnaligned is very complex. The factors to consider include
// type of hardware and memory aligment. This threshold was chosen as a good balance accross different configurations.
if (byteLength > 768)
Unsafe.Add<byte>(ref b, 6) = 0;
return;
case 8:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
#endif
return;
case 9:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.Add<byte>(ref b, 8) = 0;
return;
case 10:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.As<byte, short>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
return;
case 11:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.Add<byte>(ref b, 10) = 0;
return;
case 12:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.As<byte, int>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
return;
case 13:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.Add<byte>(ref b, 12) = 0;
return;
case 14:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.As<byte, short>(ref Unsafe.Add<byte>(ref b, 12)) = 0;
return;
case 15:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
#else
Unsafe.As<byte, int>(ref b) = 0;
Unsafe.Add<byte>(ref b, 14) = 0;
return;
case 16:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
#endif
return;
case 17:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
Unsafe.Add<byte>(ref b, 16) = 0;
return;
case 18:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
Unsafe.As<byte, short>(ref Unsafe.Add<byte>(ref b, 16)) = 0;
return;
case 19:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
Unsafe.Add<byte>(ref b, 18) = 0;
return;
case 20:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
Unsafe.As<byte, int>(ref Unsafe.Add<byte>(ref b, 16)) = 0;
return;
case 21:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
Unsafe.Add<byte>(ref b, 20) = 0;
return;
case 22:
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref b) = 0;
Unsafe.As<byte, long>(ref Unsafe.Add<byte>(ref b, 8)) = 0;
#else
// So the only cost is a bit of code size, which is made up for by the fact that
// we save on writes to b.
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref Unsafe.AddByteOffset<byte>(ref b, i)) = 0;
Unsafe.As<byte, long>(ref Unsafe.AddByteOffset<byte>(ref b, i + 8)) = 0;
#else
if ((byteLength & 8) != 0)
{
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<byte, long>(ref Unsafe.AddByteOffset<byte>(ref b, i)) = 0;
#else
Unsafe.As<byte, int>(ref Unsafe.AddByteOffset<byte>(ref b, i)) = 0;
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
length -= 2; a += 2; b += 2;
// unroll the loop
-#if BIT64
+#if TARGET_64BIT
while (length >= 12)
{
if (*(long*)a != *(long*)b) goto DiffOffset0;
if (*(long*)(a + 8) != *(long*)(b + 8)) goto DiffOffset8;
length -= 12; a += 12; b += 12;
}
-#else // BIT64
+#else // TARGET_64BIT
while (length >= 10)
{
if (*(int*)a != *(int*)b) goto DiffOffset0;
if (*(int*)(a + 8) != *(int*)(b + 8)) goto DiffOffset8;
length -= 10; a += 10; b += 10;
}
-#endif // BIT64
+#endif // TARGET_64BIT
// Fallback loop:
// go back to slower code path and do comparison on 4 bytes at a time.
// The longer string will be larger.
return strA.Length - strB.Length;
-#if BIT64
+#if TARGET_64BIT
DiffOffset8: a += 4; b += 4;
DiffOffset4: a += 4; b += 4;
-#else // BIT64
+#else // TARGET_64BIT
// Use jumps instead of falling through, since
// otherwise going to DiffOffset8 will involve
// 8 add instructions before getting to DiffNextInt
DiffOffset6: a += 6; b += 6; goto DiffOffset0;
DiffOffset4: a += 2; b += 2;
DiffOffset2: a += 2; b += 2;
-#endif // BIT64
+#endif // TARGET_64BIT
DiffOffset0:
// If we reached here, we already see a difference in the unrolled loop above
-#if BIT64
+#if TARGET_64BIT
if (*(int*)a == *(int*)b)
{
a += 2; b += 2;
}
-#endif // BIT64
+#endif // TARGET_64BIT
DiffNextInt:
if (*a != *b) return *a - *b;
if (numBytes == 0)
return Empty;
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
int numCharsRequired = Interop.Kernel32.MultiByteToWideChar(Interop.Kernel32.CP_ACP, Interop.Kernel32.MB_PRECOMPOSED, pb, numBytes, (char*)null, 0);
if (numCharsRequired == 0)
throw new ArgumentException(SR.Arg_InvalidANSIString);
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nint = System.Int32;
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System.Text
{
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nint = System.Int32;
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System.Text.Unicode
{
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nint = System.Int32;
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System.Text.Unicode
{
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
-#else // BIT64
+#else // TARGET_64BIT
using nint = System.Int32;
using nuint = System.UInt32;
-#endif // BIT64
+#endif // TARGET_64BIT
namespace System.Text.Unicode
{
using Internal.Runtime.CompilerServices;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nint = System.Int64;
using nuint = System.UInt64;
#else
#if FASTLOOP
// If endianess is backwards then each pair of bytes would be backwards.
if ((bigEndian ^ BitConverter.IsLittleEndian) &&
-#if BIT64
+#if TARGET_64BIT
(unchecked((long)chars) & 7) == 0 &&
#else
(unchecked((int)chars) & 3) == 0 &&
#if FASTLOOP
// If endianess is backwards then each pair of bytes would be backwards.
if ((bigEndian ^ BitConverter.IsLittleEndian) &&
-#if BIT64
+#if TARGET_64BIT
(unchecked((long)chars) & 7) == 0 &&
#else
(unchecked((int)chars) & 3) == 0 &&
// That'll hurt if we're unaligned because we'll always test but never be aligned
#if FASTLOOP
if ((bigEndian ^ BitConverter.IsLittleEndian) &&
-#if BIT64
+#if TARGET_64BIT
(unchecked((long)bytes) & 7) == 0 &&
#else
(unchecked((int)bytes) & 3) == 0 &&
-#endif // BIT64
+#endif // TARGET_64BIT
lastByte == -1 && lastChar == 0)
{
// Need -1 to check 2 at a time. If we have an even #, longBytes will go
// That'll hurt if we're unaligned because we'll always test but never be aligned
#if FASTLOOP
if ((bigEndian ^ BitConverter.IsLittleEndian) &&
-#if BIT64
+#if TARGET_64BIT
(unchecked((long)chars) & 7) == 0 &&
#else
(unchecked((int)chars) & 3) == 0 &&
private void CreateEventCore(bool initialState, EventResetMode mode, string? name, out bool createdNew)
{
-#if !PLATFORM_WINDOWS
+#if TARGET_UNIX
if (name != null)
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#endif
private static OpenExistingResult OpenExistingWorker(string name, out EventWaitHandle? result)
{
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
if (mutexHandle.IsInvalid)
{
mutexHandle.SetHandleAsInvalid();
-#if !PLATFORM_WINDOWS
+#if TARGET_UNIX
if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE)
// On Unix, length validation is done by CoreCLR's PAL after converting to utf-8
throw new ArgumentException(SR.Argument_WaitHandleNameTooLong, nameof(name));
if (myHandle.IsInvalid)
{
int errorCode = Marshal.GetLastWin32Error();
-#if !PLATFORM_WINDOWS
+#if TARGET_UNIX
if (errorCode == Interop.Errors.ERROR_FILENAME_EXCED_RANGE)
{
// On Unix, length validation is done by CoreCLR's PAL after converting to utf-8
private const int ThreadPoolThreadTimeoutMs = 20 * 1000; // If you change this make sure to change the timeout times in the tests.
-#if BIT64
+#if TARGET_64BIT
private const short MaxPossibleThreadCount = short.MaxValue;
-#elif BIT32
+#elif TARGET_32BIT
private const short MaxPossibleThreadCount = 1023;
#else
#error Unknown platform
[StructLayout(LayoutKind.Explicit, Size = CacheLineSize * 5)]
private struct CacheLineSeparated
{
-#if ARM64
+#if TARGET_ARM64
private const int CacheLineSize = 128;
#else
private const int CacheLineSize = 64;
Debug.Assert(maximumCount >= 1);
Debug.Assert(initialCount <= maximumCount);
-#if !PLATFORM_WINDOWS
+#if TARGET_UNIX
if (name != null)
throw new PlatformNotSupportedException(SR.PlatformNotSupported_NamedSynchronizationPrimitives);
#endif
private static OpenExistingResult OpenExistingWorker(string name, out Semaphore? result)
{
-#if PLATFORM_WINDOWS
+#if TARGET_WINDOWS
if (name == null)
throw new ArgumentNullException(nameof(name));
if (name.Length == 0)
[Intrinsic]
[NonVersionable]
public static long Read(ref long location) =>
-#if BIT64
+#if TARGET_64BIT
(long)Unsafe.As<long, VolatileIntPtr>(ref location).Value;
#else
// On 32-bit machines, we use Interlocked, since an ordinary volatile read would not be atomic.
[Intrinsic]
[NonVersionable]
public static void Write(ref long location, long value) =>
-#if BIT64
+#if TARGET_64BIT
Unsafe.As<long, VolatileIntPtr>(ref location).Value = (IntPtr)value;
#else
// On 32-bit, we use Interlocked, since an ordinary volatile write would not be atomic.
using System.Runtime.Versioning;
#pragma warning disable SA1121 // explicitly using type aliases instead of built-in types
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
[NonVersionable]
public unsafe UIntPtr(ulong value)
{
-#if BIT64
+#if TARGET_64BIT
_value = (void*)value;
#else
_value = (void*)checked((uint)value);
public override unsafe int GetHashCode()
{
-#if BIT64
+#if TARGET_64BIT
ulong l = (ulong)_value;
return unchecked((int)l) ^ (int)(l >> 32);
#else
[NonVersionable]
public unsafe uint ToUInt32()
{
-#if BIT64
+#if TARGET_64BIT
return checked((uint)_value);
#else
return (uint)_value;
[NonVersionable]
public static unsafe explicit operator uint(UIntPtr value) =>
-#if BIT64
+#if TARGET_64BIT
checked((uint)value._value);
#else
(uint)value._value;
}
- [Conditional("NOT_SILVERLIGHT")]
internal void EmitSourceInstruction(string line)
{
}
- [Conditional("NOT_SILVERLIGHT")]
internal void EmitSourceLabel(string line)
{
}
- [Conditional("NOT_SILVERLIGHT")]
internal void EmitSourceComment(string comment)
{
}
internal enum ScriptingLanguage
{
JScript,
-#if !FEATURE_PAL // visualbasic
VisualBasic,
-#endif // !FEATURE_PAL
CSharp
}
{
lang = ScriptingLanguage.CSharp;
}
-#if !FEATURE_PAL // visualbasic
else if (
string.Equals(langName, "vb", StringComparison.OrdinalIgnoreCase) ||
string.Equals(langName, "visualbasic", StringComparison.OrdinalIgnoreCase)
{
lang = ScriptingLanguage.VisualBasic;
}
-#endif // !FEATURE_PAL
else
{
throw XsltException.Create(SR.Xslt_ScriptInvalidLanguage, langName);
<PropertyGroup Condition="'$(Platform)' == 'x64'">
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>false</Prefer32Bit>
- <DefineConstants>BIT64;AMD64;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_64BIT;TARGET_AMD64;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'x86'">
<PlatformTarget>x86</PlatformTarget>
- <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm'">
<PlatformTarget>arm</PlatformTarget>
- <DefineConstants>BIT32;ARM;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;TARGET_ARM;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'arm64'">
<PlatformTarget>AnyCPU</PlatformTarget>
- <DefineConstants>BIT64;ARM64;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_64BIT;TARGET_ARM64;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(Platform)' == 'wasm32'">
<PlatformTarget>AnyCPU</PlatformTarget>
- <DefineConstants>BIT32;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_32BIT;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<!-- Configuration specific properties -->
<Optimize Condition="'$(Optimize)' == ''">true</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetsOSX)' == 'true'">
- <DefineConstants>PLATFORM_OSX;$(DefineConstants)</DefineConstants>
+ <DefineConstants>TARGET_OSX;$(DefineConstants)</DefineConstants>
</PropertyGroup>
<!-- Assembly attributes -->
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using Mono;
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;
using System.Runtime.CompilerServices;
-#if BIT64
+#if TARGET_64BIT
using nuint = System.UInt64;
#else
using nuint = System.UInt32;