Generate efficient code for rotation patterns.
add_definitions(-DFEATURE_EVENT_TRACE=1)
endif (WIN32 OR CLR_CMAKE_PLATFORM_LINUX)
+if (CLR_CMAKE_PLATFORM_LINUX)
+ add_definitions(-DFEATURE_EVENTSOURCE_XPLAT=1)
+endif (CLR_CMAKE_PLATFORM_LINUX)
+
if(CLR_CMAKE_PLATFORM_UNIX)
add_subdirectory(src/ToolBox/SOS/lldbplugin)
add_subdirectory(src/pal)
-Cross Compilation
-=================
+Cross Compilation for ARM
+=========================
Through cross compilation, on Linux it is possible to build CoreCLR for ARM or ARM64.
ben@ubuntu ~/git/coreclr/ $ ROOTFS_DIR=/home/ben/coreclr-cross/arm ./build.sh arm debug verbose clean cross
-As usual the resulting binaries will be found in `bin/Product/BuildOS.BuildArch.BuildType/`
\ No newline at end of file
+As usual the resulting binaries will be found in `bin/Product/BuildOS.BuildArch.BuildType/`
+
+Cross Compilation for Linux, FreeBSD, or OS X
+=============================================
+
+It is also possible to use a Windows machine to build the managed components of CoreCLR or CoreFX for Linux or OS X. This can be useful when the build on the target platform fails, for example due to Mono issues.
+
+Build mscorlib on Windows
+-------------------------
+The following instructions assume you are on a Windows machine with a clone of the CoreCLR repo that has a correctly configured [environment](https://github.com/dotnet/coreclr/wiki/Windows-instructions#environment).
+
+To build mscorlib for Linux, run the following command:
+
+```
+D:\git\coreclr> build.cmd linuxmscorlib
+```
+
+The arguments `freebsdmscorlib` and `osxmscorlib` can be used instead to build mscorlib for FreeBSD or OS X.
+
+The output is at bin\Product\<BuildOS>.x64.Debug\mscorlib.dll.
+
+The CoreCLR native components need to be built on the target platform. This can be done with the following command:
+
+```
+ellismg@linux:~/git/coreclr$ ./build.sh skipmscorlib
+```
+
+Build the Framework Managed Components on Windows
+-------------------------------------------------
+The following instructions assume you are on a Windows machine with a clone of the CoreFX repo.
+
+To build the CoreFX managed components for Linux, run the following command:
+
+```
+D:\git\corefx> build.cmd /p:OSGroup=Linux /p:SkipTests=true
+```
+
+`FreeBSD` and `OSX` can be used instead for the `OSGroup`.
+
+The output is at bin\<BuildOS>.AnyCPU.Debug.
+
+The CoreFX native components need to be built on the target platform. This can be done with the following command:
+
+```
+ellismg@linux:~/git/corefx$ ./build.sh native
+```
======================================
```sh
-janhenke@freebsd-frankfurt:~/git/corefx$ src/Native/build.sh
+janhenke@freebsd-frankfurt:~/git/corefx$ ./build.sh native
janhenke@freebsd-frankfurt:~/git/corefx$ cp bin/FreeBSD.x64.Debug/Native/*.so ~/coreclr-demo/runtime
```
ellismg@linux:~/git/coreclr$ cp bin/Product/Linux.x64.Debug/corerun ~/coreclr-demo/runtime
ellismg@linux:~/git/coreclr$ cp bin/Product/Linux.x64.Debug/libcoreclr.so ~/coreclr-demo/runtime
ellismg@linux:~/git/coreclr$ cp bin/Product/Linux.x64.Debug/mscorlib.dll ~/coreclr-demo/runtime
+ellismg@linux:~/git/coreclr$ cp bin/Product/Linux.x64.Debug/System.Globalization.Native.so ~/coreclr-demo/runtime
```
-(Alternative) Build the Microsoft Core Library on Windows
-=========================================================
-
-If the build fails (for example due to Mono issues), alternatively you can build it on Windows.
-You'll need a Windows machine with clone of the CoreCLR project.
-
-You will build mscorlib.dll out of the coreclr repository.
-From a regular command prompt window run:
+Build the Framework
+===================
```
-D:\git\coreclr> build.cmd linuxmscorlib
+ellismg@linux:~/git/corefx$ ./build.sh
```
-The output is placed in bin\Product\Linux.x64.Debug\mscorlib.dll. You'll want to copy this to the runtime folder on your Linux machine. (e.g. ~/coreclr-demo/runtime)
-
-Build the Framework Native Components
-======================================
+For the purposes of Hello World, you need to copy a few required files to the demo folder.
```
-ellismg@linux:~/git/corefx$ src/Native/build.sh
ellismg@linux:~/git/corefx$ cp bin/Linux.x64.Debug/Native/*.so ~/coreclr-demo/runtime
+ellismg@linux:~/git/corefx$ cp bin/Linux.AnyCPU.Debug/System.Console/System.Console.dll ~/coreclr-demo/runtime
+ellismg@linux:~/git/corefx$ cp bin/Linux.AnyCPU.Debug/System.Diagnostics.Debug/System.Diagnostics.Debug.dll ~/coreclr-demo/runtime
```
-Build the Framework Managed Components
-======================================
-
-We don't _yet_ have support for building managed code on Linux, so you'll need a Windows machine with clones of CoreFX project.
-
-You will build the rest of the framework that out of the corefx repository.
-You need to pass some special parameters to build.cmd when building out of the CoreFX repository.
-
-```
-D:\git\corefx> build.cmd /p:OSGroup=Linux /p:SkipTests=true
-```
-
-It's also possible to add `/t:rebuild` to the build.cmd to force it to delete the previously built assemblies.
-
-For the purposes of Hello World, you need to copy over both `bin\Linux.AnyCPU.Debug\System.Console\System.Console.dll` and `bin\Linux.AnyCPU.Debug\System.Diagnostics.Debug\System.Diagnostics.Debug.dll` into the runtime folder on Linux. (e.g `~/coreclr-demo/runtime`).
-
-After you've done these steps, the runtime directory on Linux should look like this:
+The runtime directory should now look like the following:
```
matell@linux:~$ ls ~/coreclr-demo/runtime/
-corerun libcoreclr.so mscorlib.dll System.Console.dll System.Diagnostics.Debug.dll System.Native.so
+corerun System.Globalization.Native.so
+libcoreclr.so System.Native.so
+mscorlib.dll System.Net.Http.Native.so
+System.Console.dll System.Security.Cryptography.Native.so
+System.Diagnostics.Debug.dll
```
Download Dependencies
dotnet-mbp:coreclr-demo richlander$ curl -L -O https://nuget.org/nuget.exe
-Build CoreCLR
-=============
+Build the Runtime and Microsoft Core Library
+============================================
To Build CoreCLR, run build.sh from the root of the coreclr repo.
- `corerun`: The command line host. This program loads and starts the CoreCLR runtime and passes the managed program you want to run to it.
- `libcoreclr.dylib`: The CoreCLR runtime itself.
+- `mscorlib.dll`: Microsoft Core Library (requires Mono).
Copy the runtime and corerun into the demo directory.
dotnet-mbp:coreclr richlander$ cp bin/Product/OSX.x64.Debug/corerun ~/coreclr-demo/runtime/
dotnet-mbp:coreclr richlander$ cp bin/Product/OSX.x64.Debug/libcoreclr.dylib ~/coreclr-demo/runtime/
+ dotnet-mbp:coreclr richlander$ cp bin/Product/OSX.x64.Debug/mscorlib.dll ~/coreclr-demo/runtime/
+ dotnet-mbp:coreclr richlander$ cp bin/Product/OSX.x64.Debug/System.Globalization.Native.dylib ~/coreclr-demo/runtime/
-Build the Framework Native Components
-=====================================
-
- dotnet-mbp:corefx richlander$ src/Native/build.sh
- dotnet-mbp:corefx richlander$ cp bin/OSX.x64.Debug/Native/*.dylib ~/coreclr-demo/runtime
-
-Build the Framework Managed Components
-======================================
-
-While CoreFX can be built on OS X, building mscorlib still requires Windows.
-
-Build mscorlb
--------------
-
-The following instructions assume you are on a Windows machine with a clone of the CoreCLR repo and that has a correctly configured [environment](https://github.com/dotnet/coreclr/wiki/Windows-instructions#environment).
-
-You will need to copy binaries built on Windows to your Mac. Use whatever copying method works for you, such as a thumbdrive, a sync program or a cloud drive. To make this easy, copy files to a demo directory on Windows, so that you can copy all of the files to your Mac together.
-
- C:\git\coreclr>mkdir \coreclr-demo
-
-Build mscorlib.dll out of the coreclr repository:
-
- C:\git\coreclr>build.cmd osxmscorlib
-
-The output is placed in `bin\obj\OSX.x64.Debug`. Copy to the demo folder.
-
- C:\git\coreclr>copy bin\obj\OSX.x64.Debug\mscorlib.dll \coreclr-demo
-
-Copy mscorlib
--------------
-
-Copy the newly built mscorlib.dll from `C:\coreclr-demo` to your Mac, in the `~/coreclr-demo/runtime/` directory.
-
-Build CoreFX
-------------
-
-Build the rest of the Framework out of the corefx directory on your Mac.
+Build the Framework
+===================
dotnet-mbp:corefx richlander$ ./build.sh
+For the purposes of this demo, you need to copy a few required files to the demo folder.
-For the purposes of this demo, you need to copy a few required assemblies to the demo folder.
-
+ dotnet-mbp:corefx richlander$ cp bin/OSX.x64.Debug/Native/*.dylib ~/coreclr-demo/runtime
dotnet-mbp:corefx richlander$ cp bin/OSX.AnyCPU.Debug/System.Console/System.Console.dll ~/coreclr-demo/runtime
dotnet-mbp:corefx richlander$ cp bin/OSX.AnyCPU.Debug/System.Diagnostics.Debug/System.Diagnostics.Debug.dll ~/coreclr-demo/runtime
The runtime directory should now look like the following:
dotnet-mbp:~ richlander$ ls ~/coreclr-demo/runtime/
- System.Console.dll libcoreclr.dylib
- System.Diagnostics.Debug.dll mscorlib.dll
- corerun
+ System.Console.dll System.Security.Cryptography.Native.dylib
+ System.Diagnostics.Debug.dll corerun
+ System.Globalization.Native.dylib libcoreclr.dylib
+ System.Native.dylib mscorlib.dll
+ System.Net.Http.Native.dylib
Download NuGet Packages
=======================
> ```bash
> ~/coreclr$ tests/runtest.sh
-> --testRootDir="~/test/Windows_NT.x64.Debug"
-> --testNativeBinDir="~/coreclr/bin/obj/Linux.x64.Debug/tests"
-> --coreClrBinDir="~/coreclr/bin/Product/Linux.x64.Debug"
-> --mscorlibDir="/media/coreclr/bin/Product/Linux.x64.Debug"
-> --coreFxBinDir="~/corefx/bin/Linux.AnyCPU.Debug"
-> --coreFxNativeBinDir="~/corefx/bin/Linux.x64.Debug"
+> --testRootDir=~/test/Windows_NT.x64.Debug
+> --testNativeBinDir=~/coreclr/bin/obj/Linux.x64.Debug/tests
+> --coreClrBinDir=~/coreclr/bin/Product/Linux.x64.Debug
+> --mscorlibDir=/media/coreclr/bin/Product/Linux.x64.Debug
+> --coreFxBinDir=~/corefx/bin/Linux.AnyCPU.Debug
+> --coreFxNativeBinDir=~/corefx/bin/Linux.x64.Debug
> ```
Test results will go into:
--- /dev/null
+.NET Core uses third-party libraries or other resources that may be
+distributed under licenses different than the .NET Core software.
+
+In the event that we accidentally failed to list a required notice, please
+bring it to our attention. Post an issue or email us:
+
+ dotnet@microsoft.com
+
+The attached notices are provided for information only.
+
+License notice for RFC 3492
+---------------------------
+
+Copyright (C) The Internet Society (2003). All Rights Reserved.
+
+This document and translations of it may be copied and furnished to
+others, and derivative works that comment on or otherwise explain it
+or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any
+kind, provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to the Internet Society or other
+Internet organizations, except as needed for the purpose of
+developing Internet standards in which case the procedures for
+copyrights defined in the Internet Standards process must be
+followed, or as required to translate it into languages other than
+English.
+
+The limited permissions granted above are perpetual and will not be
+revoked by the Internet Society or its successors or assigns.
+
+This document and the information contained herein is provided on an
+"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
+TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
<FeatureSvrGc Condition="'$(TargetArch)' != 'arm'">true</FeatureSvrGc>
</PropertyGroup>
+ <PropertyGroup Condition="'$(TargetsLinux)' == 'true'">
+ <FeatureXplatEventSource>true</FeatureXplatEventSource>
+ </PropertyGroup>
+
<PropertyGroup Condition="'$(TargetsUnix)' == 'true'">
<FeaturePal>true</FeaturePal>
<CDefines Condition="'$(FeatureDbgipcTransportVM)' == 'true'">$(CDefines);FEATURE_DBGIPC_TRANSPORT_VM</CDefines>
<CDefines Condition="'$(FeatureDbgPublish)' == 'true'">$(CDefines);FEATURE_DBG_PUBLISH</CDefines>
<CDefines Condition="'$(FeatureEventTrace)' == 'true'">$(CDefines);FEATURE_EVENT_TRACE</CDefines>
+ <CDefines Condition="'$(FeatureXplatEventSource)' == 'true'">$(CDefines);FEATURE_EVENTSOURCE_XPLAT</CDefines>
<CDefines Condition="'$(FeatureExceptionDispatchInfo)' == 'true'">$(CDefines);FEATURE_EXCEPTIONDISPATCHINFO</CDefines>
<CDefines Condition="'$(FeatureExceptionNotifications)' == 'true'">$(CDefines);FEATURE_EXCEPTION_NOTIFICATIONS</CDefines>
<CDefines Condition="'$(FeatureFrameworkInternal)' == 'true'">$(CDefines);FEATURE_FRAMEWORK_INTERNAL</CDefines>
<DefineConstants Condition="'$(FeatureNongenericCollections)' == 'true'">$(DefineConstants);FEATURE_NONGENERIC_COLLECTIONS</DefineConstants>
<DefineConstants Condition="'$(FeatureNormIdnaOnly)' == 'true'">$(DefineConstants);FEATURE_NORM_IDNA_ONLY</DefineConstants>
<DefineConstants Condition="'$(FeaturePal)' == 'true'">$(DefineConstants);FEATURE_PAL</DefineConstants>
+ <DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
<DefineConstants Condition="'$(FeaturePerfmon)' == 'true'">$(DefineConstants);FEATURE_PERFMON</DefineConstants>
<DefineConstants Condition="'$(FeaturePls)' == 'true'">$(DefineConstants);FEATURE_PLS</DefineConstants>
<DefineConstants Condition="'$(FeatureRandomizedStringHashing)' == 'true'">$(DefineConstants);FEATURE_RANDOMIZED_STRING_HASHING</DefineConstants>
// Innerloop build OS's
def osList = ['Ubuntu', 'OSX', 'Windows_NT', 'FreeBSD', 'CentOS7.1', 'OpenSUSE13.2']
-def static getBuildJobName(def configuration, def os) {
- // Massage names a bit
- return configuration.toLowerCase() + '_' + os.toLowerCase()
+def static getBuildJobName(def configuration, def architecture, def os) {
+ // If the architecture is x64, do not add that info into the build name.
+ // Need to change around some systems and other builds to pick up the right builds
+ // to do that.
+
+ if (architecture == 'x64') {
+ return configuration.toLowerCase() + '_' + os.toLowerCase()
+ }
+ else {
+ // Massage names a bit
+ return architecture.toLowerCase() + '_' + configuration.toLowerCase() + '_' + os.toLowerCase()
+ }
}
// **************************
// **************************
// Loop over the options and build up the innerloop build matrix
+// Default architecture is x64. Right now that isn't built into the
+// build name. We'll need to change that eventually, but for now leave as is.
+// x86 builds have the new build name
-['Debug', 'Release'].each { configuration ->
- osList.each { os ->
- // Calculate names
- def lowerConfiguration = configuration.toLowerCase()
-
- // Calculate job name
- def jobName = getBuildJobName(configuration, os)
- def buildCommand = '';
-
- def osGroup = osGroupMap[os]
-
- // Calculate the build command
- if (os == 'Windows_NT') {
- // On Windows we build the mscorlibs too.
- buildCommand = "build.cmd ${lowerConfiguration} && tests\\runtest.cmd ${lowerConfiguration} && build.cmd ${lowerConfiguration} linuxmscorlib && build.cmd ${lowerConfiguration} freebsdmscorlib && build.cmd ${lowerConfiguration} osxmscorlib"
- }
- else {
- // On other OS's we skipmscorlib but run the pal tests
- buildCommand = "./build.sh skipmscorlib verbose ${lowerConfiguration} && src/pal/tests/palsuite/runpaltests.sh \${WORKSPACE}/bin/obj/${osGroup}.x64.${configuration} \${WORKSPACE}/bin/paltestout"
- }
-
- // Create the new job
- def newCommitJob = job(Utilities.getFullJobName(project, jobName, false)) {
- // Set the label.
- label(machineLabelMap[os])
- steps {
- if (os == 'Windows_NT') {
- // Batch
- batchFile(buildCommand)
+['x64', 'x86'].each { architecture ->
+ ['Debug', 'Release'].each { configuration ->
+ osList.each { os ->
+ // Calculate names
+ def lowerConfiguration = configuration.toLowerCase()
+
+ // Calculate job name
+ def jobName = getBuildJobName(configuration, architecture, os)
+ def buildCommands = [];
+
+ def osGroup = osGroupMap[os]
+
+ // Calculate the build commands
+ if (os == 'Windows_NT') {
+ // On Windows we build the mscorlibs too.
+ buildCommands += "build.cmd ${lowerConfiguration} ${architecture}"
+
+ // If x64, we run tests
+ if (architecture == 'x64') {
+ buildCommands += "tests\\runtest.cmd ${lowerConfiguration} ${architecture}"
}
- else {
- // Shell
- shell(buildCommand)
+
+ // Build the mscorlib for the other OS's
+ buildCommands += "build.cmd ${lowerConfiguration} ${architecture} linuxmscorlib"
+ buildCommands += "build.cmd ${lowerConfiguration} ${architecture} freebsdmscorlib"
+ buildCommands += "build.cmd ${lowerConfiguration} ${architecture} osxmscorlib"
+ }
+ else {
+ // On other OS's we skipmscorlib but run the pal tests
+ buildCommands += "./build.sh skipmscorlib verbose ${lowerConfiguration} ${architecture}"
+ buildCommands += "src/pal/tests/palsuite/runpaltests.sh \${WORKSPACE}/bin/obj/${osGroup}.${architecture}.${configuration} \${WORKSPACE}/bin/paltestout"
+ }
+
+ // Create the new job
+ def newCommitJob = job(Utilities.getFullJobName(project, jobName, false)) {
+ // Set the label.
+ label(machineLabelMap[os])
+ steps {
+ if (os == 'Windows_NT') {
+ buildCommands.each { buildCommand ->
+ batchFile(buildCommand)
+ }
+ }
+ else {
+ buildCommands.each { buildCommand ->
+ shell(buildCommand)
+ }
+ }
}
}
- }
- // Add commit job options
- Utilities.addScm(newCommitJob, project)
- Utilities.addStandardNonPRParameters(newCommitJob)
- Utilities.addGithubPushTrigger(newCommitJob)
-
- // Create the new PR job
-
- def newPRJob = job(Utilities.getFullJobName(project, jobName, true)) {
- // Set the label.
- label(machineLabelMap[os])
- steps {
- if (os == 'Windows_NT') {
- // Batch
- batchFile(buildCommand)
- }
- else {
- // Shell
- shell(buildCommand)
+ // Add commit job options
+ Utilities.addScm(newCommitJob, project)
+ Utilities.addStandardNonPRParameters(newCommitJob)
+
+ // Add a push trigger. Do not enable the push trigger for non-windows x86,
+ // which do not work at the moment.
+ if (architecture == 'x64' || osGroup == 'Windows_NT') {
+ Utilities.addGithubPushTrigger(newCommitJob)
+ }
+
+ // Create the new PR job
+
+ def newPRJob = job(Utilities.getFullJobName(project, jobName, true)) {
+ // Set the label.
+ label(machineLabelMap[os])
+ steps {
+ if (os == 'Windows_NT') {
+ buildCommands.each { buildCommand ->
+ batchFile(buildCommand)
+ }
+ }
+ else {
+ buildCommands.each { buildCommand ->
+ shell(buildCommand)
+ }
+ }
}
}
- }
-
- // Add a PR trigger. For some OS's, create an explicit trigger
- // PR's are run for everything except SuSE
- if (os != 'OpenSUSE13.2') {
- Utilities.addGithubPRTrigger(newPRJob, "${os} ${configuration} Build")
- }
- Utilities.addPRTestSCM(newPRJob, project)
- Utilities.addStandardPRParameters(newPRJob, project)
-
- // Add common options:
-
- [newPRJob, newCommitJob].each { newJob ->
- Utilities.addStandardOptions(newJob)
- if (osGroup == 'Windows_NT') {
- Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml')
- Utilities.addArchival(newJob, "bin/Product/**,bin/tests/**", "bin/tests/obj/**")
- } else {
- // Add .NET results for the
- Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
- Utilities.addArchival(newJob, "bin/Product/**")
- Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**")
+ // Add a PR trigger. For some OS's, create an explicit trigger
+ // PR's are run for everything except SuSE by default. Add on-demand triggers
+ // for everything else. This probably deserves a bit of cleanup eventually once we
+ // have an easy way to do regex trigger phrases, to put in some more structured test phrases.
+ def triggerPhraseString = ''
+ if (os == 'OpenSUSE13.2' && architecture == 'x64') {
+ triggerPhraseString = '@dotnet-bot test suse'
+ } else if (architecture == 'x86' && osGroup == 'Windows_NT') {
+ triggerPhraseString = '@dotnet-bot test x86'
+ } else if (architecture == 'x86' && osGroup == 'Linux') {
+ triggerPhraseString = '@dotnet-bot test x86 linux'
+ } else if (architecture == 'x86' && osGroup == 'OSX') {
+ triggerPhraseString = '@dotnet-bot test x86 osx'
+ } else if (architecture == 'x86' && osGroup == 'FreeBSD') {
+ triggerPhraseString = '@dotnet-bot test x86 freebsd'
}
- }
- }
-}
+ Utilities.addGithubPRTrigger(newPRJob, "${os} ${architecture} ${configuration} Build", triggerPhraseString)
+ Utilities.addPRTestSCM(newPRJob, project)
+ Utilities.addStandardPRParameters(newPRJob, project)
+
+ // Add common options:
+
+ [newPRJob, newCommitJob].each { newJob ->
+ Utilities.addStandardOptions(newJob)
+
+ if (osGroup == 'Windows_NT') {
+ Utilities.addXUnitDotNETResults(newJob, 'bin/**/TestRun*.xml')
+ Utilities.addArchival(newJob, "bin/Product/**,bin/tests/**", "bin/tests/obj/**")
+ } else {
+ // Add .NET results for the
+ Utilities.addXUnitDotNETResults(newJob, '**/pal_tests.xml')
+ Utilities.addArchival(newJob, "bin/Product/**")
+ Utilities.addArchival(newJob, "bin/Product/**,bin/obj/*/tests/**")
+ }
+ }
+ } // os
+ } // configuration
+} // architecture
// Ubuntu cross compiled arm and arm64 builds
// Scheduled for nightly and on-demand PR for now
}
// Create the Linux coreclr test leg for debug and release.
-// Put the OS's supported for coreclr cross testing here
-['Ubuntu'].each { os ->
- [true, false].each { isPR ->
- ['Debug', 'Release'].each { configuration ->
-
- def lowerConfiguration = configuration.toLowerCase()
- def osGroup = osGroupMap[os]
- def jobName = getBuildJobName(configuration, os) + "_tst"
- def inputCoreCLRBuildName = Utilities.getFolderName(project) + '/' +
- Utilities.getFullJobName(project, getBuildJobName(configuration, os), isPR)
- def inputWindowTestsBuildName = Utilities.getFolderName(project) + '/' +
- Utilities.getFullJobName(project, getBuildJobName(configuration, 'windows_nt'), isPR)
-
- def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
- // Set the label.
- label(machineLabelMap[os])
-
- // Add parameters for the inputs
+// Architectures
+['x64', 'x86'].each { architecture ->
+ // Put the OS's supported for coreclr cross testing here
+ ['Ubuntu'].each { os ->
+ [true, false].each { isPR ->
+ ['Debug', 'Release'].each { configuration ->
- parameters {
- stringParam('CORECLR_WINDOWS_BUILD', '', 'Build number to copy CoreCLR windows test binaries from')
- stringParam('CORECLR_LINUX_BUILD', '', 'Build number to copy CoreCLR linux binaries from')
- }
+ def lowerConfiguration = configuration.toLowerCase()
+ def osGroup = osGroupMap[os]
+ def jobName = getBuildJobName(configuration, architecture, os) + "_tst"
+ def inputCoreCLRBuildName = Utilities.getFolderName(project) + '/' +
+ Utilities.getFullJobName(project, getBuildJobName(configuration, architecture, os), isPR)
+ def inputWindowTestsBuildName = Utilities.getFolderName(project) + '/' +
+ Utilities.getFullJobName(project, getBuildJobName(configuration, architecture, 'windows_nt'), isPR)
- steps {
- // Set up the copies
+ def newJob = job(Utilities.getFullJobName(project, jobName, isPR)) {
+ // Set the label.
+ label(machineLabelMap[os])
- // Coreclr build we are trying to test
+ // Add parameters for the inputs
- copyArtifacts(inputCoreCLRBuildName) {
- excludePatterns('**/testResults.xml', '**/*.ni.dll')
- buildSelector {
- buildNumber('${CORECLR_LINUX_BUILD}')
- }
+ parameters {
+ stringParam('CORECLR_WINDOWS_BUILD', '', 'Build number to copy CoreCLR windows test binaries from')
+ stringParam('CORECLR_LINUX_BUILD', '', 'Build number to copy CoreCLR linux binaries from')
}
- // Coreclr build containing the tests and mscorlib
-
- copyArtifacts(inputWindowTestsBuildName) {
- excludePatterns('**/testResults.xml', '**/*.ni.dll')
- buildSelector {
- buildNumber('${CORECLR_WINDOWS_BUILD}')
+ steps {
+ // Set up the copies
+
+ // Coreclr build we are trying to test
+
+ copyArtifacts(inputCoreCLRBuildName) {
+ excludePatterns('**/testResults.xml', '**/*.ni.dll')
+ buildSelector {
+ buildNumber('${CORECLR_LINUX_BUILD}')
+ }
}
- }
-
- // Corefx native components
- copyArtifacts("dotnet_corefx_linux_nativecomp_debug") {
- includePatterns('bin/**')
- buildSelector {
- latestSuccessful(true)
+
+ // Coreclr build containing the tests and mscorlib
+
+ copyArtifacts(inputWindowTestsBuildName) {
+ excludePatterns('**/testResults.xml', '**/*.ni.dll')
+ buildSelector {
+ buildNumber('${CORECLR_WINDOWS_BUILD}')
+ }
}
- }
-
- // Corefx linux binaries
- copyArtifacts("dotnet_corefx_linux_nativecomp_debug") {
- includePatterns('bin/Linux*/**')
- buildSelector {
- latestSuccessful(true)
+
+ // Corefx native components
+ copyArtifacts("dotnet_corefx_linux_nativecomp_debug") {
+ includePatterns('bin/**')
+ buildSelector {
+ latestSuccessful(true)
+ }
+ }
+
+ // Corefx linux binaries
+ copyArtifacts("dotnet_corefx_linux_debug") {
+ includePatterns('bin/Linux*/**')
+ buildSelector {
+ latestSuccessful(true)
+ }
}
+
+ // Execute the shell command
+
+ shell("""
+ ./tests/runtest.sh \\
+ --testRootDir=\"\${WORKSPACE}/bin/tests/Windows_NT.${architecture}.${configuration}\" \\
+ --testNativeBinDir=\"\${WORKSPACE}/bin/obj/Linux.${architecture}.${configuration}/tests\" \\
+ --coreClrBinDir=\"\${WORKSPACE}/bin/Product/Linux.${architecture}.${configuration}\" \\
+ --mscorlibDir=\"\${WORKSPACE}/bin/Product/Linux.${architecture}.${configuration}\" \\
+ --coreFxBinDir=\"\${WORKSPACE}/bin/Linux.AnyCPU.Debug\" \\
+ --coreFxNativeBinDir=\"\${WORKSPACE}/bin/Linux.${architecture}.Debug\"""")
}
-
- // Execute the shell command
-
- shell("""
-./tests/runtest.sh \\
- --testRootDir='\${WORKSPACE}/bin/tests/Windows_NT.x64.Debug' \\
- --testNativeBinDir='\${WORKSPACE}/bin/obj/Linux.x64.Debug/tests' \\
- --coreClrBinDir='\${WORKSPACE}/bin/Product/Linux.x64.Debug' \\
- --mscorlibDir='\${WORKSPACE}/bin/Product/Linux.x64.Debug' \\
- --coreFxBinDir='\${WORKSPACE}/bin/Linux.AnyCPU.Debug' \\
- --coreFxNativeBinDir='\${WORKSPACE}/bin/Linux.x64.Debug'""")
}
- }
-
- if (!isPR) {
- // Add rolling job options
- Utilities.addScm(newJob, project)
- Utilities.addStandardNonPRParameters(newJob)
- }
- else {
- // Add PR job options
- Utilities.addPRTestSCM(newJob, project)
- Utilities.addStandardPRParameters(newJob, project)
- }
- Utilities.addStandardOptions(newJob)
- Utilities.addXUnitDotNETResults(newJob, '**/coreclrtests.xml')
-
- // Create a build flow to join together the build and tests required to run this
- // test.
- // Windows CoreCLR build and Linux CoreCLR build (in parallel) ->
- // Linux CoreCLR test
- def flowJobName = getBuildJobName(configuration, os) + "_flow"
- def fullTestJobName = Utilities.getFolderName(project) + '/' + newJob.name
- def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR)) {
- buildFlow("""
+
+ if (!isPR) {
+ // Add rolling job options
+ Utilities.addScm(newJob, project)
+ Utilities.addStandardNonPRParameters(newJob)
+ }
+ else {
+ // Add PR job options
+ Utilities.addPRTestSCM(newJob, project)
+ Utilities.addStandardPRParameters(newJob, project)
+ }
+ Utilities.addStandardOptions(newJob)
+ Utilities.addXUnitDotNETResults(newJob, '**/coreclrtests.xml')
+
+ // Create a build flow to join together the build and tests required to run this
+ // test.
+ // Windows CoreCLR build and Linux CoreCLR build (in parallel) ->
+ // Linux CoreCLR test
+ def flowJobName = getBuildJobName(configuration, architecture, os) + "_flow"
+ def fullTestJobName = Utilities.getFolderName(project) + '/' + newJob.name
+ def newFlowJob = buildFlowJob(Utilities.getFullJobName(project, flowJobName, isPR)) {
+ buildFlow("""
// Grab the checked out git commit hash so that it can be passed to the child
// builds.
gitCommit = build.environment.get('GIT_COMMIT')
{ linuxBuildJob = build(params + [GitBranchOrCommit: gitCommit], '${inputCoreCLRBuildName}') },
{ windowsBuildJob = build(params + [GitBranchOrCommit: gitCommit], '${inputWindowTestsBuildName}') }
)
-
+
// And then build the test build
build(params + [CORECLR_LINUX_BUILD: linuxBuildJob.build.number,
CORECLR_WINDOWS_BUILD: windowsBuildJob.build.number, GitBranchOrCommit: gitCommit], '${fullTestJobName}')
""")
- // Needs a workspace
- configure {
- def buildNeedsWorkspace = it / 'buildNeedsWorkspace'
- buildNeedsWorkspace.setValue('true')
+ // Needs a workspace
+ configure {
+ def buildNeedsWorkspace = it / 'buildNeedsWorkspace'
+ buildNeedsWorkspace.setValue('true')
+ }
}
- }
- if (isPR) {
- Utilities.addPRTestSCM(newFlowJob, project)
- Utilities.addStandardPRParameters(newFlowJob, project)
- Utilities.addGithubPRTrigger(newFlowJob, "Linux ${configuration} Build and Test", '@dotnet-bot test linux')
- }
- else {
- Utilities.addScm(newFlowJob, project)
- Utilities.addStandardNonPRParameters(newFlowJob)
+ if (isPR) {
+ Utilities.addPRTestSCM(newFlowJob, project)
+ Utilities.addStandardPRParameters(newFlowJob, project)
+ if (architecture == 'x64') {
+ Utilities.addGithubPRTrigger(newFlowJob, "Linux ${architecture} ${configuration} Build and Test", '@dotnet-bot test linux')
+ } else {
+ Utilities.addGithubPRTrigger(newFlowJob, "Linux ${architecture} ${configuration} Build and Test", '@dotnet-bot test linux x86')
+ }
+ }
+ else {
+ Utilities.addScm(newFlowJob, project)
+ Utilities.addStandardNonPRParameters(newFlowJob)
+ }
+
+ Utilities.addStandardOptions(newFlowJob)
}
-
- Utilities.addStandardOptions(newFlowJob)
}
}
-}
-
+}
\ No newline at end of file
}
/*
+Static Function:
+AreEqualOrdinalIgnoreCase
+*/
+static bool AreEqualOrdinalIgnoreCase(UChar32 one, UChar32 two)
+{
+ // Return whether the two characters are identical or would be identical if they were upper-cased.
+
+ if (one == two)
+ {
+ return true;
+ }
+
+ if (one == 0x0131 || two == 0x0131)
+ {
+ // On Windows with InvariantCulture, the LATIN SMALL LETTER DOTLESS I (U+0131)
+ // capitalizes to itself, whereas with ICU it capitalizes to LATIN CAPITAL LETTER I (U+0049).
+ // We special case it to match the Windows invariant behavior.
+ return false;
+ }
+
+ return u_toupper(one) == u_toupper(two);
+}
+
+/*
+Function:
+IndexOfOrdinalIgnoreCase
+*/
+extern "C" int32_t
+IndexOfOrdinalIgnoreCase(
+ const UChar* lpTarget, int32_t cwTargetLength,
+ const UChar* lpSource, int32_t cwSourceLength,
+ int32_t findLast)
+{
+ int32_t result = -1;
+
+ int32_t endIndex = cwSourceLength - cwTargetLength;
+ assert(endIndex >= 0);
+
+ int32_t i = 0;
+ while (i <= endIndex)
+ {
+ int32_t srcIdx = i, trgIdx = 0;
+ const UChar *src = lpSource, *trg = lpTarget;
+ UChar32 srcCodepoint, trgCodepoint;
+
+ bool match = true;
+ while (trgIdx < cwTargetLength)
+ {
+ U16_NEXT(src, srcIdx, cwSourceLength, srcCodepoint);
+ U16_NEXT(trg, trgIdx, cwTargetLength, trgCodepoint);
+ if (!AreEqualOrdinalIgnoreCase(srcCodepoint, trgCodepoint))
+ {
+ match = false;
+ break;
+ }
+ }
+
+ if (match)
+ {
+ result = i;
+ if (!findLast)
+ {
+ break;
+ }
+ }
+
+ U16_FWD_1(lpSource, i, cwSourceLength);
+ }
+
+ return result;
+}
+
+/*
Return value is a "Win32 BOOL" (1 = true, 0 = false)
*/
extern "C" int32_t StartsWith(
case DB_IPCE_GET_GCHANDLE_INFO:
cbAdditionalSize = sizeof(pEvent->GetGCHandleInfo);
break;
-
+
+ case DB_IPCE_CUSTOM_NOTIFICATION:
+ cbAdditionalSize = sizeof(pEvent->CustomNotification);
+ break;
+
default:
printf("Unknown debugger event type: 0x%x\n", (pEvent->type & DB_IPCE_TYPE_MASK));
_ASSERTE(!"Unknown debugger event type");
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_ReadyToRun, W("ReadyToRun"), 0, "Enable/disable use of ReadyToRun native code") // Off by default for desktop
#endif
-#if defined(FEATURE_PAL) && defined(FEATURE_EVENT_TRACE)
+#if defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT)
RETAIL_CONFIG_DWORD_INFO(EXTERNAL_EnableEventLog, W("EnableEventLog"), 0, "Enable/disable use of EnableEventLogging mechanism ") // Off by default
-#endif //defined(FEATURE_PAL) && defined(FEATURE_EVENT_TRACE)
+#endif //defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT)
//
// Interop
#define GetClrInstanceId() (static_cast<UINT16>(g_nClrInstanceId))
+#if defined(FEATURE_EVENT_TRACE) || defined(FEATURE_EVENTSOURCE_XPLAT)
+
+#include "clrconfig.h"
+ class XplatEventLogger
+{
+ public:
+ inline static BOOL IsEventLoggingEnabled()
+ {
+ static ConfigDWORD configEventLogging;
+ return configEventLogging.val(CLRConfig::EXTERNAL_EnableEventLog);
+ }
+};
+
+#endif //defined(FEATURE_EVENT_TRACE)
+
#if defined(FEATURE_EVENT_TRACE)
#ifndef FEATURE_PAL
#elif defined(__LINUX__)
-#include "clrconfig.h"
- class XplatEventLogger
-{
- public:
- inline static BOOL IsEventLoggingEnabled()
- {
- static ConfigDWORD configEventLogging;
- return configEventLogging.val(CLRConfig::EXTERNAL_EnableEventLog);
- }
-};
#include "clrallevents.h"
#else
#error "A tracing System has not been enabled for this Platform"
//
//
-// Defines a random number generator, ripped off from the System.Random code in the BCL. If you notice any problems,
-// please compare to the implementation in ndp\clr\src\bcl\system\random.cs.
+// Defines a random number generator, initially from the System.Random code in the BCL. If you notice any problems,
+// please compare to the implementation in src\mscorlib\src\system\random.cs.
//
// Main advantages over rand() are:
//
int mj, mk;
//Initialize our Seed array.
- //This algorithm comes from Numerical Recipes in C (2nd Ed.)
mj = MSEED - abs(Seed);
SeedArray[55]=mj;
mk=1;
{
LIMITED_METHOD_DAC_CONTRACT;
- // Current implementation taken from lookup3.c, by Bob Jenkins, May 2006
-
+ /*
+ lookup3.c, by Bob Jenkins, May 2006, Public Domain.
+
+ These are functions for producing 32-bit hashes for hash table lookup.
+ hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final()
+ are externally useful functions. Routines to test the hash are included
+ if SELF_TEST is defined. You can use this free for any purpose. It's in
+ the public domain. It has no warranty.
+ */
+
#define rot32(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
c ^= b; c -= rot32(b,14);
a ^= c; a -= rot32(c,11);
+++ /dev/null
-The MIT License (MIT)
-
-Copyright (c) 2014 Microsoft
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-
internal unsafe static extern int LastIndexOf(byte[] localeName, string target, char* pSource, int cwSourceLength, CompareOptions options);
[DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode)]
+ internal unsafe static extern int IndexOfOrdinalIgnoreCase(string target, int cwTargetLength, char* pSource, int cwSourceLength, bool findLast);
+
+ [DllImport(Libraries.GlobalizationInterop, CharSet = CharSet.Unicode)]
[return: MarshalAs(UnmanagedType.Bool)]
internal unsafe static extern bool StartsWith(byte[] localeName, string target, string source, int cwSourceLength, CompareOptions options);
m_sortNameAsUtf8 = System.Text.Encoding.UTF8.GetBytes(m_sortName);
}
- internal static int IndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase)
+ internal static unsafe int IndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase)
{
Contract.Assert(source != null);
Contract.Assert(value != null);
return startIndex;
}
- // TODO (dotnet/corefx#3468): Move this into the shim so we don't have to do the ToUpper or call substring.
+ if (count < value.Length)
+ {
+ return -1;
+ }
if (ignoreCase)
{
- source = source.ToUpper(CultureInfo.InvariantCulture);
- value = value.ToUpper(CultureInfo.InvariantCulture);
+ fixed (char* pSource = source)
+ {
+ int index = Interop.GlobalizationInterop.IndexOfOrdinalIgnoreCase(value, value.Length, pSource + startIndex, count, findLast: false);
+ return index != -1 ?
+ startIndex + index :
+ -1;
+ }
}
- source = source.Substring(startIndex, count);
-
- for (int i = 0; i + value.Length <= source.Length; i++)
+ int endIndex = startIndex + (count - value.Length);
+ for (int i = startIndex; i <= endIndex; i++)
{
- for (int j = 0; j < value.Length; j++) {
- if (source[i + j] != value[j]) {
- break;
- }
+ int valueIndex, sourceIndex;
+
+ for (valueIndex = 0, sourceIndex = i;
+ valueIndex < value.Length && source[sourceIndex] == value[valueIndex];
+ valueIndex++, sourceIndex++) ;
- if (j == value.Length - 1) {
- return i + startIndex;
- }
+ if (valueIndex == value.Length)
+ {
+ return i;
}
}
return -1;
}
- internal static int LastIndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase)
+ internal static unsafe int LastIndexOfOrdinal(string source, string value, int startIndex, int count, bool ignoreCase)
{
Contract.Assert(source != null);
Contract.Assert(value != null);
return startIndex;
}
- // TODO (dotnet/corefx#3468): Move this into the shim so we don't have to do the ToUpper or call substring.
+ if (count < value.Length)
+ {
+ return -1;
+ }
+
+ // startIndex is the index into source where we start search backwards from.
+ // leftStartIndex is the index into source of the start of the string that is
+ // count characters away from startIndex.
+ int leftStartIndex = startIndex - count + 1;
if (ignoreCase)
{
- source = source.ToUpper(CultureInfo.InvariantCulture);
- value = value.ToUpper(CultureInfo.InvariantCulture);
+ fixed (char* pSource = source)
+ {
+ int lastIndex = Interop.GlobalizationInterop.IndexOfOrdinalIgnoreCase(value, value.Length, pSource + leftStartIndex, count, findLast: true);
+ return lastIndex != -1 ?
+ leftStartIndex + lastIndex :
+ -1;
+ }
}
- source = source.Substring(startIndex - count + 1, count);
+ for (int i = startIndex - value.Length + 1; i >= leftStartIndex; i--)
+ {
+ int valueIndex, sourceIndex;
- int last = -1;
+ for (valueIndex = 0, sourceIndex = i;
+ valueIndex < value.Length && source[sourceIndex] == value[valueIndex];
+ valueIndex++, sourceIndex++) ;
- int cur = 0;
- while ((cur = IndexOfOrdinal(source, value, last + 1, source.Length - last - 1, false)) != -1)
- {
- last = cur;
+ if (valueIndex == value.Length) {
+ return i;
+ }
}
- return last >= 0 ?
- last + startIndex - count + 1 :
- -1;
+ return -1;
}
private unsafe int GetHashCodeOfStringCore(string source, CompareOptions options)
fixed (char* pSource = source)
{
- int lastIndex = Interop.GlobalizationInterop.IndexOf(m_sortNameAsUtf8, target, pSource + startIndex, count, options);
+ int index = Interop.GlobalizationInterop.IndexOf(m_sortNameAsUtf8, target, pSource + startIndex, count, options);
- return lastIndex != -1 ? lastIndex + startIndex : -1;
+ return index != -1 ? index + startIndex : -1;
}
}
<DiagnosticsSources Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\EventDescriptor.cs" />
<DiagnosticsSources Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\EventProvider.cs" />
<DiagnosticsSources Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\EventSource.cs" />
+ <DiagnosticsSources Condition="'$(FeatureXplatEventSource)' == 'true'" Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\XplatEventLogger.cs" />
<DiagnosticsSources Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\EventSourceException.cs" />
<DiagnosticsSources Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\FrameworkEventSource.cs" />
<DiagnosticsSources Include="$(BclSourcesRoot)\System\Diagnostics\Eventing\StubEnvironment.cs" />
/// </remarks>
public partial class EventSource : IDisposable
{
+
+#if FEATURE_EVENTSOURCE_XPLAT
+ private static readonly EventListener persistent_Xplat_Listener = XplatEventLogger.InitializePersistentListener();
+#endif //FEATURE_EVENTSOURCE_XPLAT
+
/// <summary>
/// The human-friendly name of the eventSource. It defaults to the simple name of the class
/// </summary>
--- /dev/null
+using System;
+using System.Runtime.CompilerServices;
+using System.Collections.ObjectModel;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Text;
+using System.Runtime.InteropServices;
+
+using Contract = System.Diagnostics.Contracts.Contract;
+
+#if FEATURE_EVENTSOURCE_XPLAT
+
+namespace System.Diagnostics.Tracing
+{
+
+ internal class XplatEventLogger : EventListener
+ {
+ public XplatEventLogger() {}
+
+ private static bool initializedPersistentListener = false;
+
+ [System.Security.SecuritySafeCritical]
+ public static EventListener InitializePersistentListener()
+ {
+ try{
+
+ if (!initializedPersistentListener && XplatEventLogger.IsEventSourceLoggingEnabled())
+ {
+ initializedPersistentListener = true;
+ return new XplatEventLogger();
+ }
+ }
+ catch(Exception){}
+
+ return null;
+ }
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ private static extern bool IsEventSourceLoggingEnabled();
+
+ [DllImport(JitHelpers.QCall, CharSet = CharSet.Unicode)]
+ private static extern void LogEventSource(int eventID, string eventName, string eventSourceName, string payload);
+
+ static List<char> escape_seq = new List<char> { '\b', '\f', '\n', '\r', '\t', '\"', '\\' };
+ static Dictionary<char, string> seq_mapping = new Dictionary<char, string>()
+ {
+ {'\b', "b"},
+ {'\f', "f"},
+ {'\n', "n"},
+ {'\r', "r"},
+ {'\t', "t"},
+ {'\"', "\\\""},
+ {'\\', "\\\\"}
+ };
+
+ private static void minimalJsonserializer(string payload, StringBuilder sb)
+ {
+ foreach( var elem in payload)
+ {
+ if (escape_seq.Contains(elem))
+ {
+ sb.Append("\\\\");
+ sb.Append(seq_mapping[elem]);
+ }
+ else
+ {
+ sb.Append(elem);
+ }
+ }
+ }
+
+ private static string Serialize(ReadOnlyCollection<string> payloadName, ReadOnlyCollection<object> payload, string sep = ", ")
+ {
+
+ if (payloadName == null || payload == null )
+ return String.Empty;
+
+ if (payloadName.Count == 0 || payload.Count == 0)
+ return String.Empty;
+
+ Contract.Assert(payloadName.Count == payload.Count);
+
+ var sb = StringBuilderCache.Acquire();
+
+ sb.Append('{');
+ for (int i = 0; i < payloadName.Count; i++)
+ {
+ var fieldstr = payloadName[i].ToString();
+
+ sb.Append("\\\"");
+ sb.Append(fieldstr);
+ sb.Append("\\\"");
+ sb.Append(':');
+
+ var valuestr = payload[i] as string;
+
+ if( valuestr != null)
+ {
+ sb.Append("\\\"");
+ minimalJsonserializer(valuestr,sb);
+ sb.Append("\\\"");
+ }
+ else
+ {
+ sb.Append(payload[i].ToString());
+ }
+
+ sb.Append(sep);
+
+ }
+
+ sb.Length -= sep.Length;
+ sb.Append('}');
+
+ return StringBuilderCache.GetStringAndRelease(sb);
+ }
+
+ internal protected override void OnEventSourceCreated(EventSource eventSource)
+ {
+ EnableEvents(eventSource, EventLevel.LogAlways, EventKeywords.All, null);
+ }
+
+ internal protected override void OnEventWritten(EventWrittenEventArgs eventData)
+ {
+ LogOnEventWritten(eventData);
+ }
+
+ [System.Security.SecuritySafeCritical]
+ private void LogOnEventWritten(EventWrittenEventArgs eventData)
+ {
+ string payload = "";
+ if (eventData.Payload != null)
+ {
+ payload = Serialize(eventData.PayloadNames, eventData.Payload);
+ }
+
+ LogEventSource( eventData.EventId, eventData.EventName,eventData.EventSource.Name,payload);
+ }
+ }
+}
+#endif //FEATURE_EVENTSOURCE_XPLAT
// RFC 3491 - Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)
// RFC 3492 - Punycode: A Bootstring encoding of Unicode for Internationalized Domain Names in Applications (IDNA)
//
+
+/*
+
+The punycode implementation is based on the sample code in RFC 3492
+
+Copyright (C) The Internet Society (2003). All Rights Reserved.
+
+This document and translations of it may be copied and furnished to
+others, and derivative works that comment on or otherwise explain it
+or assist in its implementation may be prepared, copied, published
+and distributed, in whole or in part, without restriction of any
+kind, provided that the above copyright notice and this paragraph are
+included on all such copies and derivative works. However, this
+document itself may not be modified in any way, such as by removing
+the copyright notice or references to the Internet Society or other
+Internet organizations, except as needed for the purpose of
+developing Internet standards in which case the procedures for
+copyrights defined in the Internet Standards process must be
+followed, or as required to translate it into languages other than
+English.
+
+The limited permissions granted above are perpetual and will not be
+revoked by the Internet Society or its successors or assigns.
+
+This document and the information contained herein is provided on an
+"AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
+TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
+BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
+HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
+MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+*/
+
namespace System.Globalization
{
using System;
int mj, mk;
//Initialize our Seed array.
- //This algorithm comes from Numerical Recipes in C (2nd Ed.)
int subtraction = (Seed == Int32.MinValue) ? Int32.MaxValue : Math.Abs(Seed);
mj = MSEED - subtraction;
SeedArray[55]=mj;
typedef DWORD (PALAPI *PTHREAD_START_ROUTINE)(LPVOID lpThreadParameter);
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
+
+/******************* Tracing Initialization *******************************/
+
+#if defined(__LINUX__)
+
+// Constructor priority is set to 200, which allows for constructors to
+// guarantee that they run before or after this constructor by setting
+// their priority appropriately.
+
+// Priority values must be greater than 100. The lower the value,
+// the higher the priority.
+static
+void
+__attribute__((__unused__))
+__attribute__((constructor (200)))
+PAL_InitializeTracing(void);
+
+#endif
+
+
/******************* PAL-Specific Entrypoints *****************************/
PALIMPORT
// significant set bit, or 0 if if mask is zero.
//
// The same is true for BitScanForward, except that the GCC function is __builtin_ffs.
-
+EXTERN_C
PALIMPORT
+inline
unsigned char
PALAPI
BitScanForward(
- IN OUT PDWORD Index,
- IN UINT qwMask);
+ IN OUT PDWORD Index,
+ IN UINT qwMask)
+{
+ unsigned char bRet = FALSE;
+ int iIndex = __builtin_ffsl(qwMask);
+ if (iIndex != 0)
+ {
+ // Set the Index after deducting unity
+ *Index = (DWORD)(iIndex - 1);
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+EXTERN_C
PALIMPORT
-LONG
+inline
+unsigned char
PALAPI
-InterlockedIncrement(
- IN OUT LONG volatile *lpAddend);
+BitScanForward64(
+ IN OUT PDWORD Index,
+ IN UINT64 qwMask)
+{
+ unsigned char bRet = FALSE;
+ int iIndex = __builtin_ffsl(qwMask);
+ if (iIndex != 0)
+ {
+ // Set the Index after deducting unity
+ *Index = (DWORD)(iIndex - 1);
+ bRet = TRUE;
+ }
+
+ return bRet;
+}
+/*++
+Function:
+InterlockedIncrement
+
+The InterlockedIncrement function increments (increases by one) the
+value of the specified variable and checks the resulting value. The
+function prevents more than one thread from using the same variable
+simultaneously.
+
+Parameters
+
+lpAddend
+[in/out] Pointer to the variable to increment.
+
+Return Values
+
+The return value is the resulting incremented value.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedDecrement(
- IN OUT LONG volatile *lpAddend);
+InterlockedIncrement(
+ IN OUT LONG volatile *lpAddend)
+{
+ return __sync_add_and_fetch(lpAddend, (LONG)1);
+}
+EXTERN_C
PALIMPORT
-LONG
+inline
+LONGLONG
PALAPI
-InterlockedExchange(
- IN OUT LONG volatile *Target,
- IN LONG Value);
+InterlockedIncrement64(
+ IN OUT LONGLONG volatile *lpAddend)
+{
+ return __sync_add_and_fetch(lpAddend, (LONGLONG)1);
+}
+
+/*++
+Function:
+InterlockedDecrement
+
+The InterlockedDecrement function decrements (decreases by one) the
+value of the specified variable and checks the resulting value. The
+function prevents more than one thread from using the same variable
+simultaneously.
+Parameters
+
+lpAddend
+[in/out] Pointer to the variable to decrement.
+
+Return Values
+
+The return value is the resulting decremented value.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedCompareExchange(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand);
+InterlockedDecrement(
+ IN OUT LONG volatile *lpAddend)
+{
+ return __sync_sub_and_fetch(lpAddend, (LONG)1);
+}
+EXTERN_C
PALIMPORT
-LONG
+inline
+LONGLONG
PALAPI
-InterlockedCompareExchangeAcquire(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand);
+InterlockedDecrement64(
+ IN OUT LONGLONG volatile *lpAddend)
+{
+ return __sync_sub_and_fetch(lpAddend, (LONGLONG)1);
+}
+
+/*++
+Function:
+InterlockedExchange
+The InterlockedExchange function atomically exchanges a pair of
+values. The function prevents more than one thread from using the same
+variable simultaneously.
+
+Parameters
+
+Target
+[in/out] Pointer to the value to exchange. The function sets
+this variable to Value, and returns its prior value.
+Value
+[in] Specifies a new value for the variable pointed to by Target.
+
+Return Values
+
+The function returns the initial value pointed to by Target.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedCompareExchangeRelease(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand);
-
+InterlockedExchange(
+ IN OUT LONG volatile *Target,
+ IN LONG Value)
+{
+ return __sync_swap(Target, Value);
+}
+
+EXTERN_C
PALIMPORT
-LONG
+inline
+LONGLONG
PALAPI
-InterlockedExchangeAdd(
- IN OUT LONG volatile *Addend,
- IN LONG Value);
-
+InterlockedExchange64(
+ IN OUT LONGLONG volatile *Target,
+ IN LONGLONG Value)
+{
+ return __sync_swap(Target, Value);
+}
+
+/*++
+Function:
+InterlockedCompareExchange
+
+The InterlockedCompareExchange function performs an atomic comparison
+of the specified values and exchanges the values, based on the outcome
+of the comparison. The function prevents more than one thread from
+using the same variable simultaneously.
+
+If you are exchanging pointer values, this function has been
+superseded by the InterlockedCompareExchangePointer function.
+
+Parameters
+
+Destination [in/out] Specifies the address of the destination value. The sign is ignored.
+Exchange [in] Specifies the exchange value. The sign is ignored.
+Comperand [in] Specifies the value to compare to Destination. The sign is ignored.
+
+Return Values
+
+The return value is the initial value of the destination.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedAnd(
- IN OUT LONG volatile *Destination,
- IN LONG Value);
+InterlockedCompareExchange(
+ IN OUT LONG volatile *Destination,
+ IN LONG Exchange,
+ IN LONG Comperand)
+{
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+EXTERN_C
PALIMPORT
+inline
LONG
PALAPI
-InterlockedOr(
- IN OUT LONG volatile *Destination,
- IN LONG Value);
+InterlockedCompareExchangeAcquire(
+ IN OUT LONG volatile *Destination,
+ IN LONG Exchange,
+ IN LONG Comperand)
+{
+ // TODO: implement the version with only the acquire semantics
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+EXTERN_C
PALIMPORT
-UCHAR
+inline
+LONG
PALAPI
-InterlockedBitTestAndReset(
- IN OUT LONG volatile *Base,
- IN LONG Bit);
+InterlockedCompareExchangeRelease(
+ IN OUT LONG volatile *Destination,
+ IN LONG Exchange,
+ IN LONG Comperand)
+{
+ // TODO: implement the version with only the release semantics
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+// See the 32-bit variant in interlock2.s
+EXTERN_C
PALIMPORT
-UCHAR
+inline
+LONGLONG
PALAPI
-InterlockedBitTestAndSet(
- IN OUT LONG volatile *Base,
- IN LONG Bit);
+InterlockedCompareExchange64(
+ IN OUT LONGLONG volatile *Destination,
+ IN LONGLONG Exchange,
+ IN LONGLONG Comperand)
+{
+ return __sync_val_compare_and_swap(
+ Destination, /* The pointer to a variable whose value is to be compared with. */
+ Comperand, /* The value to be compared */
+ Exchange /* The value to be stored */);
+}
+
+/*++
+Function:
+InterlockedExchangeAdd
+
+The InterlockedExchangeAdd function atomically adds the value of 'Value'
+to the variable that 'Addend' points to.
+
+Parameters
+lpAddend
+[in/out] Pointer to the variable to to added.
+
+Return Values
+
+The return value is the original value that 'Addend' pointed to.
+
+--*/
+EXTERN_C
PALIMPORT
-unsigned char
+inline
+LONG
PALAPI
-BitScanForward64(
- IN OUT PDWORD Index,
- IN UINT64 qwMask);
+InterlockedExchangeAdd(
+ IN OUT LONG volatile *Addend,
+ IN LONG Value)
+{
+ return __sync_fetch_and_add(Addend, Value);
+}
+EXTERN_C
PALIMPORT
+inline
LONGLONG
PALAPI
-InterlockedIncrement64(
- IN OUT LONGLONG volatile *lpAddend);
+InterlockedExchangeAdd64(
+ IN OUT LONGLONG volatile *Addend,
+ IN LONGLONG Value)
+{
+ return __sync_fetch_and_add(Addend, Value);
+}
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+LONG
PALAPI
-InterlockedDecrement64(
- IN OUT LONGLONG volatile *lpAddend);
+InterlockedAnd(
+ IN OUT LONG volatile *Destination,
+ IN LONG Value)
+{
+ return __sync_fetch_and_and(Destination, Value);
+}
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+LONG
PALAPI
-InterlockedExchange64(
- IN OUT LONGLONG volatile *Target,
- IN LONGLONG Value);
-
+InterlockedOr(
+ IN OUT LONG volatile *Destination,
+ IN LONG Value)
+{
+ return __sync_fetch_and_or(Destination, Value);
+}
+
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+UCHAR
PALAPI
-InterlockedExchangeAdd64(
- IN OUT LONGLONG volatile *Addend,
- IN LONGLONG Value);
+InterlockedBitTestAndReset(
+ IN OUT LONG volatile *Base,
+ IN LONG Bit)
+{
+ return (InterlockedAnd(Base, ~(1 << Bit)) & (1 << Bit)) != 0;
+}
+EXTERN_C
PALIMPORT
-LONGLONG
+inline
+UCHAR
PALAPI
-InterlockedCompareExchange64(
- IN OUT LONGLONG volatile *Destination,
- IN LONGLONG Exchange,
- IN LONGLONG Comperand);
+InterlockedBitTestAndSet(
+ IN OUT LONG volatile *Base,
+ IN LONG Bit)
+{
+ return (InterlockedOr(Base, (1 << Bit)) & (1 << Bit)) != 0;
+}
#if defined(BIT64)
#define InterlockedExchangePointer(Target, Value) \
((PVOID)(UINT_PTR)InterlockedCompareExchange((PLONG)(UINT_PTR)(Destination), (LONG)(UINT_PTR)(ExChange), (LONG)(UINT_PTR)(Comperand)))
#endif
+/*++
+Function:
+MemoryBarrier
+
+The MemoryBarrier function creates a full memory barrier.
+
+--*/
+EXTERN_C
PALIMPORT
+inline
VOID
PALAPI
MemoryBarrier(
- VOID);
+ VOID)
+{
+ __sync_synchronize();
+}
PALIMPORT
VOID
}
#endif
-PALIMPORT unsigned int __cdecl _rotl(unsigned int, int);
+/*++
+Function:
+_rotl
+
+See MSDN doc.
+--*/
+EXTERN_C
+PALIMPORT
+inline
+unsigned int __cdecl _rotl(unsigned int value, int shift)
+{
+ unsigned int retval = 0;
+
+ shift &= 0x1f;
+ retval = (value << shift) | (value >> (sizeof(int) * CHAR_BIT - shift));
+ return retval;
+}
+
// On 64 bit unix, make the long an int.
#ifdef BIT64
#define _lrotl _rotl
#endif // BIT64
-PALIMPORT unsigned int __cdecl _rotr(unsigned int, int);
+/*++
+Function:
+_rotr
+
+See MSDN doc.
+--*/
+EXTERN_C
+PALIMPORT
+inline
+unsigned int __cdecl _rotr(unsigned int value, int shift)
+{
+ unsigned int retval;
+
+ shift &= 0x1f;
+ retval = (value >> shift) | (value << (sizeof(int) * CHAR_BIT - shift));
+ return retval;
+}
+
PALIMPORT int __cdecl abs(int);
PALIMPORT double __cdecl fabs(double);
#ifndef PAL_STDCPP_COMPAT
#define MAKEDLLNAME(x) MAKEDLLNAME_A(x)
#endif
+#define PAL_SHLIB_PREFIX "lib"
+
+#if __APPLE__
+#define PAL_SHLIB_SUFFIX ".dylib"
+#elif _AIX
+#define PAL_SHLIB_SUFFIX ".a"
+#elif _HPUX_
+#define PAL_SHLIB_SUFFIX ".sl"
+#else
+#define PAL_SHLIB_SUFFIX ".so"
+#endif
+
#define DBG_EXCEPTION_HANDLED ((DWORD )0x00010001L)
#define DBG_CONTINUE ((DWORD )0x00010002L)
#define DBG_EXCEPTION_NOT_HANDLED ((DWORD )0x80010001L)
return FireEtXplatCodeSymbols(ModuleId,TotalChunks,ChunkNumber,ChunkLength,Chunk,ClrInstanceID);
}
+inline BOOL EventEnabledEventSource() {return XplatEventLogger::IsEventLoggingEnabled() && EventXplatEnabledEventSource();}
+
+inline ULONG FireEtwEventSource(
+ const signed int EventID,
+ PCWSTR EventName,
+ PCWSTR EventSourceName,
+ PCWSTR Payload
+)
+{
+ if (!EventEnabledEventSource()) {return ERROR_SUCCESS;}
+ return FireEtXplatEventSource(EventID,EventName,EventSourceName,Payload);
+}
+
inline BOOL EventEnabledCLRStackWalkDCStart() {return XplatEventLogger::IsEventLoggingEnabled() && EventXplatEnabledCLRStackWalkDCStart();}
inline ULONG FireEtwCLRStackWalkDCStart(
const BYTE* Chunk,
const unsigned short ClrInstanceID
);
+extern "C" BOOL EventXplatEnabledEventSource();
+extern "C" ULONG FireEtXplatEventSource(
+ const signed int EventID,
+ PCWSTR EventName,
+ PCWSTR EventSourceName,
+ PCWSTR Payload
+);
extern "C" BOOL EventXplatEnabledCLRStackWalkDCStart();
extern "C" ULONG FireEtXplatCLRStackWalkDCStart(
const unsigned short ClrInstanceID,
#define FireEtwDebugExceptionProcessingStart() 0
#define FireEtwDebugExceptionProcessingEnd() 0
#define FireEtwCodeSymbols(ModuleId, TotalChunks, ChunkNumber, ChunkLength, Chunk, ClrInstanceID) 0
+#define FireEtwEventSource(EventID, EventName, EventSourceName, Payload) 0
#define FireEtwCLRStackWalkDCStart(ClrInstanceID, Reserved1, Reserved2, FrameCount, Stack) 0
#define FireEtwMethodDCStart(MethodID, ModuleID, MethodStartAddress, MethodSize, MethodToken, MethodFlags) 0
#define FireEtwMethodDCStart_V1(MethodID, ModuleID, MethodStartAddress, MethodSize, MethodToken, MethodFlags, ClrInstanceID) 0
misc/error.cpp
misc/errorstrings.cpp
misc/fmtmessage.cpp
- misc/interlock.cpp
misc/miscpalapi.cpp
misc/msgbox.cpp
misc/strutil.cpp
/*++
Function:
- _rotl
-
-See MSDN doc.
---*/
-unsigned int
-__cdecl
-_rotl( unsigned int value, int shift )
-{
- unsigned int retval = 0;
-
- PERF_ENTRY(_rotl);
- ENTRY("_rotl( value:%u shift=%d )\n", value, shift );
- shift &= 0x1f;
- retval = ( value << shift ) | ( value >> ( sizeof( int ) * CHAR_BIT - shift ));
- LOGEXIT("_rotl returns unsigned int %u\n", retval);
- PERF_EXIT(_rotl);
- return retval;
-}
-
-/*++
-Function:
- _rotr
-
-See MSDN doc.
---*/
-unsigned int
-__cdecl
-_rotr( unsigned int value, int shift )
-{
- unsigned int retval;
-
- PERF_ENTRY(_rotr);
- ENTRY("_rotr( value:%u shift=%d )\n", value, shift );
- shift &= 0x1f;
- retval = ( value >> shift ) | ( value << ( sizeof( int ) * CHAR_BIT - shift ) );
- LOGEXIT("_rotr returns unsigned int %u\n", retval);
- PERF_EXIT(_rotr);
- return retval;
-}
-
-/*++
-Function:
_gcvt_s
See MSDN doc.
return Error;
}
+extern "C" BOOL EventXplatEnabledEventSource(){ return TRUE;}
+extern "C" ULONG FireEtXplatEventSource(
+ const signed int EventID,
+ PCWSTR EventName,
+ PCWSTR EventSourceName,
+ PCWSTR Payload
+)
+{
+ ULONG Error = ERROR_WRITE_FAULT;
+ if (!EventXplatEnabledEventSource()){ return ERROR_SUCCESS;};
+ INT EventName_path_size = -1;
+ INT EventName_full_name_path_size = WideCharToMultiByte( CP_ACP, 0, EventName, -1, NULL, 0, NULL, NULL );
+ CHAR* EventName_full_name=NULL;
+ INT EventSourceName_path_size = -1;
+ INT EventSourceName_full_name_path_size = WideCharToMultiByte( CP_ACP, 0, EventSourceName, -1, NULL, 0, NULL, NULL );
+ CHAR* EventSourceName_full_name=NULL;
+ INT Payload_path_size = -1;
+ INT Payload_full_name_path_size = WideCharToMultiByte( CP_ACP, 0, Payload, -1, NULL, 0, NULL, NULL );
+ CHAR* Payload_full_name=NULL;
+
+ EventName_full_name = (CHAR*)malloc(EventName_full_name_path_size*sizeof(CHAR));
+ _ASSERTE(EventName_full_name != NULL);
+ if(EventName_full_name == NULL){goto LExit;}
+
+ EventName_path_size = WideCharToMultiByte( CP_ACP, 0, EventName, -1, EventName_full_name, EventName_full_name_path_size, NULL, NULL );
+ _ASSERTE(EventName_path_size == EventName_full_name_path_size );
+ if( EventName_path_size == 0 ){ Error = ERROR_INVALID_PARAMETER; goto LExit;}
+ EventSourceName_full_name = (CHAR*)malloc(EventSourceName_full_name_path_size*sizeof(CHAR));
+ _ASSERTE(EventSourceName_full_name != NULL);
+ if(EventSourceName_full_name == NULL){goto LExit;}
+
+ EventSourceName_path_size = WideCharToMultiByte( CP_ACP, 0, EventSourceName, -1, EventSourceName_full_name, EventSourceName_full_name_path_size, NULL, NULL );
+ _ASSERTE(EventSourceName_path_size == EventSourceName_full_name_path_size );
+ if( EventSourceName_path_size == 0 ){ Error = ERROR_INVALID_PARAMETER; goto LExit;}
+ Payload_full_name = (CHAR*)malloc(Payload_full_name_path_size*sizeof(CHAR));
+ _ASSERTE(Payload_full_name != NULL);
+ if(Payload_full_name == NULL){goto LExit;}
+
+ Payload_path_size = WideCharToMultiByte( CP_ACP, 0, Payload, -1, Payload_full_name, Payload_full_name_path_size, NULL, NULL );
+ _ASSERTE(Payload_path_size == Payload_full_name_path_size );
+ if( Payload_path_size == 0 ){ Error = ERROR_INVALID_PARAMETER; goto LExit;}
+
+ tracepoint(
+ DotNETRuntime,
+ EventSource,
+ EventID,
+ EventName_full_name,
+ EventSourceName_full_name,
+ Payload_full_name
+ );
+
+ Error = ERROR_SUCCESS;
+LExit:
+ if (Payload_full_name != NULL) {free(Payload_full_name);}
+ if (EventSourceName_full_name != NULL) {free(EventSourceName_full_name);}
+ if (EventName_full_name != NULL) {free(EventName_full_name);}
+
+return Error;
+}
#include <lttng/tracepoint.h>
+#define EventSource_TRACEPOINT_ARGS \
+TP_ARGS(\
+ const signed int ,EventID,\
+ const char* ,EventName,\
+ const char* ,EventSourceName,\
+ const char* ,Payload\
+)
+TRACEPOINT_EVENT_CLASS(
+ DotNETRuntime,
+ EventSource,
+ EventSource_TRACEPOINT_ARGS,
+ TP_FIELDS(
+ ctf_integer(signed int,EventID,EventID)
+ ctf_string(EventName,EventName)
+ ctf_string(EventSourceName,EventSourceName)
+ ctf_string(Payload,Payload)
+ )
+)
+#define EventSourceT_TRACEPOINT_INSTANCE(name) \
+TRACEPOINT_EVENT_INSTANCE(\
+ DotNETRuntime,\
+ EventSource ,\
+ name ,\
+ EventSource_TRACEPOINT_ARGS \
+)
+
#define StrongNameVerification_TRACEPOINT_ARGS \
TP_ARGS(\
const unsigned int ,VerificationFlags,\
T_TRACEPOINT_INSTANCE(DebugExceptionProcessingStart)
T_TRACEPOINT_INSTANCE(DebugExceptionProcessingEnd)
CodeSymbolsT_TRACEPOINT_INSTANCE(CodeSymbols)
+EventSourceT_TRACEPOINT_INSTANCE(EventSource)
#endif /* LTTNG_CORECLR_HDotNETRuntime */
#include <lttng/tracepoint-event.h>
{
#endif // __cplusplus
-#define PAL_SHLIB_PREFIX "lib"
-
-#if __APPLE__
-#define PAL_SHLIB_SUFFIX ".dylib"
-#elif _AIX
-#define PAL_SHLIB_SUFFIX ".a"
-#elif _HPUX_
-#define PAL_SHLIB_SUFFIX ".sl"
-#else
-#define PAL_SHLIB_SUFFIX ".so"
-#endif
-
typedef BOOL (__stdcall *PDLLMAIN)(HINSTANCE, DWORD, LPVOID); /* entry point of module */
typedef HINSTANCE (PALAPI *PREGISTER_MODULE)(LPCSTR); /* used to create the HINSTANCE for above DLLMain entry point */
typedef VOID (PALAPI *PUNREGISTER_MODULE)(HINSTANCE); /* used to cleanup the HINSTANCE for above DLLMain entry point */
--*/
static HMODULE LOADLoadLibrary(LPCSTR shortAsciiName, BOOL fDynamic)
{
- CHAR * fullLibraryName;
- PathCharString fullLibraryNamePS;
HMODULE module = NULL;
HMODULE dl_handle = NULL;
// See if file can be dlopen()ed; this should work even if it's already loaded
{
// See GetProcAddress for an explanation why we leave the PAL.
- PAL_LeaveHolder holder;
-
- // P/Invokes are often declared with variations on the actual library name.
- // For example, it's common to leave off the extension/suffix of the library
- // even if it has one, or to leave off a prefix like "lib" even if it has one
- // (both of these are done typically to smooth over cross-platform differences).
- // We try to dlopen with such variations on the original.
- const char* const formatStrings[4] = // used with args: PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX
- {
- "%s%s%s", // prefix+name+suffix
- "%.0s%s%.0s", // name
- "%.0s%s%s", // name+suffix
- "%s%s%.0s", // prefix+name
- };
- const int skipPrefixing = strchr(shortAsciiName, '/') != NULL; // skip prefixing if the name is actually a path
- for (int i = 0; i < 4; i++)
- {
- if (skipPrefixing && (i == 0 || i == 3)) // 0th and 3rd strings include prefixes
- continue;
+ PAL_LeaveHolder holder;
- _ASSERTE(dl_handle == nullptr);
- fullLibraryName = fullLibraryNamePS.OpenStringBuffer(strlen(PAL_SHLIB_PREFIX)+strlen(shortAsciiName)+strlen(PAL_SHLIB_SUFFIX));
- int size = snprintf(fullLibraryName, fullLibraryNamePS.GetSizeOf(), formatStrings[i], PAL_SHLIB_PREFIX, shortAsciiName, PAL_SHLIB_SUFFIX);
- if (size < fullLibraryNamePS.GetSizeOf())
- {
- fullLibraryNamePS.CloseBuffer(size);
- dl_handle = LOADLoadLibraryDirect(fullLibraryName, false /* setLastError */);
- if (dl_handle != nullptr)
- {
- shortAsciiName = fullLibraryName;
- break;
- }
- }
- }
+ dl_handle = LOADLoadLibraryDirect(shortAsciiName, false /* setLastError */);
}
if (!dl_handle)
+++ /dev/null
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-/*++
-
-
-
-Module Name:
-
- interlock.c
-
-Abstract:
-
- Implementation of Interlocked functions for the Intel x86
- platform. These functions are processor dependent.
-
-
-
---*/
-
-#include "pal/palinternal.h"
-
-
-//
-// We need the following methods to have volatile arguments for compatibility with Win32
-//
-#undef volatile
-
-
-/*++
-Function:
- InterlockedIncrement
-
-The InterlockedIncrement function increments (increases by one) the
-value of the specified variable and checks the resulting value. The
-function prevents more than one thread from using the same variable
-simultaneously.
-
-Parameters
-
-lpAddend
- [in/out] Pointer to the variable to increment.
-
-Return Values
-
-The return value is the resulting incremented value.
-
---*/
-LONG
-PALAPI
-InterlockedIncrement(
- IN OUT LONG volatile *lpAddend)
-{
- return __sync_add_and_fetch(lpAddend, (LONG)1);
-}
-
-LONGLONG
-PALAPI
-InterlockedIncrement64(
- IN OUT LONGLONG volatile *lpAddend)
-{
- return __sync_add_and_fetch(lpAddend, (LONGLONG)1);
-}
-
-/*++
-Function:
- InterlockedDecrement
-
-The InterlockedDecrement function decrements (decreases by one) the
-value of the specified variable and checks the resulting value. The
-function prevents more than one thread from using the same variable
-simultaneously.
-
-Parameters
-
-lpAddend
- [in/out] Pointer to the variable to decrement.
-
-Return Values
-
-The return value is the resulting decremented value.
-
---*/
-LONG
-PALAPI
-InterlockedDecrement(
- IN OUT LONG volatile *lpAddend)
-{
- return __sync_sub_and_fetch(lpAddend, (LONG)1);
-}
-
-LONGLONG
-PALAPI
-InterlockedDecrement64(
- IN OUT LONGLONG volatile *lpAddend)
-{
- return __sync_sub_and_fetch(lpAddend, (LONGLONG)1);
-}
-
-/*++
-Function:
- InterlockedExchange
-
-The InterlockedExchange function atomically exchanges a pair of
-values. The function prevents more than one thread from using the same
-variable simultaneously.
-
-Parameters
-
-Target
- [in/out] Pointer to the value to exchange. The function sets
- this variable to Value, and returns its prior value.
-Value
- [in] Specifies a new value for the variable pointed to by Target.
-
-Return Values
-
-The function returns the initial value pointed to by Target.
-
---*/
-LONG
-PALAPI
-InterlockedExchange(
- IN OUT LONG volatile *Target,
- IN LONG Value)
-{
- return __sync_swap(Target, Value);
-}
-
-LONGLONG
-PALAPI
-InterlockedExchange64(
- IN OUT LONGLONG volatile *Target,
- IN LONGLONG Value)
-{
- return __sync_swap(Target, Value);
-}
-
-/*++
-Function:
- InterlockedCompareExchange
-
-The InterlockedCompareExchange function performs an atomic comparison
-of the specified values and exchanges the values, based on the outcome
-of the comparison. The function prevents more than one thread from
-using the same variable simultaneously.
-
-If you are exchanging pointer values, this function has been
-superseded by the InterlockedCompareExchangePointer function.
-
-Parameters
-
-Destination [in/out] Specifies the address of the destination value. The sign is ignored.
-Exchange [in] Specifies the exchange value. The sign is ignored.
-Comperand [in] Specifies the value to compare to Destination. The sign is ignored.
-
-Return Values
-
-The return value is the initial value of the destination.
-
---*/
-LONG
-PALAPI
-InterlockedCompareExchange(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-LONG
-PALAPI
-InterlockedCompareExchangeAcquire(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- // TODO: implement the version with only the acquire semantics
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-LONG
-PALAPI
-InterlockedCompareExchangeRelease(
- IN OUT LONG volatile *Destination,
- IN LONG Exchange,
- IN LONG Comperand)
-{
- // TODO: implement the version with only the release semantics
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-// See the 32-bit variant in interlock2.s
-LONGLONG
-PALAPI
-InterlockedCompareExchange64(
- IN OUT LONGLONG volatile *Destination,
- IN LONGLONG Exchange,
- IN LONGLONG Comperand)
-{
- return __sync_val_compare_and_swap(
- Destination, /* The pointer to a variable whose value is to be compared with. */
- Comperand, /* The value to be compared */
- Exchange /* The value to be stored */);
-}
-
-/*++
-Function:
-InterlockedExchangeAdd
-
-The InterlockedExchangeAdd function atomically adds the value of 'Value'
-to the variable that 'Addend' points to.
-
-Parameters
-
-lpAddend
-[in/out] Pointer to the variable to to added.
-
-Return Values
-
-The return value is the original value that 'Addend' pointed to.
-
---*/
-LONG
-PALAPI
-InterlockedExchangeAdd(
- IN OUT LONG volatile *Addend,
- IN LONG Value)
-{
- return __sync_fetch_and_add(Addend, Value);
-}
-
-LONGLONG
-PALAPI
-InterlockedExchangeAdd64(
- IN OUT LONGLONG volatile *Addend,
- IN LONGLONG Value)
-{
- return __sync_fetch_and_add(Addend, Value);
-}
-
-LONG
-PALAPI
-InterlockedAnd(
- IN OUT LONG volatile *Destination,
- IN LONG Value)
-{
- return __sync_fetch_and_and(Destination, Value);
-}
-
-LONG
-PALAPI
-InterlockedOr(
- IN OUT LONG volatile *Destination,
- IN LONG Value)
-{
- return __sync_fetch_and_or(Destination, Value);
-}
-
-UCHAR
-PALAPI
-InterlockedBitTestAndReset(
- IN OUT LONG volatile *Base,
- IN LONG Bit)
-{
- return (InterlockedAnd(Base, ~(1 << Bit)) & (1 << Bit)) != 0;
-}
-
-UCHAR
-PALAPI
-InterlockedBitTestAndSet(
- IN OUT LONG volatile *Base,
- IN LONG Bit)
-{
- return (InterlockedOr(Base, (1 << Bit)) & (1 << Bit)) != 0;
-}
-
-/*++
-Function:
-MemoryBarrier
-
-The MemoryBarrier function creates a full memory barrier.
-
---*/
-void
-PALAPI
-MemoryBarrier(
- VOID)
-{
- __sync_synchronize();
-}
-
-#define volatile DoNotUseVolatileKeyword
static const char RANDOM_DEVICE_NAME[] ="/dev/random";
static const char URANDOM_DEVICE_NAME[]="/dev/urandom";
+
+/*++
+
+Initialization logic for LTTng tracepoint providers.
+
+--*/
+#if defined(__LINUX__)
+
+static const char tpLibName[] = "libcoreclrtraceptprovider.so";
+
+
+/*++
+
+NOTE: PAL_InitializeTracing MUST NOT depend on anything in the PAL itself
+as it is called prior to PAL initialization.
+
+--*/
+static
+void
+PAL_InitializeTracing(void)
+{
+ // Get the path to the currently executing shared object (libcoreclr.so).
+ Dl_info info;
+ int succeeded = dladdr((void *)PAL_InitializeTracing, &info);
+ if(!succeeded)
+ {
+ return;
+ }
+
+ // Copy the path and modify the shared object name to be the tracepoint provider.
+ char tpProvPath[MAX_LONGPATH];
+ int pathLen = strlen(info.dli_fname);
+ int tpLibNameLen = strlen(tpLibName);
+
+ // Find the length of the full path without the shared object name, including the trailing slash.
+ int lastTrailingSlashLen = -1;
+ for(int i=pathLen-1; i>=0; i--)
+ {
+ if(info.dli_fname[i] == '/')
+ {
+ lastTrailingSlashLen = i+1;
+ break;
+ }
+ }
+
+ // Make sure we found the last trailing slash.
+ if(lastTrailingSlashLen == -1)
+ {
+ return;
+ }
+
+ // Make sure that the final path is shorter than MAX_PATH.
+ // +1 ensures that the string can be NULL-terminated.
+ if((lastTrailingSlashLen + tpLibNameLen + 1) > MAX_LONGPATH)
+ {
+ return;
+ }
+
+ // Copy the path without the shared object name.
+ memcpy(&tpProvPath, info.dli_fname, lastTrailingSlashLen);
+
+ // Append the shared object name for the tracepoint provider.
+ memcpy(&tpProvPath[lastTrailingSlashLen], &tpLibName, tpLibNameLen);
+
+ // NULL-terminate the string.
+ tpProvPath[lastTrailingSlashLen + tpLibNameLen] = '\0';
+
+ // Load the tracepoint provider.
+ // It's OK if this fails - that just means that tracing dependencies aren't available.
+ dlopen(tpProvPath, RTLD_NOW | RTLD_GLOBAL);
+}
+
+#endif
+
/*++
Function :
return bRet;
}
-// Define _BitScanForward64 and BitScanForward
-// Per MSDN, BitScanForward64 will search the mask data from LSB to MSB for a set bit.
-// If one is found, its bit position is returned in the outPDWORD argument and 1 is returned.
-// Otherwise, 0 is returned.
-//
-// On GCC, the equivalent function is __builtin_ffsl. It returns 1+index of the least
-// significant set bit, or 0 if if mask is zero.
-unsigned char
-PALAPI
-BitScanForward64(
- IN OUT PDWORD Index,
- IN UINT64 qwMask)
-{
- unsigned char bRet = FALSE;
- int iIndex = __builtin_ffsl(qwMask);
- if (iIndex != 0)
- {
- // Set the Index after deducting unity
- *Index = (DWORD)(iIndex-1);
- bRet = TRUE;
- }
-
- return bRet;
-}
-
-// On GCC, the equivalent function is __builtin_ffs. It returns 1+index of the least
-// significant set bit, or 0 if if mask is zero.
-unsigned char
-PALAPI
-BitScanForward(
- IN OUT PDWORD Index,
- IN UINT wMask)
-{
- unsigned char bRet = FALSE;
- int iIndex = __builtin_ffs(wMask);
- if (iIndex != 0)
- {
- // Set the Index after deducting unity
- *Index = (DWORD)(iIndex-1);
- bRet = TRUE;
- }
-
- return bRet;
-}
-
BOOL
PALAPI
PAL_Random(
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test1.c
+ test1.cpp
)
add_executable(paltest_rotl_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test1.c
+ test1.cpp
)
add_executable(paltest_rotr_test1
win_Binary,
win_UInt16
);
+ EventXplatEnabledEventSource();
+Error |= FireEtXplatEventSource(
+win_Int32,
+W(" Testing UnicodeString "),
+W(" Testing UnicodeString "),
+W(" Testing UnicodeString ")
+);
EventXplatEnabledCLRStackWalkDCStart();
Error |= FireEtXplatCLRStackWalkDCStart(
win_UInt16,
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchangeadd_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedbit_test1
TEST_DATA test_data[] =
{
- { 0x00000000, 3, 0x00000000, 0 },
- { 0x12341234, 2, 0x12341230, 1 },
- { 0x12341234, 3, 0x12341234, 0 },
- { 0x12341234, 31, 0x12341234, 0 },
- { 0x12341234, 28, 0x02341234, 1 },
- { 0xffffffff, 28, 0xefffffff, 1 }
+ { (LONG)0x00000000, 3, (LONG)0x00000000, 0 },
+ { (LONG)0x12341234, 2, (LONG)0x12341230, 1 },
+ { (LONG)0x12341234, 3, (LONG)0x12341234, 0 },
+ { (LONG)0x12341234, 31, (LONG)0x12341234, 0 },
+ { (LONG)0x12341234, 28, (LONG)0x02341234, 1 },
+ { (LONG)0xffffffff, 28, (LONG)0xefffffff, 1 }
};
int __cdecl main(int argc, char *argv[]) {
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedbit_test2
TEST_DATA test_data[] =
{
- { 0x00000000, 2, 0x00000004, 0 },
- { 0x12341234, 2, 0x12341234, 1 },
- { 0x12341234, 3, 0x1234123c, 0 },
- { 0x12341234, 31, 0x92341234, 0 },
- { 0x12341234, 28, 0x12341234, 1 },
- { 0xffffffff, 28, 0xffffffff, 1 }
+ { (LONG)0x00000000, 2, (LONG)0x00000004, 0 },
+ { (LONG)0x12341234, 2, (LONG)0x12341234, 1 },
+ { (LONG)0x12341234, 3, (LONG)0x1234123c, 0 },
+ { (LONG)0x12341234, 31, (LONG)0x92341234, 0 },
+ { (LONG)0x12341234, 28, (LONG)0x12341234, 1 },
+ { (LONG)0xffffffff, 28, (LONG)0xffffffff, 1 }
};
int __cdecl main(int argc, char *argv[]) {
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchange64_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedcompareexchangepointer_test1
(5 in this case)
*/
- if((int)ReturnValue != 5)
+ if((int)(size_t)ReturnValue != 5)
{
Fail("ERROR: The return value should be the value of the "
"variable before the exchange took place, which was 5. "
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockeddecrement64_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchange_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedexchange64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- InterlockedExchangePointer.c
+ InterlockedExchangePointer.cpp
)
add_executable(paltest_interlockedexchangepointer_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement_test2
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement64_test1
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SOURCES
- test.c
+ test.cpp
)
add_executable(paltest_interlockedincrement64_test2
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
-
// GuidFromName
-// Algorithm from Internet Draft document "UUIDs and GUIDs"
-// By Paul J. Leach and Rich Sals, February 4, 1998.
-
-// This function has been adapted from the routines in the document
-// uuid_create_from_name and format_uuid_v3
-
-// Changes from documented routines:
-// 1. Changed all instances of uuid_t to GUID.
-// uuid_t field time_low is GUID field Data1.
-// uuid_t field time_mid is GUID field Data2.
-// uuid_t field time_hi_and_version is GUID field Data3.
-// uuid_t field clock_seq_hi_and_reserved is GUID field Data4[0].
-// uuid_t field clock_seq_low is GUID field Data4[1].
-// uuid_t field node[6] is GUID field Data4[2] through Data4[8].
-//
-// 2. Use a c++ implementation of the md5 cryptographic hash function.
-//
-// 3. Implemented the htonl, htons, ntohl, ntohs socket routines as inlines.
-//
-// 4. Renamed variables and types to suit my biases.
-
-/*
-** Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
-** Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
-** Digital Equipment Corporation, Maynard, Mass.
-** To anyone who acknowledges that this file is provided "AS IS"
-** without any express or implied warranty: permission to use, copy,
-** modify, and distribute this file for any purpose is hereby
-** granted without fee, provided that the above copyright notices and
-** this notice appears in all source code copies, and that none of
-** the names of Open Software Foundation, Inc., Hewlett-Packard
-** Company, or Digital Equipment Corporation be used in advertising
-** or publicity pertaining to distribution of the software without
-** specific, written prior permission. Neither Open Software
-** Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
-** Corporation makes any representations about the suitability of
-** this software for any purpose.
+/**
+
+Algorithm from Internet Draft document "UUIDs and GUIDs"
+By Paul J. Leach and Rich Sals, February 4, 1998.
+
+This function has been adapted from the routines in the document
+ uuid_create_from_name and format_uuid_v3
+
+Changes from documented routines:
+1. Changed all instances of uuid_t to GUID.
+ uuid_t field time_low is GUID field Data1.
+ uuid_t field time_mid is GUID field Data2.
+ uuid_t field time_hi_and_version is GUID field Data3.
+ uuid_t field clock_seq_hi_and_reserved is GUID field Data4[0].
+ uuid_t field clock_seq_low is GUID field Data4[1].
+ uuid_t field node[6] is GUID field Data4[2] through Data4[8].
+
+2. Use a c++ implementation of the md5 cryptographic hash function.
+
+3. Implemented the htonl, htons, ntohl, ntohs socket routines as inlines.
+
+4. Renamed variables and types to suit my biases.
+
+
+Copyright (c) 1990- 1993, 1996 Open Software Foundation, Inc.
+Copyright (c) 1989 by Hewlett-Packard Company, Palo Alto, Ca. &
+Digital Equipment Corporation, Maynard, Mass.
+To anyone who acknowledges that this file is provided "AS IS"
+without any express or implied warranty: permission to use, copy,
+modify, and distribute this file for any purpose is hereby
+granted without fee, provided that the above copyright notices and
+this notice appears in all source code copies, and that none of
+the names of Open Software Foundation, Inc., Hewlett-Packard
+Company, or Digital Equipment Corporation be used in advertising
+or publicity pertaining to distribution of the software without
+specific, written prior permission. Neither Open Software
+Foundation, Inc., Hewlett-Packard Company, Microsoft, nor Digital Equipment
+Corporation makes any representations about the suitability of
+this software for any purpose.
+
+
+Copyright(C) The Internet Society 1997. All Rights Reserved.
+
+This document and translations of it may be copied and furnished to others,
+and derivative works that comment on or otherwise explain it or assist in
+its implementation may be prepared, copied, published and distributed, in
+whole or in part, without restriction of any kind, provided that the above
+copyright notice and this paragraph are included on all such copies and
+derivative works.However, this document itself may not be modified in any
+way, such as by removing the copyright notice or references to the Internet
+Society or other Internet organizations, except as needed for the purpose of
+developing Internet standards in which case the procedures for copyrights
+defined in the Internet Standards process must be followed, or as required
+to translate it into languages other than English.
+
+The limited permissions granted above are perpetual and will not be revoked
+by the Internet Society or its successors or assigns.
+
+This document and the information contained herein is provided on an "AS IS"
+basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING TASK FORCE
+DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
+ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY
+RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
+PARTICULAR PURPOSE.
+
*/
#include "stdafx.h"
<!--Templates-->
<templates>
+ <template tid="EventSource">
+ <data name="EventID" inType="win:Int32" />
+ <data name="EventName" inType="win:UnicodeString" />
+ <data name="EventSourceName" inType="win:UnicodeString" />
+ <data name="Payload" inType="win:UnicodeString" />
+
+ <UserData>
+ <EventSource xmlns="myNs">
+ <EventID> %1 </EventID>
+ <EventName> %2 </EventName>
+ <EventSourceName> %3 </EventSourceName>
+ <Payload> %4 </Payload>
+ </EventSource>
+ </UserData>
+ </template>
<template tid="StrongNameVerification">
<data name="VerificationFlags" inType="win:UInt32" outType="win:HexInt32"/>
<data name="ErrorCode" inType="win:UInt32" outType="win:HexInt32"/>
keywords="CodeSymbolsKeyword" opcode="win:Start"
task="CodeSymbols"
symbol="CodeSymbols" message="$(string.RuntimePublisher.CodeSymbolsEventMessage)"/>
+
+ <event value="270" version="0" level="win:Informational" template="EventSource"
+ opcode="win:Start"
+ symbol="EventSource" />
</events>
</provider>
##########################
# GarbageCollection events
##########################
+noclrinstanceid::::EventSource
noclrinstanceid:GarbageCollection:::GCStart
nostack:GarbageCollection:::GCStart
nomac:GarbageCollection:::GCStart_V1
}
#endif //defined(FEATURE_HOST_ASSEMBLY_RESOLVER)
-/* static */
-HINSTANCE NDirect::LoadLibraryModule( NDirectMethodDesc * pMD, LoadLibErrorTracker * pErrorTracker)
+// Try to load the module alongside the assembly where the PInvoke was declared.
+HMODULE NDirect::LoadFromPInvokeAssemblyDirectory(NDirectMethodDesc *pMD, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker)
+{
+ STANDARD_VM_CONTRACT;
+
+ HMODULE hmod = NULL;
+
+ Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly();
+ SString path = pAssembly->GetManifestFile()->GetPath();
+
+ SString::Iterator lastPathSeparatorIter = path.End();
+ if (PEAssembly::FindLastPathSeparator(path, lastPathSeparatorIter))
+ {
+ lastPathSeparatorIter++;
+ path.Truncate(lastPathSeparatorIter);
+
+ path.Append(libName);
+ hmod = LocalLoadLibraryHelper(path, flags, pErrorTracker);
+ }
+
+ return hmod;
+}
+
+// Try to load the module from the native DLL search directories
+HMODULE NDirect::LoadFromNativeDllSearchDirectories(AppDomain* pDomain, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker)
+{
+ STANDARD_VM_CONTRACT;
+
+ HMODULE hmod = NULL;
+
+ if (pDomain->HasNativeDllSearchDirectories())
+ {
+ AppDomain::PathIterator pathIter = pDomain->IterateNativeDllSearchDirectories();
+ while (hmod == NULL && pathIter.Next())
+ {
+ SString qualifiedPath(*(pathIter.GetPath()));
+ qualifiedPath.Append(libName);
+ if (!Path::IsRelative(qualifiedPath))
+ {
+ hmod = LocalLoadLibraryHelper(qualifiedPath, flags, pErrorTracker);
+ }
+ }
+ }
+
+ return hmod;
+}
+
+HINSTANCE NDirect::LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracker * pErrorTracker)
{
CONTRACTL
{
{
W("mscorpe.dll"), W("mscorpe")
};
-
+
for (int i = 0; i < COUNTOF(rgSxSAwareDlls); i++)
{
if (SString::_wcsicmp(wszLibName, rgSxSAwareDlls[i]) == 0)
DWORD dllImportSearchPathFlag = 0;
BOOL searchAssemblyDirectory = TRUE;
+ bool libNameIsRelativePath = Path::IsRelative(wszLibName);
if (hmod == NULL)
{
#ifndef FEATURE_CORECLR
attributeIsFound = TRUE;
}
}
-
+
if (!attributeIsFound)
{
CheckUnificationList(pMD, &dllImportSearchPathFlag, &searchAssemblyDirectory);
}
#endif // !FEATURE_CORECLR
- if (!Path::IsRelative(wszLibName))
+ if (!libNameIsRelativePath)
{
DWORD flags = loadWithAlteredPathFlags;
if ((dllImportSearchPathFlag & LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR) != 0)
}
else if (searchAssemblyDirectory)
{
- // Try to load the DLL alongside the assembly where the PInvoke was
- // declared using the path of the assembly.
- Assembly* pAssembly = pMD->GetMethodTable()->GetAssembly();
-
- SString path = pAssembly->GetManifestFile()->GetPath();
- SString::Iterator i = path.End();
-
- if (PEAssembly::FindLastPathSeparator(path, i))
- {
- i++;
- path.Truncate(i);
-
- path.Append(wszLibName);
-
- hmod = LocalLoadLibraryHelper(path, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker);
- }
+ hmod = LoadFromPInvokeAssemblyDirectory(pMD, wszLibName, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker);
#ifndef FEATURE_CORECLR
if (hmod == NULL)
- {
+ {
// Try to load the DLL alongside the assembly where the PInvoke was
// declared using the codebase of the assembly. This is required for download
// and shadow copy scenarios.
const WCHAR* ptr;
- SString codebase;
+ SString codebase;
pAssembly->GetCodeBase(codebase);
DWORD dwCodebaseLength = codebase.GetCount();
-
+
// Strip off the protocol
for (ptr = codebase.GetUnicode(); *ptr && *ptr != W(':'); ptr++);
SString pathFromCodebase;
// After finding the colon move forward until no more forward slashes
- for(ptr++; *ptr && *ptr == W('/'); ptr++);
+ for (ptr++; *ptr && *ptr == W('/'); ptr++);
if (*ptr)
{
// Calculate the number of characters we are interested in
if (tail > ptr)
{
- for(;ptr <= tail; ptr++)
+ for (;ptr <= tail; ptr++)
{
- if(*ptr == W('/'))
+ if (*ptr == W('/'))
pathFromCodebase.Append(W('\\'));
else
pathFromCodebase.Append(*ptr);
}
#ifdef FEATURE_CORECLR
- if (hmod == NULL && pDomain->HasNativeDllSearchDirectories())
+ if (hmod == NULL)
{
- AppDomain::PathIterator i = pDomain->IterateNativeDllSearchDirectories();
- while (hmod == NULL && i.Next())
- {
- SString qualifiedPath(*(i.GetPath()));
- qualifiedPath.Append(wszLibName);
- if (!Path::IsRelative(qualifiedPath))
- {
- hmod = LocalLoadLibraryHelper(qualifiedPath, loadWithAlteredPathFlags, pErrorTracker);
- }
- }
+ LoadFromNativeDllSearchDirectories(pDomain, wszLibName, loadWithAlteredPathFlags, pErrorTracker);
}
+
#endif // FEATURE_CORECLR
- // Do we really need to do this. This call searches the application directory
- // instead of the location for the library.
- if(hmod == NULL)
+ // This call searches the application directory instead of the location for the library.
+ if (hmod == NULL)
{
hmod = LocalLoadLibraryHelper(wszLibName, dllImportSearchPathFlag, pErrorTracker);
}
}
}
+#ifdef FEATURE_PAL
+ if (hmod == NULL)
+ {
+ // P/Invokes are often declared with variations on the actual library name.
+ // For example, it's common to leave off the extension/suffix of the library
+ // even if it has one, or to leave off a prefix like "lib" even if it has one
+ // (both of these are typically done to smooth over cross-platform differences).
+ // We try to dlopen with such variations on the original.
+ const char* const prefixSuffixCombinations[] =
+ {
+ "%s%s%s", // prefix+name+suffix
+ "%.0s%s%s", // name+suffix
+ "%s%s%.0s", // prefix+name
+ };
+
+ const int NUMBER_OF_LIB_NAME_VARIATIONS = COUNTOF(prefixSuffixCombinations);
+
+ // Try to load from places we tried above, but this time with variations on the
+ // name including the prefix, suffix, and both.
+ for (int i = 0; i < NUMBER_OF_LIB_NAME_VARIATIONS; i++)
+ {
+ SString currLibNameVariation;
+ currLibNameVariation.Printf(prefixSuffixCombinations[i], PAL_SHLIB_PREFIX, name, PAL_SHLIB_SUFFIX);
+
+ if (libNameIsRelativePath && searchAssemblyDirectory)
+ {
+ hmod = LoadFromPInvokeAssemblyDirectory(pMD, currLibNameVariation, loadWithAlteredPathFlags | dllImportSearchPathFlag, pErrorTracker);
+ if (hmod != NULL)
+ break;
+ }
+
+ hmod = LoadFromNativeDllSearchDirectories(pDomain, currLibNameVariation, loadWithAlteredPathFlags, pErrorTracker);
+ if (hmod != NULL)
+ break;
+
+ hmod = LocalLoadLibraryHelper(currLibNameVariation, dllImportSearchPathFlag, pErrorTracker);
+ if (hmod != NULL)
+ break;
+ }
+ }
+#endif // FEATURE_PAL
+
// After all this, if we have a handle add it to the cache.
if (hmod)
{
return hmod.Extract();
}
-
//---------------------------------------------------------
// Loads the DLL and finds the procaddress for an N/Direct call.
//---------------------------------------------------------
//
if (!pMD->GetModule()->GetSecurityDescriptor()->CanCallUnmanagedCode())
- Security::ThrowSecurityException(g_SecurityPermissionClassName, SPFLAGSUNMANAGEDCODE);
+ Security::ThrowSecurityException(g_SecurityPermissionClassName, SPFLAGSUNMANAGEDCODE);
if (!pMD->IsZapped())
{
pMD->CheckRestore();
- NDirect::NDirectLink(pMD);
+ NDirect::NDirectLink(pMD);
}
}
static LPVOID NDirectGetEntryPoint(NDirectMethodDesc *pMD, HINSTANCE hMod);
static HMODULE LoadLibraryFromPath(LPCWSTR libraryPath);
static HINSTANCE LoadLibraryModule(NDirectMethodDesc * pMD, LoadLibErrorTracker *pErrorTracker);
-
+
#ifndef FEATURE_CORECLR
static VOID CheckUnificationList(NDirectMethodDesc * pMD, DWORD * pDllImportSearchPathFlag, BOOL * pSearchAssemblyDirectory);
#endif // !FEATURE_CORECLR
private:
NDirect() {LIMITED_METHOD_CONTRACT;}; // prevent "new"'s on this class
+ static HMODULE LoadFromNativeDllSearchDirectories(AppDomain* pDomain, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker);
+ static HMODULE LoadFromPInvokeAssemblyDirectory(NDirectMethodDesc *pMD, LPCWSTR libName, DWORD flags, LoadLibErrorTracker *pErrorTracker);
+
#if defined(FEATURE_HOST_ASSEMBLY_RESOLVER)
static HMODULE LoadLibraryModuleViaHost(NDirectMethodDesc * pMD, AppDomain* pDomain, const wchar_t* wszLibName);
#endif //defined(FEATURE_HOST_ASSEMBLY_RESOLVER)
FCFuncEnd()
#endif // ifdef FEATURE_COMINTEROP
+#if defined(FEATURE_EVENTSOURCE_XPLAT)
+FCFuncStart(gEventLogger)
+ QCFuncElement("IsEventSourceLoggingEnabled", XplatEventSourceLogger::IsEventSourceLoggingEnabled)
+ QCFuncElement("LogEventSource", XplatEventSourceLogger::LogEventSource)
+FCFuncEnd()
+#endif // defined(FEATURE_EVENTSOURCE_XPLAT)
+
#ifdef FEATURE_COMINTEROP
FCFuncStart(gRuntimeClassFuncs)
FCFuncElement("GetRedirectedGetHashCodeMD", ComObject::GetRedirectedGetHashCodeMD)
#ifdef FEATURE_X509
FCClassElement("X509Utils", "System.Security.Cryptography.X509Certificates", gX509CertificateFuncs)
#endif // FEATURE_X509
+#if defined(FEATURE_EVENTSOURCE_XPLAT)
+FCClassElement("XplatEventLogger", "System.Diagnostics.Tracing", gEventLogger)
+#endif //defined(FEATURE_EVENTSOURCE_XPLAT)
#ifdef FEATURE_CAS_POLICY
FCClassElement("Zone", "System.Security.Policy", gCOMSecurityZone)
#endif // FEATURE_CAS_POLICY
}
}
+#if defined(FEATURE_EVENTSOURCE_XPLAT)
+
+void QCALLTYPE XplatEventSourceLogger::LogEventSource(__in_z int eventID, __in_z LPCWSTR eventName, __in_z LPCWSTR eventSourceName, __in_z LPCWSTR payload)
+{
+ QCALL_CONTRACT;
+
+ BEGIN_QCALL;
+ FireEtwEventSource(eventID, eventName, eventSourceName, payload);
+ END_QCALL;
+}
+
+BOOL QCALLTYPE XplatEventSourceLogger::IsEventSourceLoggingEnabled()
+{
+ QCALL_CONTRACT;
+
+ BOOL retVal = FALSE;
+
+ BEGIN_QCALL;
+ retVal = XplatEventLogger::IsEventLoggingEnabled();
+ END_QCALL;
+
+ return retVal;
+
+}
+
+#endif //defined(FEATURE_EVENTSOURCE_XPLAT)
+
#endif // !FEATURE_REDHAWK
#endif // __EVENTTRACEPRIV_H__
+
+#if defined(FEATURE_EVENTSOURCE_XPLAT)
+class XplatEventSourceLogger
+{
+public:
+ static void QCALLTYPE LogEventSource(__in_z int eventID, __in_z LPCWSTR eventName, __in_z LPCWSTR eventSourceName, __in_z LPCWSTR payload);
+
+ static BOOL QCALLTYPE IsEventSourceLoggingEnabled();
+};
+
+#endif //defined(FEATURE_EVENTSOURCE_XPLAT)
#include "windowsruntimebufferhelper.h"
#endif
-#endif // CROSSGEN_MSCORLIB
+#if defined(FEATURE_EVENTSOURCE_XPLAT)
+#define __EVENTTRACEPRIV_H__
+#include "eventtracepriv.h"
+#undef __EVENTTRACEPRIV_H__
+#endif //defined(FEATURE_EVENTSOURCE_XPLAT)
+#endif // CROSSGEN_MSCORLIB
#ifdef CROSSGEN_MSCORLIB
#ifndef DACCESS_COMPILE
#ifdef FEATURE_IMPLICIT_TLS
-EXTERN_C Thread* STDCALL GetThread()
-{
- return gCurrentThreadInfo.m_pThread;
-}
-
-EXTERN_C AppDomain* STDCALL GetAppDomain()
-{
- return gCurrentThreadInfo.m_pAppDomain;
-}
-
BOOL SetThread(Thread* t)
{
LIMITED_METHOD_CONTRACT
#include "appdomain.hpp"
#include "frames.h"
+#ifndef DACCESS_COMPILE
+#ifdef FEATURE_IMPLICIT_TLS
+
+#ifndef __llvm__
+EXTERN_C __declspec(thread) ThreadLocalInfo gCurrentThreadInfo;
+#else // !__llvm__
+EXTERN_C __thread ThreadLocalInfo gCurrentThreadInfo;
+#endif // !__llvm__
+
+EXTERN_C inline Thread* STDCALL GetThread()
+{
+ return gCurrentThreadInfo.m_pThread;
+}
+
+EXTERN_C inline AppDomain* STDCALL GetAppDomain()
+{
+ return gCurrentThreadInfo.m_pAppDomain;
+}
+
+#endif // FEATURE_IMPLICIT_TLS
+#endif // !DACCESS_COMPILE
+
#ifdef ENABLE_GET_THREAD_GENERIC_FULL_CHECK
// See code:GetThreadGenericFullCheck
inline /* static */ BOOL Thread::ShouldEnforceEEThreadNotRequiredContracts()
Interop/ICastable/Castable.sh
-Interop/ReversePInvoke/Marshalling/MarshalBoolArray.sh
JIT/Directed/lifetime/lifetime2.sh
JIT/Directed/newarr/newarr.sh
JIT/Directed/PREFIX/unaligned/1/arglist.sh